Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #34

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Database-Storage/DB.mwb
Binary file not shown.
Binary file modified Database-Storage/DB.mwb.bak
Binary file not shown.
12 changes: 7 additions & 5 deletions Database-Storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>com.github.javydreamercsw</groupId>
<artifactId>Database-Storage</artifactId>
<name>Database</name>
<name>Tournament Manager Database</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
Expand Down Expand Up @@ -42,27 +42,29 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.198</version>
<type>jar</type>
<version>1.4.199</version>
</dependency>
<dependency>
<groupId>com.googlecode.flyway</groupId>
<artifactId>flyway-core</artifactId>
<version>2.3.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ public class Game implements Serializable
private Integer id;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "game")
private List<Format> formatList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "game")
private List<Record> recordList;

public Game()
{
Expand Down Expand Up @@ -119,17 +117,6 @@ public String toString()
return "com.github.javydreamercsw.database.storage.db.Game[ id=" + id + " ]";
}

@XmlTransient
public List<Record> getRecordList()
{
return recordList;
}

public void setRecordList(List<Record> recordList)
{
this.recordList = recordList;
}

public String getName()
{
return name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
})
public class MatchEntry implements Serializable
{
private static final long serialVersionUID = 3610712802330920081L;
private static final long serialVersionUID = -8541562626617426725L;
@EmbeddedId
protected MatchEntryPK matchEntryPK;
@Basic(optional = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,9 @@ public class Player implements Serializable
})
@ManyToMany
private List<Team> teamList;
@JoinTable(name = "player_has_record", joinColumns =
{
@JoinColumn(name = "player_id", referencedColumnName = "id")
}, inverseJoinColumns =
{
@JoinColumn(name = "record_id", referencedColumnName = "id"),
@JoinColumn(name = "record_game_id", referencedColumnName = "game_id")
})
@ManyToMany
private List<Record> recordList;

public Player()
{
recordList = new ArrayList<>();
teamList = new ArrayList<>();
}

Expand Down Expand Up @@ -115,17 +104,6 @@ public void setTeamList(List<Team> teamList)
this.teamList = teamList;
}

@XmlTransient
public List<Record> getRecordList()
{
return recordList;
}

public void setRecordList(List<Record> recordList)
{
this.recordList = recordList;
}

@Override
public int hashCode()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
Expand All @@ -25,40 +26,45 @@
@NamedQueries(
{
@NamedQuery(name = "Record.findAll", query = "SELECT r FROM Record r"),
@NamedQuery(name = "Record.findById",
query = "SELECT r FROM Record r WHERE r.recordPK.id = :id"),
@NamedQuery(name = "Record.findByWins",
query = "SELECT r FROM Record r WHERE r.wins = :wins"),
@NamedQuery(name = "Record.findByLoses",
query = "SELECT r FROM Record r WHERE r.loses = :loses"),
query = "SELECT r FROM Record r WHERE r.losses = :losses"),
@NamedQuery(name = "Record.findByDraws",
query = "SELECT r FROM Record r WHERE r.draws = :draws"),
@NamedQuery(name = "Record.findByGameId",
query = "SELECT r FROM Record r WHERE r.recordPK.gameId = :gameId")
})
public class Record implements Serializable
{
private static final long serialVersionUID = -893880954416960217L;
@EmbeddedId
protected RecordPK recordPK;
private static final long serialVersionUID = -587143815558105193L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Basic(optional = false)
@NotNull
@Column(name = "wins")
private int wins;
@Basic(optional = false)
@NotNull
@Column(name = "loses")
private int loses;
@Column(name = "losses")
private int losses;
@Basic(optional = false)
@NotNull
@Column(name = "draws")
private int draws;
@ManyToMany(mappedBy = "recordList")
private List<Player> playerList;
@JoinTable(name = "team_has_record", joinColumns =
{
@JoinColumn(name = "record_id", referencedColumnName = "id")
}, inverseJoinColumns =
{
@JoinColumn(name = "team_id", referencedColumnName = "id")
})
@ManyToMany
private List<Team> teamList;
@JoinTable(name = "tournament_has_team_has_record", joinColumns =
{
@JoinColumn(name = "record_id", referencedColumnName = "id"),
@JoinColumn(name = "record_game_id", referencedColumnName = "game_id")
}, inverseJoinColumns =
{
@JoinColumn(name = "tournament_has_team_tournament_id",
Expand All @@ -68,77 +74,53 @@ public class Record implements Serializable
})
@ManyToMany
private List<TournamentHasTeam> tournamentHasTeamList;
@JoinColumn(name = "game_id", referencedColumnName = "id", insertable = false,
updatable = false)
@ManyToOne(optional = false)
private Game game;

public Record()
{
this(0, 0, 0);
}

public Record(int wins, int loses, int draws)
public Record(int wins, int losses, int draws)
{
this.wins = wins;
this.loses = loses;
this.losses = losses;
this.draws = draws;
tournamentHasTeamList = new ArrayList<>();
playerList = new ArrayList<>();
}

public Record(int gameId)
{
this.recordPK = new RecordPK(gameId);
teamList = new ArrayList<>();
}

public RecordPK getRecordPK()
{
return recordPK;
}

public void setRecordPK(RecordPK recordPK)
@XmlTransient
public List<TournamentHasTeam> getTournamentHasTeamList()
{
this.recordPK = recordPK;
return tournamentHasTeamList;
}


public Game getGame()
public void setTournamentHasTeamList(List<TournamentHasTeam> tournamentHasTeamList)
{
return game;
this.tournamentHasTeamList = tournamentHasTeamList;
}

public void setGame(Game game)
public Record(Integer id)
{
this.game = game;
this.id = id;
}

@Override
public int hashCode()
public Record(Integer id, int wins, int losses, int draws)
{
int hash = 0;
hash += (recordPK != null ? recordPK.hashCode() : 0);
return hash;
this.id = id;
this.wins = wins;
this.losses = losses;
this.draws = draws;
}

@Override
public boolean equals(Object object)
public Integer getId()
{
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Record))
{
return false;
}
Record other = (Record) object;
return !((this.recordPK == null && other.recordPK != null)
|| (this.recordPK != null && !this.recordPK.equals(other.recordPK)));
return id;
}

@Override
public String toString()
public void setId(Integer id)
{
return "com.github.javydreamercsw.database.storage.db.Record[ recordPK="
+ recordPK + " ]";
this.id = id;
}

public int getWins()
Expand All @@ -151,14 +133,14 @@ public void setWins(int wins)
this.wins = wins;
}

public int getLoses()
public int getLosses()
{
return loses;
return losses;
}

public void setLoses(int loses)
public void setLosses(int losses)
{
this.loses = loses;
this.losses = losses;
}

public int getDraws()
Expand All @@ -172,25 +154,40 @@ public void setDraws(int draws)
}

@XmlTransient
public List<Player> getPlayerList()
public List<Team> getTeamList()
{
return playerList;
return teamList;
}

public void setPlayerList(List<Player> playerList)
public void setTeamList(List<Team> teamList)
{
this.playerList = playerList;
this.teamList = teamList;
}

@XmlTransient
public List<TournamentHasTeam> getTournamentHasTeamList()
@Override
public int hashCode()
{
return tournamentHasTeamList;
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}

public void setTournamentHasTeamList(List<TournamentHasTeam> tournamentHasTeamList)
@Override
public boolean equals(Object object)
{
this.tournamentHasTeamList = tournamentHasTeamList;
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Record))
{
return false;
}
Record other = (Record) object;
return !((this.id == null && other.id != null) || (this.id != null
&& !this.id.equals(other.id)));
}

@Override
public String toString()
{
return "com.github.javydreamercsw.database.storage.db.Record[ id=" + id + " ]";
}

}
Loading