Commit 69904e1f by Antti Tonkyra

TournamentStuff

1 parent 2ee18976
......@@ -29,6 +29,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "" }); // first version, no changes
dbUpdates.add(new String[] { "ALTER TABLE tournaments ADD COLUMN game integer NOT NULL REFERENCES tournament_games(id)" });
dbUpdates.add(new String[] { "ALTER TABLE tournaments ADD COLUMN rules integer NOT NULL REFERENCES tournament_rules(id)" });
dbUpdates.add(new String[] { "ALTER TABLE tournaments ADD COLUMN max_participants integer NOT NULL DEFAULT 0" });
dbUpdates.add(new String[] { "ALTER TABLE tournament_participants ADD COLUMN tournament integer NOT NULL REFERENCES tournaments(id)" });
// dbUpdates.add(new String[] { "ALTER TABLE users ALTER COLUMN birthday TYPE date" });
}
......
......@@ -43,8 +43,8 @@ public class TournamentBean implements TournamentBeanLocal {
}
@Override
public void createGame(TournamentGame tg) {
tournamentGameFacade.create(tg);
public TournamentGame createGame(TournamentGame tg) {
return tournamentGameFacade.create(tg);
}
@Override
......
......@@ -13,7 +13,7 @@ public interface TournamentBeanLocal {
List<TournamentGame> getGames();
List<TournamentRule> getRulesByGame(TournamentGame tg);
void createGame(TournamentGame tg);
TournamentGame createGame(TournamentGame tg);
TournamentRule createRule(TournamentRule tr);
TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id);
......
......@@ -51,6 +51,7 @@ public class Tournament extends GenericEntity implements Serializable {
@Enumerated(EnumType.STRING)
private TournamentStatus tournamentStatus;
@OneToOne
@JoinColumn(name="tournament_root")
private TournamentMatch tournamentRoot;
......@@ -60,9 +61,14 @@ public class Tournament extends GenericEntity implements Serializable {
@Column(name="players_per_team")
private Integer playersPerTeam;
@Column(name="max_participants")
private Integer maxParticipants;
@ManyToOne
@JoinColumn(name="game", nullable=false)
private TournamentGame tournamentGame;
@ManyToOne
@JoinColumn(name="rules", nullable=false)
private TournamentRule rules;
......@@ -70,6 +76,9 @@ public class Tournament extends GenericEntity implements Serializable {
@OrderBy("id ASC")
private List<Tournament> subTournaments;
@OneToMany
private List<TournamentParticipant> participants;
public Tournament() { super(); }
public Integer getTalynTournamentId() {
......@@ -182,4 +191,20 @@ public class Tournament extends GenericEntity implements Serializable {
public void setRules(TournamentRule rules) {
this.rules = rules;
}
public Integer getMaxParticipants() {
return maxParticipants;
}
public void setMaxParticipants(Integer maxParticipants) {
this.maxParticipants = maxParticipants;
}
public List<TournamentParticipant> getParticipants() {
return participants;
}
public void setTournamentParticipants(List<TournamentParticipant> participants) {
this.participants = participants;
}
}
......@@ -25,6 +25,10 @@ public class TournamentParticipant extends GenericEntity implements Serializable
@OneToMany
private List<EventUser> teamMembers;
@ManyToOne
@JoinColumn(name="tournament")
private Tournament tournament;
public TournamentParticipant() {
super();
}
......
......@@ -80,6 +80,14 @@
<f:selectItems value="#{tournamentCreateView.tournamentTypes}" var="val" itemLabel="#{val}" />
</h:selectOneMenu>
<br />
<h:outputText value="#{i18n['tournaments.max_participants']}" />
<h:panelGrid columns="1" style="margin-bottom:10px">
<p:inputText id="maxParticipantsSlider" value="#{tournamentCreateView.tournament.maxParticipants}" />
<p:slider for="maxParticipantsSlider" />
</h:panelGrid>
<h:outputText value="#{i18n['tournaments.players_per_match']}" />
<h:panelGrid columns="1" style="margin-bottom:10px">
<p:inputText id="playerSlider" value="#{tournamentCreateView.tournament.playersPerMatch}" />
......
......@@ -34,6 +34,12 @@
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.fillamount']}" />
</f:facet>
<h:outputText value="#{tournament.participants.size()}/#{tournament.maxParticipants}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.playerspermatch_slash_teamsize']}" />
</f:facet>
<h:outputText value="#{tournament.playersPerMatch}/#{tournament.playersPerTeam}" />
......
......@@ -50,11 +50,13 @@ public class TournamentCreateView extends GenericCDIView {
this.beginConversation();
tournament = new Tournament();
tournament.setPlayersPerMatch(0);
tournament.setMaxParticipants(0);
backupPlayers = 0;
tournamentGames = tournamentBean.getGames();
}
}
public String save() {
tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers);
tournament.setLanEvent(eventBean.getCurrentEvent());
......@@ -95,7 +97,7 @@ public class TournamentCreateView extends GenericCDIView {
tg.setDescription(tournamentGameDescription);
tg.setLanEvent(eventBean.getCurrentEvent());
tournamentBean.createGame(tg);
game = tournamentBean.createGame(tg);
}
tournamentRules = tournamentBean.getRulesByGame(game);
......
package fi.codecrew.moya.web.cdiview.tournaments;
public class TournamentListView {
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!