Commit d6fa9ae9 by Antti Tonkyra

Tournamentjuttuja

1 parent 8f92fad3
......@@ -39,4 +39,23 @@ public class TournamentBean implements TournamentBeanLocal {
return tournamentGameFacade.getGames();
}
@Override
public void createGame(TournamentGame tg) {
tournamentGameFacade.create(tg);
}
@Override
public void createRule(TournamentRule tr) {
tournamentRuleFacade.create(tr);
}
@Override
public TournamentGame findGame(Integer id) {
return tournamentGameFacade.find(id);
}
@Override
public TournamentRule findRule(Integer id) {
return tournamentRuleFacade.find(id);
}
}
......@@ -12,5 +12,9 @@ public interface TournamentBeanLocal {
List<TournamentGame> getGames();
List<TournamentRule> getRulesByGame(TournamentGame tg);
void createGame(TournamentGame tg);
void createRule(TournamentRule tr);
TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id);
}
......@@ -59,4 +59,20 @@ public class TournamentGame extends GenericEntity implements Serializable {
public void setAvailableRules(List<TournamentRule> availableRules) {
this.availableRules = availableRules;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LanEvent getLanEvent() {
return lanEvent;
}
public void setLanEvent(LanEvent lanEvent) {
this.lanEvent = lanEvent;
}
}
......@@ -9,80 +9,78 @@
</f:metadata>
<ui:define name="content">
<h1>#{i18n['actionlog.tournaments.admin.create_tournament']}</h1>
<h1>#{i18n['tournaments.admin.create_tournament']}</h1>
<h:form>
<p:wizard widgetVar="wiz" flowListener="#{tournamentCreateView.onFlowProcess}">
<p:tab id="selectGame" title="#{i18n['actionlog.tournaments.admin.select_a_game']}">
<p:tab id="selectGame" title="#{i18n['tournaments.admin.select_a_game']}">
<p:panel>
<h:messages errorClass="error" />
<h:panelGroup rendered="#{tournamentCreateView.tournamentGames.isEmpty() eq false}">
<h2>#{i18n['actionlog.tournaments.admin.select_a_game']}</h2>
<p:selectOneMenu>
<f:selectItems value="#{tournamentCreateView.tournamentGames}"></f:selectItems>
</p:selectOneMenu>
<h2>#{i18n['tournaments.admin.select_a_game']}</h2>
<h:selectOneMenu value="#{tournamentCreateView.game}" converter="#{tournamentGameConverter}">
<f:selectItems var="game" itemLabel="#{game.name}" value="#{tournamentCreateView.tournamentGames}" itemValue="#{game.id}" />
</h:selectOneMenu>
</h:panelGroup>
<h2>#{i18n['actionlog.tournaments.admin.create_a_game']}</h2>
<h2>#{i18n['tournaments.admin.create_a_game']}</h2>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['actionlog.tournaments.admin.game_name']}" />
<h:outputText value="#{i18n['actionlog.tournaments.admin.game_description']}" />
<h:outputText value="#{i18n['tournaments.admin.game_name']}" />
<h:outputText value="#{i18n['tournaments.admin.game_description']}" />
<p:inputText />
<p:inputText />
<h:outputText value="#{i18n['actionlog.tournaments.admin.upload_game_image']}" />
<h:outputText value="" />
<p:fileUpload mode="simple" />
<p:inputText value="#{tournamentCreateView.tournamentGameName}" />
<p:inputText value="#{tournamentCreateView.tournamentGameDescription}" />
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="selectRuleset" title="#{i18n['actionlog.tournaments.admin.rules']}">
<p:tab id="selectRuleset" title="#{i18n['tournaments.admin.rules']}">
<p:panel>
<h:messages errorClass="error" />
<h2>#{i18n['actionlog.tournaments.admin.select_a_ruleset']}</h2>
<p:selectOneMenu>
<f:selectItems value="#{tournamentCreateView.tournamentRules}"></f:selectItems>
</p:selectOneMenu>
<h:panelGroup rendered="#{tournamentCreateView.tournamentRules.isEmpty() eq false}">
<h2>#{i18n['tournaments.admin.select_a_ruleset']}</h2>
<h:selectOneMenu value="#{tournamentCreateView.rules}" converter="#{tournamentRuleConverter}">
<f:selectItems var="rule" itemLabel="#{rule.name}" value="#{tournamentCreateView.tournamentRules}" itemValue="#{rule.id}" />
</h:selectOneMenu>
</h:panelGroup>
<br />
<h2>#{i18n['actionlog.tournaments.admin.create_new_ruleset']}</h2>
<h:outputText value="#{i18n['actionlog.tournaments.ruleset_name']}" />
<h2>#{i18n['tournaments.admin.create_new_ruleset']}</h2>
<h:outputText value="#{i18n['tournaments.ruleset_name']}" />
<br />
<p:inputText />
<p:inputText value="#{tournamentCreateView.rulesetName}" />
<br />
<h:outputText value="#{i18n['actionlog.tournaments.ruleset_description']}" />
<h:outputText value="#{i18n['tournaments.ruleset_description']}" />
<br />
<p:inputTextarea />
<p:inputTextarea value="#{tournamentCreateView.rulesetDescription}"/>
</p:panel>
</p:tab>
<p:tab id="selectRegTimes" title="#{i18n['actionlog.tournaments.admin.set_time_constraints']}">
<p:tab id="selectRegTimes" title="#{i18n['tournaments.admin.set_time_constraints']}">
<p:panel>
<h:messages errorClass="error" />
<h2>#{i18n['actionlog.tournaments.admin.registration_time_constraints']}</h2>
<h2>#{i18n['tournaments.admin.registration_time_constraints']}</h2>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['actionlog.tournaments.registration_opens']}" />
<h:outputText value="#{i18n['actionlog.tournaments.registration_closes']}" />
<h:outputText value="#{i18n['tournaments.registration_opens']}" />
<h:outputText value="#{i18n['tournaments.registration_closes']}" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
</h:panelGrid>
<h2>#{i18n['actionlog.tournaments.admin.begin_time_constraints']}</h2>
<h2>#{i18n['tournaments.admin.begin_time_constraints']}</h2>
<h:panelGrid>
<h:outputText value="Start time" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" />
</h:panelGrid>
</p:panel>
<div style="float: right;">
<p:commandButton icon="apply" value="#{i18n['actionlog.tournaments.admin.create_tournament']}" />
<p:commandButton icon="apply" value="#{i18n['tournaments.admin.create_tournament']}" />
</div>
</p:tab>
</p:wizard>
......
......@@ -3,6 +3,7 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import java.io.Serializable;
import java.util.List;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.Tournament;
......@@ -36,6 +37,7 @@ public class TournamentCreateView extends GenericCDIView {
private String rulesetDescription;
@EJB TournamentBeanLocal tournamentBean;
@EJB EventBeanLocal eventBean;
public void initView() {
if(tournament == null) {
......@@ -58,18 +60,32 @@ public class TournamentCreateView extends GenericCDIView {
return tournamentRules;
}
public void uploadListener(org.primefaces.event.FileUploadEvent event) {
System.out.println("ZZ");
}
public String onFlowProcess(FlowEvent event) {
switch(event.getOldStep()) {
case "selectGame":
if(tournamentGameName.length() > 0) {
// logic-create-new
// oh lurd, we want to create a new gamy now
TournamentGame tg = new TournamentGame();
tg.setName(tournamentGameName);
tg.setDescription(tournamentGameDescription);
tg.setLanEvent(eventBean.getCurrentEvent());
tournamentBean.createGame(tg);
}
tournamentRules = tournamentBean.getRulesByGame(this.getGame());
break;
case "selectRuleset":
if(rulesetName.length() > 0) {
// logic-create-new
if(rulesetName != null && rulesetName.length() > 0) {
TournamentRule tr = new TournamentRule();
tr.setName(rulesetName);
tr.setDescription(rulesetDescription);
tournamentBean.createRule(tr);
}
break;
}
......
package fi.codecrew.moya.web.converter;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
@Named
@RequestScoped
public class TournamentGameConverter extends GenericIntegerEntityConverter<TournamentGame> {
@EJB private TournamentBeanLocal tournamentBean;
@Override
protected TournamentGame find(Integer id) {
return tournamentBean.findGame(id);
}
}
package fi.codecrew.moya.web.converter;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.utilities.jsf.GenericIntegerEntityConverter;
@Named
@RequestScoped
public class TournamentRuleConverter extends GenericIntegerEntityConverter<TournamentRule> {
@EJB private TournamentBeanLocal tournamentBean;
@Override
protected TournamentRule find(Integer id) {
return tournamentBean.findRule(id);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!