-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
523 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/main/java/com/clockwise/tworcy/model/game/GameArchiveData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.clockwise.tworcy.model.game; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.annotations.Type; | ||
import org.joda.time.DateTime; | ||
|
||
/** | ||
* Defines Game added by users of the page. | ||
* @author Daniel | ||
* | ||
*/ | ||
@Entity | ||
@Table(name = "GameArchiveData") | ||
public class GameArchiveData { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id", nullable = false) | ||
private int id; | ||
|
||
@Column(name = "gameId", nullable = false) | ||
private int gameId; | ||
|
||
@Column(name = "authorId", nullable = false) | ||
private int authorId; | ||
|
||
@Column(name = "media", nullable = true) | ||
private String media; | ||
|
||
@Column(name = "title", nullable = false) | ||
private String title; | ||
|
||
@Column(name = "description", nullable = false) | ||
private String description; | ||
|
||
@Column(name = "dateAdded", nullable = false) | ||
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") | ||
private DateTime dateAdded; | ||
|
||
@Column(name = "dateUpdated", nullable = true) | ||
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime") | ||
private DateTime dateUpdated; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
public int getGameId() { | ||
return gameId; | ||
} | ||
|
||
public int getAuthorId() { | ||
return authorId; | ||
} | ||
|
||
public String getMedia() { | ||
return media; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public DateTime getDateAdded() { | ||
return dateAdded; | ||
} | ||
|
||
public DateTime getDateUpdated() { | ||
return dateUpdated; | ||
} | ||
|
||
|
||
void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
void setGameId(int gameId) { | ||
this.gameId = gameId; | ||
} | ||
|
||
void setAuthorId(int authorId) { | ||
this.authorId = authorId; | ||
} | ||
|
||
public void setMedia(String media) { | ||
this.media = media; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
void setDateAdded(DateTime dateAdded) { | ||
this.dateAdded = dateAdded; | ||
} | ||
|
||
void setDateUpdated(DateTime dateUpdated) { | ||
this.dateUpdated = dateUpdated; | ||
} | ||
|
||
public void setDefault() { | ||
gameId = 0; | ||
authorId = 0; | ||
media = null; | ||
title = null; | ||
description = null; | ||
dateAdded = null; | ||
dateUpdated = null; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/main/java/com/clockwise/tworcy/model/game/GameConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.clockwise.tworcy.model.game; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.clockwise.tworcy.util.JSONUtils; | ||
|
||
@Service class GameConverter { | ||
|
||
private @Autowired JSONUtils json; | ||
GameData toData(Game game) { | ||
GameData data = new GameData(); | ||
data.setGameId(game.getGameId()); | ||
data.setAuthorId(game.getAuthorId()); | ||
data.setMedia(json.stringArrayToJSON(game.getMedia())); | ||
data.setTitle(game.getTitle()); | ||
data.setDescription(game.getDescription()); | ||
data.setDateAdded(game.getDateAdded()); | ||
data.setDateUpdated(game.getDateUpdated()); | ||
return data; | ||
} | ||
GameData toData(Game game, GameData data) { | ||
data.setGameId(game.getGameId()); | ||
data.setAuthorId(game.getAuthorId()); | ||
data.setMedia(json.stringArrayToJSON(game.getMedia())); | ||
data.setTitle(game.getTitle()); | ||
data.setDescription(game.getDescription()); | ||
data.setDateAdded(game.getDateAdded()); | ||
data.setDateUpdated(game.getDateUpdated()); | ||
return data; | ||
} | ||
GameData toData(GameArchiveData archive) { | ||
GameData data = new GameData(); | ||
data.setGameId(archive.getGameId()); | ||
data.setAuthorId(archive.getAuthorId()); | ||
data.setMedia(archive.getMedia()); | ||
data.setTitle(archive.getTitle()); | ||
data.setDescription(archive.getDescription()); | ||
data.setDateAdded(archive.getDateAdded()); | ||
data.setDateUpdated(archive.getDateUpdated()); | ||
return data; | ||
} | ||
|
||
Game toGame(GameData data) { | ||
Game game = new Game(); | ||
game.setGameId(data.getGameId()); | ||
game.setAuthorId(data.getAuthorId()); | ||
game.setMedia(json.stringListFromJSON(data.getMedia())); | ||
game.setTitle(data.getTitle()); | ||
game.setDescription(data.getDescription()); | ||
game.setDateAdded(data.getDateAdded()); | ||
game.setDateUpdated(data.getDateUpdated()); | ||
return game; | ||
} | ||
Game toGame(GameData data, Game game) { | ||
game.setGameId(data.getGameId()); | ||
game.setAuthorId(data.getAuthorId()); | ||
game.setMedia(json.stringListFromJSON(data.getMedia())); | ||
game.setTitle(data.getTitle()); | ||
game.setDescription(data.getDescription()); | ||
game.setDateAdded(data.getDateAdded()); | ||
game.setDateUpdated(data.getDateUpdated()); | ||
return game; | ||
} | ||
|
||
GameArchiveData toArchive(GameData data) { | ||
GameArchiveData archive = new GameArchiveData(); | ||
archive.setGameId(data.getGameId()); | ||
archive.setAuthorId(data.getAuthorId()); | ||
archive.setMedia(data.getMedia()); | ||
archive.setTitle(data.getTitle()); | ||
archive.setDescription(data.getDescription()); | ||
archive.setDateAdded(data.getDateAdded()); | ||
archive.setDateUpdated(data.getDateUpdated()); | ||
|
||
return archive; | ||
} | ||
} |
Oops, something went wrong.