Commit 69904e1f by Antti Tonkyra

TournamentStuff

1 parent 2ee18976
...@@ -29,6 +29,8 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -29,6 +29,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { "" }); // first version, no changes 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 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 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" }); // dbUpdates.add(new String[] { "ALTER TABLE users ALTER COLUMN birthday TYPE date" });
} }
......
...@@ -43,8 +43,8 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -43,8 +43,8 @@ public class TournamentBean implements TournamentBeanLocal {
} }
@Override @Override
public void createGame(TournamentGame tg) { public TournamentGame createGame(TournamentGame tg) {
tournamentGameFacade.create(tg); return tournamentGameFacade.create(tg);
} }
@Override @Override
......
...@@ -13,7 +13,7 @@ public interface TournamentBeanLocal { ...@@ -13,7 +13,7 @@ public interface TournamentBeanLocal {
List<TournamentGame> getGames(); List<TournamentGame> getGames();
List<TournamentRule> getRulesByGame(TournamentGame tg); List<TournamentRule> getRulesByGame(TournamentGame tg);
void createGame(TournamentGame tg); TournamentGame createGame(TournamentGame tg);
TournamentRule createRule(TournamentRule tr); TournamentRule createRule(TournamentRule tr);
TournamentGame findGame(Integer id); TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id); TournamentRule findRule(Integer id);
......
...@@ -51,6 +51,7 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -51,6 +51,7 @@ public class Tournament extends GenericEntity implements Serializable {
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private TournamentStatus tournamentStatus; private TournamentStatus tournamentStatus;
@OneToOne
@JoinColumn(name="tournament_root") @JoinColumn(name="tournament_root")
private TournamentMatch tournamentRoot; private TournamentMatch tournamentRoot;
...@@ -60,9 +61,14 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -60,9 +61,14 @@ public class Tournament extends GenericEntity implements Serializable {
@Column(name="players_per_team") @Column(name="players_per_team")
private Integer playersPerTeam; private Integer playersPerTeam;
@Column(name="max_participants")
private Integer maxParticipants;
@ManyToOne
@JoinColumn(name="game", nullable=false) @JoinColumn(name="game", nullable=false)
private TournamentGame tournamentGame; private TournamentGame tournamentGame;
@ManyToOne
@JoinColumn(name="rules", nullable=false) @JoinColumn(name="rules", nullable=false)
private TournamentRule rules; private TournamentRule rules;
...@@ -70,6 +76,9 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -70,6 +76,9 @@ public class Tournament extends GenericEntity implements Serializable {
@OrderBy("id ASC") @OrderBy("id ASC")
private List<Tournament> subTournaments; private List<Tournament> subTournaments;
@OneToMany
private List<TournamentParticipant> participants;
public Tournament() { super(); } public Tournament() { super(); }
public Integer getTalynTournamentId() { public Integer getTalynTournamentId() {
...@@ -182,4 +191,20 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -182,4 +191,20 @@ public class Tournament extends GenericEntity implements Serializable {
public void setRules(TournamentRule rules) { public void setRules(TournamentRule rules) {
this.rules = 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 ...@@ -25,6 +25,10 @@ public class TournamentParticipant extends GenericEntity implements Serializable
@OneToMany @OneToMany
private List<EventUser> teamMembers; private List<EventUser> teamMembers;
@ManyToOne
@JoinColumn(name="tournament")
private Tournament tournament;
public TournamentParticipant() { public TournamentParticipant() {
super(); super();
} }
......
...@@ -80,6 +80,14 @@ ...@@ -80,6 +80,14 @@
<f:selectItems value="#{tournamentCreateView.tournamentTypes}" var="val" itemLabel="#{val}" /> <f:selectItems value="#{tournamentCreateView.tournamentTypes}" var="val" itemLabel="#{val}" />
</h:selectOneMenu> </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:outputText value="#{i18n['tournaments.players_per_match']}" />
<h:panelGrid columns="1" style="margin-bottom:10px"> <h:panelGrid columns="1" style="margin-bottom:10px">
<p:inputText id="playerSlider" value="#{tournamentCreateView.tournament.playersPerMatch}" /> <p:inputText id="playerSlider" value="#{tournamentCreateView.tournament.playersPerMatch}" />
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
</p:column> </p:column>
<p:column> <p:column>
<f:facet name="header"> <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']}" /> <h:outputText value="#{i18n['tournament.playerspermatch_slash_teamsize']}" />
</f:facet> </f:facet>
<h:outputText value="#{tournament.playersPerMatch}/#{tournament.playersPerTeam}" /> <h:outputText value="#{tournament.playersPerMatch}/#{tournament.playersPerTeam}" />
......
...@@ -50,11 +50,13 @@ public class TournamentCreateView extends GenericCDIView { ...@@ -50,11 +50,13 @@ public class TournamentCreateView extends GenericCDIView {
this.beginConversation(); this.beginConversation();
tournament = new Tournament(); tournament = new Tournament();
tournament.setPlayersPerMatch(0); tournament.setPlayersPerMatch(0);
tournament.setMaxParticipants(0);
backupPlayers = 0; backupPlayers = 0;
tournamentGames = tournamentBean.getGames(); tournamentGames = tournamentBean.getGames();
} }
} }
public String save() { public String save() {
tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers); tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers);
tournament.setLanEvent(eventBean.getCurrentEvent()); tournament.setLanEvent(eventBean.getCurrentEvent());
...@@ -95,7 +97,7 @@ public class TournamentCreateView extends GenericCDIView { ...@@ -95,7 +97,7 @@ public class TournamentCreateView extends GenericCDIView {
tg.setDescription(tournamentGameDescription); tg.setDescription(tournamentGameDescription);
tg.setLanEvent(eventBean.getCurrentEvent()); tg.setLanEvent(eventBean.getCurrentEvent());
tournamentBean.createGame(tg); game = tournamentBean.createGame(tg);
} }
tournamentRules = tournamentBean.getRulesByGame(game); 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!