Commit 0eec5be6 by Tuukka Kivilahti

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

2 parents a1b2cbb0 2ee18976
...@@ -6,6 +6,7 @@ import javax.ejb.EJB; ...@@ -6,6 +6,7 @@ import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.facade.TournamentFacade; import fi.codecrew.moya.facade.TournamentFacade;
import fi.codecrew.moya.facade.TournamentGameFacade; import fi.codecrew.moya.facade.TournamentGameFacade;
import fi.codecrew.moya.facade.TournamentRuleFacade; import fi.codecrew.moya.facade.TournamentRuleFacade;
...@@ -65,4 +66,9 @@ public class TournamentBean implements TournamentBeanLocal { ...@@ -65,4 +66,9 @@ public class TournamentBean implements TournamentBeanLocal {
public void createTournament(Tournament tournament) { public void createTournament(Tournament tournament) {
tournamentFacade.create(tournament); tournamentFacade.create(tournament);
} }
@Override
public List<Tournament> getActiveTournaments() {
return tournamentFacade.getTournamentsNotInStatus(TournamentStatus.COMPLETED);
}
} }
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.List;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.model.Tournament; import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.Tournament_;
import fi.codecrew.moya.model.User;
import fi.codecrew.moya.model.User_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -11,5 +20,15 @@ public class TournamentFacade extends IntegerPkGenericFacade<Tournament> { ...@@ -11,5 +20,15 @@ public class TournamentFacade extends IntegerPkGenericFacade<Tournament> {
public TournamentFacade() { public TournamentFacade() {
super(Tournament.class); super(Tournament.class);
} }
public List<Tournament> getTournamentsNotInStatus(TournamentStatus status) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Tournament> cq = cb.createQuery(Tournament.class);
Root<Tournament> root = cq.from(Tournament.class);
cq.where(cb.notEqual(root.get(Tournament_.tournamentStatus), status));
return getEm().createQuery(cq).getResultList();
}
} }
...@@ -18,5 +18,6 @@ public interface TournamentBeanLocal { ...@@ -18,5 +18,6 @@ public interface TournamentBeanLocal {
TournamentGame findGame(Integer id); TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id); TournamentRule findRule(Integer id);
void createTournament(Tournament tournament); void createTournament(Tournament tournament);
List<Tournament> getActiveTournaments();
} }
...@@ -65,14 +65,6 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -65,14 +65,6 @@ public class Tournament extends GenericEntity implements Serializable {
@JoinColumn(name="rules", nullable=false) @JoinColumn(name="rules", nullable=false)
private TournamentRule rules; private TournamentRule rules;
public TournamentRule getRules() {
return rules;
}
public void setRules(TournamentRule rules) {
this.rules = rules;
}
@OneToMany @OneToMany
@OrderBy("id ASC") @OrderBy("id ASC")
...@@ -183,4 +175,11 @@ public class Tournament extends GenericEntity implements Serializable { ...@@ -183,4 +175,11 @@ public class Tournament extends GenericEntity implements Serializable {
public void setSubTournaments(List<Tournament> subTournaments) { public void setSubTournaments(List<Tournament> subTournaments) {
this.subTournaments = subTournaments; this.subTournaments = subTournaments;
} }
public TournamentRule getRules() {
return rules;
}
public void setRules(TournamentRule rules) {
this.rules = rules;
}
} }
...@@ -21,7 +21,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -21,7 +21,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentRule extends GenericEntity implements Serializable { public class TournamentRule extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name="name") @Column(name="name")
private String name; private String name;
...@@ -70,6 +70,4 @@ public class TournamentRule extends GenericEntity implements Serializable { ...@@ -70,6 +70,4 @@ public class TournamentRule extends GenericEntity implements Serializable {
public void setTournamentGame(TournamentGame tournamentGame) { public void setTournamentGame(TournamentGame tournamentGame) {
this.tournamentGame = tournamentGame; this.tournamentGame = tournamentGame;
} }
} }
...@@ -139,6 +139,24 @@ ...@@ -139,6 +139,24 @@
<redirect /> <redirect />
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>
<navigation-rule>
<display-name>tournaments/admin/move-to-creation-screen</display-name>
<from-view-id>/tournaments/admin/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>create</from-outcome>
<to-view-id>/tournaments/admin/createwizard.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>tournaments/admin/tournament-created</display-name>
<from-view-id>/tournaments/admin/createwizard.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/tournaments/admin/index.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config> </faces-config>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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:f="http://java.sun.com/jsf/core">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{pageOutputView.initIndexView}" />
</f:metadata>
<ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Täällä voit huoletta rikkoa.
</h:outputLabel>
<ui:fragment rendered="#{layoutView.manageContent}">
<h:link value="#{i18n['layout.editContent']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}" />
</h:link>
<br />
</ui:fragment>
<ui:repeat var="cont1" value="#{pageOutputView.contents}">
<h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat>
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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:f="http://java.sun.com/jsf/core"> <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:f="http://java.sun.com/jsf/core">
<h:head> <h:head>
<meta http-equiv="refresh" content="1;url=frontpage.jsf" />
<script type="text/javascript">
window.location.href = "frontpage.jsf"
</script>
<title></title> <title></title>
</h:head> </h:head>
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> Redirecting to <a href="frontpage.jsf">Frontpage</a>
<f:metadata>
<f:event type="preRenderView" listener="#{pageOutputView.initIndexView}" />
</f:metadata>
<ui:define name="content">
<h:outputLabel rendered="#{sessionHandler.isInDevelopmentMode()}">
Development-tilassa.
Täällä voit huoletta rikkoa.
</h:outputLabel>
<ui:fragment rendered="#{layoutView.manageContent}">
<h:link value="#{i18n['layout.editContent']}" outcome="/pages/manage">
<f:param name="pagename" value="#{layoutView.pagepath}" />
</h:link>
<br />
</ui:fragment>
<ui:repeat var="cont1" value="#{pageOutputView.contents}">
<h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat>
</ui:define>
</ui:composition>
</h:body> </h:body>
</html> </html>
\ No newline at end of file
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
<br /> <br />
</p:panel> </p:panel>
<div style="float: right;"> <div style="float: right;">
<p:commandButton icon="apply" value="#{i18n['tournaments.admin.create_tournament']}" actionListener="#{tournamentCreateView.save}"/> <p:commandButton icon="apply" value="#{i18n['tournaments.admin.create_tournament']}" action="#{tournamentCreateView.save}"/>
</div> </div>
</p:tab> </p:tab>
</p:wizard> </p:wizard>
......
...@@ -13,9 +13,47 @@ ...@@ -13,9 +13,47 @@
<h1>#{i18n['tournaments.admin.title']}</h1> <h1>#{i18n['tournaments.admin.title']}</h1>
<p>#{i18n['tournaments.admin.description']}</p> <p>#{i18n['tournaments.admin.description']}</p>
<h2>#{i18n['tournaments.active_tournaments']}</h2> <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" > --> <p:dataTable value="#{tournamentAdminView.activeTournaments}" var="tournament">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.name']}" />
</f:facet>
<h:outputText value="#{tournament.tournamentName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.status']}" />
</f:facet>
<h:outputText value="#{tournament.tournamentStatus}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.type']}" />
</f:facet>
<h:outputText value="#{tournament.tournamentType}" />
</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}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.game']}" />
</f:facet>
<h:outputText value="#{tournament.tournamentGame.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['tournament.rules']}" />
</f:facet>
<h:outputText value="#{tournament.rules.name}" />
</p:column>
</p:dataTable>
<h:form>
<p:commandButton value="#{i18n['tournament.admin.create']}" action="#{tournamentAdminView.create}" />
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -982,10 +982,21 @@ topnavi.usermgmt = Users ...@@ -982,10 +982,21 @@ topnavi.usermgmt = Users
topnavi.userplaces = Computer Places topnavi.userplaces = Computer Places
topnavi.usershop = Shop topnavi.usershop = Shop
tournament.create = Create tournament
tournament.edit = Edit tournament
tournament.game = Game
tournament.name = Tournament name
tournament.playerspermatch_slash_teamsize = Players / team size
tournament.rules = Rules
tournament.status = Status
tournament.type = Type
tournaments.active_tournaments = Active tournaments
tournaments.admin.begin_time_constraints = Tournament begin time tournaments.admin.begin_time_constraints = Tournament begin time
tournaments.admin.create_a_game = Create a game tournaments.admin.create_a_game = Create a game
tournaments.admin.create_new_ruleset = Create a new ruleset tournaments.admin.create_new_ruleset = Create a new ruleset
tournaments.admin.create_tournament = Create a tournament tournaments.admin.create_tournament = Create a tournament
tournaments.admin.description = Manage tournaments
tournaments.admin.game_description = Game description tournaments.admin.game_description = Game description
tournaments.admin.game_name = Game name tournaments.admin.game_name = Game name
tournaments.admin.registration_time_constraints = Registration time constraints tournaments.admin.registration_time_constraints = Registration time constraints
...@@ -993,6 +1004,7 @@ tournaments.admin.rules = Rules ...@@ -993,6 +1004,7 @@ tournaments.admin.rules = Rules
tournaments.admin.select_a_game = Select a game tournaments.admin.select_a_game = Select a game
tournaments.admin.select_a_ruleset = Select a ruleset tournaments.admin.select_a_ruleset = Select a ruleset
tournaments.admin.set_time_constraints = Set time constraints tournaments.admin.set_time_constraints = Set time constraints
tournaments.admin.title = Tournaments management
tournaments.registration_closes = Set registration closing time tournaments.registration_closes = Set registration closing time
tournaments.registration_opens = Set registration opening time tournaments.registration_opens = Set registration opening time
tournaments.ruleset_description = Ruleset description tournaments.ruleset_description = Ruleset description
......
...@@ -965,10 +965,21 @@ topnavi.usermgmt = K\u00E4ytt\u00E4j\u00E4t ...@@ -965,10 +965,21 @@ topnavi.usermgmt = K\u00E4ytt\u00E4j\u00E4t
topnavi.userplaces = Konepaikat topnavi.userplaces = Konepaikat
topnavi.usershop = Kauppa topnavi.usershop = Kauppa
tournament.create = Luo turnaus
tournament.edit = Muokkaa turnausta
tournament.game = Peli
tournament.name = Turnauksen nimi
tournament.playerspermatch_slash_teamsize = Pelaajat / tiimin koko
tournament.rules = S\u00E4\u00E4nn\u00F6t
tournament.status = Tilanne
tournament.type = Tyyppi
tournaments.active_tournaments = Aktiiviset turnaukset
tournaments.admin.begin_time_constraints = Turnauksen aloitusaika tournaments.admin.begin_time_constraints = Turnauksen aloitusaika
tournaments.admin.create_a_game = Luo peli tournaments.admin.create_a_game = Luo peli
tournaments.admin.create_new_ruleset = Luo uusi s\u00E4\u00E4nn\u00F6st\u00F6 tournaments.admin.create_new_ruleset = Luo uusi s\u00E4\u00E4nn\u00F6st\u00F6
tournaments.admin.create_tournament = Luo turnaus tournaments.admin.create_tournament = Luo turnaus
tournaments.admin.description = Hallinnoi turnauksia
tournaments.admin.game_description = Pelin kuvaus tournaments.admin.game_description = Pelin kuvaus
tournaments.admin.game_name = Pelin nimi tournaments.admin.game_name = Pelin nimi
tournaments.admin.registration_time_constraints = Rekister\u00F6itymisaika tournaments.admin.registration_time_constraints = Rekister\u00F6itymisaika
...@@ -976,6 +987,7 @@ tournaments.admin.rules = S\u00E4\u00E4nn\u00F6t ...@@ -976,6 +987,7 @@ tournaments.admin.rules = S\u00E4\u00E4nn\u00F6t
tournaments.admin.select_a_game = Valitse peli tournaments.admin.select_a_game = Valitse peli
tournaments.admin.select_a_ruleset = Valitse s\u00E4\u00E4nn\u00F6st\u00F6 tournaments.admin.select_a_ruleset = Valitse s\u00E4\u00E4nn\u00F6st\u00F6
tournaments.admin.set_time_constraints = Aseta aikarajat tournaments.admin.set_time_constraints = Aseta aikarajat
tournaments.admin.title = Turnauksien hallinnointi
tournaments.registration_closes = Rekister\u00F6itymisen sulkeutumisaika tournaments.registration_closes = Rekister\u00F6itymisen sulkeutumisaika
tournaments.registration_opens = Rekister\u00F6itymisen aukeamisaika tournaments.registration_opens = Rekister\u00F6itymisen aukeamisaika
tournaments.ruleset_description = S\u00E4\u00E4nn\u00F6st\u00F6n kuvaus tournaments.ruleset_description = S\u00E4\u00E4nn\u00F6st\u00F6n kuvaus
......
...@@ -41,6 +41,10 @@ public abstract class GenericCDIView implements Serializable { ...@@ -41,6 +41,10 @@ public abstract class GenericCDIView implements Serializable {
} }
} }
public void endConversation() {
if(!conversation.isTransient()) conversation.end();
}
public boolean hasPermission(IAppPermission perm) { public boolean hasPermission(IAppPermission perm) {
// boolean ret = // boolean ret =
// FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName()); // FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName());
......
...@@ -15,6 +15,11 @@ public class TournamentAdminView { ...@@ -15,6 +15,11 @@ public class TournamentAdminView {
@EJB private TournamentBeanLocal tournamentBean; @EJB private TournamentBeanLocal tournamentBean;
public List<Tournament> getActiveTournaments() { public List<Tournament> getActiveTournaments() {
return null; List<Tournament> tl = tournamentBean.getActiveTournaments();
return tl;
}
public String create() {
return "create";
} }
} }
...@@ -14,6 +14,7 @@ import fi.codecrew.moya.model.TournamentRule; ...@@ -14,6 +14,7 @@ import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.Remove;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.inject.Named; import javax.inject.Named;
...@@ -54,7 +55,7 @@ public class TournamentCreateView extends GenericCDIView { ...@@ -54,7 +55,7 @@ public class TournamentCreateView extends GenericCDIView {
} }
} }
public void save(ActionEvent actionEvent) { public String save() {
tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers); tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers);
tournament.setLanEvent(eventBean.getCurrentEvent()); tournament.setLanEvent(eventBean.getCurrentEvent());
tournament.setTournamentStatus(TournamentStatus.SETUP); tournament.setTournamentStatus(TournamentStatus.SETUP);
...@@ -62,6 +63,9 @@ public class TournamentCreateView extends GenericCDIView { ...@@ -62,6 +63,9 @@ public class TournamentCreateView extends GenericCDIView {
tournament.setRules(rules); tournament.setRules(rules);
tournamentBean.createTournament(tournament); tournamentBean.createTournament(tournament);
this.endConversation();
return "success";
} }
public List<TournamentGame> getTournamentGames() { public List<TournamentGame> getTournamentGames() {
......
...@@ -156,8 +156,7 @@ public class LayoutView { ...@@ -156,8 +156,7 @@ public class LayoutView {
LanEventProperty logo = eventbean.getProperty(LanEventPropertyKey.EVENT_LOGO); LanEventProperty logo = eventbean.getProperty(LanEventPropertyKey.EVENT_LOGO);
if (logo != null) if (logo != null)
{ {
if (logo.getByteMime() == null) if (logo.getByteMime() == null || logo.getByteValue() == null) {
{
headertext = logo.getTextvalue(); headertext = logo.getTextvalue();
} else { } else {
headerimage = new DefaultStreamedContent(new ByteArrayInputStream(logo.getByteValue()), logo.getByteMime()); headerimage = new DefaultStreamedContent(new ByteArrayInputStream(logo.getByteValue()), logo.getByteMime());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!