Commit d3bda6e2 by Antti Jaakkola

Merge branch 'devel' of codecrew.fi:bortal into devel

2 parents d3a4882c 863ae773
......@@ -28,6 +28,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
// {"Query1","Query2",...}
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 users ALTER COLUMN birthday TYPE date" });
}
......
......@@ -6,6 +6,7 @@ import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.facade.TournamentFacade;
import fi.codecrew.moya.facade.TournamentGameFacade;
import fi.codecrew.moya.facade.TournamentRuleFacade;
import fi.codecrew.moya.model.Tournament;
......@@ -21,6 +22,7 @@ public class TournamentBean implements TournamentBeanLocal {
@EJB private TournamentRuleFacade tournamentRuleFacade;
@EJB private TournamentGameFacade tournamentGameFacade;
@EJB private TournamentFacade tournamentFacade;
/**
* Default constructor.
......@@ -45,8 +47,8 @@ public class TournamentBean implements TournamentBeanLocal {
}
@Override
public void createRule(TournamentRule tr) {
tournamentRuleFacade.create(tr);
public TournamentRule createRule(TournamentRule tr) {
return tournamentRuleFacade.create(tr);
}
@Override
......@@ -58,4 +60,9 @@ public class TournamentBean implements TournamentBeanLocal {
public TournamentRule findRule(Integer id) {
return tournamentRuleFacade.find(id);
}
@Override
public void createTournament(Tournament tournament) {
tournamentFacade.create(tournament);
}
}
......@@ -4,6 +4,7 @@ import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.model.TournamentRule;
......@@ -13,8 +14,9 @@ public interface TournamentBeanLocal {
List<TournamentGame> getGames();
List<TournamentRule> getRulesByGame(TournamentGame tg);
void createGame(TournamentGame tg);
void createRule(TournamentRule tr);
TournamentRule createRule(TournamentRule tr);
TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id);
void createTournament(Tournament tournament);
}
......@@ -63,6 +63,17 @@ public class Tournament extends GenericEntity implements Serializable {
@JoinColumn(name="game", nullable=false)
private TournamentGame tournamentGame;
@JoinColumn(name="rules", nullable=false)
private TournamentRule rules;
public TournamentRule getRules() {
return rules;
}
public void setRules(TournamentRule rules) {
this.rules = rules;
}
@OneToMany
@OrderBy("id ASC")
private List<Tournament> subTournaments;
......@@ -116,4 +127,60 @@ public class Tournament extends GenericEntity implements Serializable {
public void setTournamentGame(TournamentGame tournamentGame) {
this.tournamentGame = tournamentGame;
}
public LanEvent getLanEvent() {
return lanEvent;
}
public void setLanEvent(LanEvent lanEvent) {
this.lanEvent = lanEvent;
}
public Date getBeginsAt() {
return beginsAt;
}
public void setBeginsAt(Date beginsAt) {
this.beginsAt = beginsAt;
}
public TournamentStatus getTournamentStatus() {
return tournamentStatus;
}
public void setTournamentStatus(TournamentStatus tournamentStatus) {
this.tournamentStatus = tournamentStatus;
}
public TournamentMatch getTournamentRoot() {
return tournamentRoot;
}
public void setTournamentRoot(TournamentMatch tournamentRoot) {
this.tournamentRoot = tournamentRoot;
}
public Integer getPlayersPerMatch() {
return playersPerMatch;
}
public void setPlayersPerMatch(Integer playersPerMatch) {
this.playersPerMatch = playersPerMatch;
}
public Integer getPlayersPerTeam() {
return playersPerTeam;
}
public void setPlayersPerTeam(Integer playersPerTeam) {
this.playersPerTeam = playersPerTeam;
}
public List<Tournament> getSubTournaments() {
return subTournaments;
}
public void setSubTournaments(List<Tournament> subTournaments) {
this.subTournaments = subTournaments;
}
}
......@@ -62,6 +62,14 @@ public class TournamentRule extends GenericEntity implements Serializable {
public void setRules(String rules) {
this.rules = rules;
}
public TournamentGame getTournamentGame() {
return tournamentGame;
}
public void setTournamentGame(TournamentGame tournamentGame) {
this.tournamentGame = tournamentGame;
}
}
......@@ -98,8 +98,8 @@
<p:inputTextarea cols="50" rendered="#{productShopView.gatherBillInfo}" value="#{productShopView.otherInfo}" label="#{i18n['otherInfo']}" />
<!-- <p:inputTextarea cols="50" rendered="#{productShopView.gatherBillInfo}" value="#{productShopView.otherInfo}" label="#{i18n['otherInfo']}" /> -->
<br />
......
......@@ -16,13 +16,11 @@
<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['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}" />
<f:selectItems var="game" itemLabel="#{game.name}" value="#{tournamentCreateView.tournamentGames}" itemValue="#{game}" />
</h:selectOneMenu>
</h:panelGroup>
......@@ -40,15 +38,13 @@
<p:tab id="selectRuleset" title="#{i18n['tournaments.admin.rules']}">
<p:panel>
<h:messages errorClass="error" />
<h:messages errorClass="error" />
<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}" />
<f:selectItems var="rule" itemLabel="#{rule.name}" value="#{tournamentCreateView.tournamentRules}" itemValue="#{rule}" />
</h:selectOneMenu>
</h:panelGroup>
<br />
<h2>#{i18n['tournaments.admin.create_new_ruleset']}</h2>
<h:outputText value="#{i18n['tournaments.ruleset_name']}" />
......@@ -58,31 +54,65 @@
<br />
<h:outputText value="#{i18n['tournaments.ruleset_description']}" />
<br />
<p:inputTextarea value="#{tournamentCreateView.rulesetDescription}"/>
<p:inputText value="#{tournamentCreateView.rulesetDescription}"/>
<br />
<h:outputText value="#{i18n['tournaments.ruleset_rules']}" />
<br />
<p:inputTextarea value="#{tournamentCreateView.rulesetRules}"/>
<br />
</p:panel>
</p:tab>
<p:tab id="selectRegTimes" title="#{i18n['tournaments.admin.set_time_constraints']}">
<p:panel>
<h:messages errorClass="error" />
<h2>#{i18n['tournaments.admin.registration_time_constraints']}</h2>
<h2>#{i18n['tournaments.tournament_details']}</h2>
<h:outputText value="#{i18n['tournaments.tournament_name']}" />
<br />
<p:inputText value="#{tournamentCreateView.tournament.tournamentName}" />
<br />
<h:outputText value="#{i18n['tournaments.tournament_type']}"/>
<br />
<h:selectOneMenu value="#{tournamentCreateView.tournament.tournamentType}">
<f:selectItems value="#{tournamentCreateView.tournamentTypes}" var="val" itemLabel="#{val}" />
</h:selectOneMenu>
<h:outputText value="#{i18n['tournaments.players_per_match']}" />
<h:panelGrid columns="1" style="margin-bottom:10px">
<p:inputText id="playerSlider" value="#{tournamentCreateView.tournament.playersPerMatch}" />
<p:slider for="playerSlider" />
</h:panelGrid>
<h:outputText value="#{i18n['tournaments.backup_players']}" />
<h:panelGrid columns="1" style="margin-bottom:10px">
<p:inputText id="playerBackupSlider" value="#{tournamentCreateView.backupPlayers}" />
<p:slider for="playerBackupSlider" />
</h:panelGrid>
<h2>#{i18n['tournaments.admin.registration_time_constraints']}</h2>
<h:panelGrid columns="2">
<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" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" value="#{tournamentCreateView.tournament.registrationOpensAt}"/>
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" value="#{tournamentCreateView.tournament.registrationClosesAt}"/>
</h:panelGrid>
<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" />
<p:calendar stepHour="1" stepMinute="10" pattern="dd.MM.yyyy hh:mm" value="#{tournamentCreateView.tournament.beginsAt}"/>
</h:panelGrid>
<br />
</p:panel>
<div style="float: right;">
<p:commandButton icon="apply" value="#{i18n['tournaments.admin.create_tournament']}" />
<p:commandButton icon="apply" value="#{i18n['tournaments.admin.create_tournament']}" actionListener="#{tournamentCreateView.save}"/>
</div>
</p:tab>
</p:tab>
</p:wizard>
</h:form>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<!-- <f:event type="preRenderView" listener="#{userOverviewView.initView()}" /> -->
</f:metadata>
<ui:define name="content">
<h1>#{i18n['tournaments.admin.title']}</h1>
<p>#{i18n['tournaments.admin.description']}</p>
<h2>#{i18n['tournaments.active_tournaments']}</h2>
<!-- <p:dataTable styleClass="bordertable" id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="30" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,30,50,100" > -->
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -84,6 +84,7 @@ public class MenuView extends GenericCDIView {
}
public void menuChangeEvent() {
layoutview.setPageName(menuChange);
navihandler.forward(menuChange);
// super.navihandler.forward(menuChange);
}
......@@ -233,6 +234,9 @@ public class MenuView extends GenericCDIView {
}
public String getMenuChange() {
if (menuChange == null || menuChange.isEmpty()) {
menuChange = layoutview.getPagepath();
}
return menuChange;
}
......
package fi.codecrew.moya.web.cdiview.menu;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.ejb.EJB;
......@@ -77,19 +75,7 @@ public class PrimeMenuView extends GenericCDIView {
if (menuModel == null)
{
menuModel = new DefaultMenuModel();
Set<MenuNavigation> selectedSet = new HashSet<>();
final MenuNavigation thisPage = menubean.findNavigation(layoutview.getPagepath());
MenuNavigation selectedTop = thisPage;
while (selectedTop != null && selectedTop.getParent() != null) {
selectedTop = selectedTop.getParent();
selectedSet.add(selectedTop);
}
List<MenuNavigation> tops = menubean.getTopmenus();
if (!tops.contains(selectedTop) && !tops.isEmpty()) {
selectedTop = tops.get(0);
}
MenuNavigation selectedTop = layoutview.getSelectedTopmenu();
for (MenuNavigation m : selectedTop.getChildren()) {
if (m.getItem() != null && m.getChildren().isEmpty()) {
......@@ -99,8 +85,7 @@ public class PrimeMenuView extends GenericCDIView {
menuModel.addElement(menuitem);
}
} else {
Submenu subm = addSubmenu(m, selectedSet);
Submenu subm = addSubmenu(m, layoutview.getSelectedSet());
if (subm != null) {
menuModel.addElement(subm);
......
package fi.codecrew.moya.web.cdiview.tournaments;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.model.Tournament;
@RequestScoped
@Named
public class TournamentAdminView {
@EJB private TournamentBeanLocal tournamentBean;
public List<Tournament> getActiveTournaments() {
return null;
}
}
......@@ -5,6 +5,8 @@ import java.util.List;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.enums.TournamentType;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentGame;
......@@ -35,6 +37,9 @@ public class TournamentCreateView extends GenericCDIView {
private String rulesetName;
private String rulesetDescription;
private String rulesetRules;
private Integer backupPlayers;
@EJB TournamentBeanLocal tournamentBean;
@EJB EventBeanLocal eventBean;
......@@ -43,13 +48,20 @@ public class TournamentCreateView extends GenericCDIView {
if(tournament == null) {
this.beginConversation();
tournament = new Tournament();
tournament.setPlayersPerMatch(0);
backupPlayers = 0;
tournamentGames = tournamentBean.getGames();
}
}
public void save(ActionEvent actionEvent) {
tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers);
tournament.setLanEvent(eventBean.getCurrentEvent());
tournament.setTournamentStatus(TournamentStatus.SETUP);
tournament.setTournamentGame(game);
tournament.setRules(rules);
tournamentBean.createTournament(tournament);
}
public List<TournamentGame> getTournamentGames() {
......@@ -63,6 +75,11 @@ public class TournamentCreateView extends GenericCDIView {
public void uploadListener(org.primefaces.event.FileUploadEvent event) {
System.out.println("ZZ");
}
public TournamentType[] getTournamentTypes() {
TournamentType[] items = TournamentType.values();
return items;
}
public String onFlowProcess(FlowEvent event) {
switch(event.getOldStep()) {
......@@ -77,19 +94,22 @@ public class TournamentCreateView extends GenericCDIView {
tournamentBean.createGame(tg);
}
tournamentRules = tournamentBean.getRulesByGame(this.getGame());
tournamentRules = tournamentBean.getRulesByGame(game);
System.out.println(tournamentRules);
break;
case "selectRuleset":
if(rulesetName != null && rulesetName.length() > 0) {
TournamentRule tr = new TournamentRule();
tr.setName(rulesetName);
tr.setDescription(rulesetDescription);
tr.setRules(rulesetRules);
tr.setTournamentGame(game);
rules = tournamentBean.createRule(tr);
tournamentBean.createRule(tr);
tournamentRules = tournamentBean.getRulesByGame(game);
}
break;
}
System.out.println(event.getOldStep());
return event.getNewStep();
}
......@@ -140,4 +160,28 @@ public class TournamentCreateView extends GenericCDIView {
public void setRulesetDescription(String rulesetDescription) {
this.rulesetDescription = rulesetDescription;
}
public Tournament getTournament() {
return tournament;
}
public void setTournament(Tournament tournament) {
this.tournament = tournament;
}
public Integer getBackupPlayers() {
return backupPlayers;
}
public void setBackupPlayers(Integer backupPlayers) {
this.backupPlayers = backupPlayers;
}
public String getRulesetRules() {
return rulesetRules;
}
public void setRulesetRules(String rulesetRules) {
this.rulesetRules = rulesetRules;
}
}
package fi.codecrew.moya.web.helper;
import java.io.ByteArrayInputStream;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
......@@ -17,10 +21,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.MenuBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.model.LanEventProperty;
import fi.codecrew.moya.model.LanEventPropertyKey;
import fi.codecrew.moya.model.MenuNavigation;
@Named
@RequestScoped
......@@ -37,6 +43,9 @@ public class LayoutView {
private StreamedContent headerimage;
private String headertext;
@EJB
private transient MenuBeanLocal menubean;
private static final Logger logger = LoggerFactory.getLogger(LayoutView.class);
public void init() {
......@@ -48,6 +57,38 @@ public class LayoutView {
return permbean.hasPermission(ContentPermission.MANAGE_PAGES);
}
private Set<MenuNavigation> selectedSet;
public Set<MenuNavigation> getSelectedSet()
{
if (selectedSet == null) {
getSelectedTopmenu();
}
return selectedSet;
}
private MenuNavigation selectedTop;
public MenuNavigation getSelectedTopmenu()
{
if (selectedTop == null)
{
selectedSet = new HashSet<>();
selectedTop = menubean.findNavigation(getPagepath());
while (selectedTop != null && selectedTop.getParent() != null) {
selectedTop = selectedTop.getParent();
selectedSet.add(selectedTop);
}
List<MenuNavigation> tops = menubean.getTopmenus();
if (!tops.contains(selectedTop) && !tops.isEmpty()) {
selectedTop = tops.get(0);
}
selectedSet = Collections.unmodifiableSet(selectedSet);
}
return selectedTop;
}
public String getPagepath() {
if (pagename == null) {
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
......@@ -137,4 +178,9 @@ public class LayoutView {
public void setHeadertext(String headertext) {
this.headertext = headertext;
}
public void setPageName(String menuChange) {
this.pagename = menuChange;
selectedTop = null;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!