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;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.codecrew.moya.enums.TournamentStatus;
import fi.codecrew.moya.facade.TournamentFacade;
import fi.codecrew.moya.facade.TournamentGameFacade;
import fi.codecrew.moya.facade.TournamentRuleFacade;
......@@ -65,4 +66,9 @@ public class TournamentBean implements TournamentBeanLocal {
public void createTournament(Tournament tournament) {
tournamentFacade.create(tournament);
}
@Override
public List<Tournament> getActiveTournaments() {
return tournamentFacade.getTournamentsNotInStatus(TournamentStatus.COMPLETED);
}
}
package fi.codecrew.moya.facade;
import java.util.List;
import javax.ejb.LocalBean;
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.User;
import fi.codecrew.moya.model.User_;
@Stateless
@LocalBean
......@@ -11,5 +20,15 @@ public class TournamentFacade extends IntegerPkGenericFacade<Tournament> {
public TournamentFacade() {
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 {
TournamentGame findGame(Integer id);
TournamentRule findRule(Integer id);
void createTournament(Tournament tournament);
List<Tournament> getActiveTournaments();
}
......@@ -65,14 +65,6 @@ public class Tournament extends GenericEntity implements Serializable {
@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")
......@@ -183,4 +175,11 @@ public class Tournament extends GenericEntity implements Serializable {
public void setSubTournaments(List<Tournament> 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;
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class TournamentRule extends GenericEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name="name")
private String name;
......@@ -70,6 +70,4 @@ public class TournamentRule extends GenericEntity implements Serializable {
public void setTournamentGame(TournamentGame tournamentGame) {
this.tournamentGame = tournamentGame;
}
}
......@@ -139,6 +139,24 @@
<redirect />
</navigation-case>
</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>
......
<!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">
<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>
<meta http-equiv="refresh" content="1;url=frontpage.jsf" />
<script type="text/javascript">
window.location.href = "frontpage.jsf"
</script>
<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>
Redirecting to <a href="frontpage.jsf">Frontpage</a>
</h:body>
</html>
\ No newline at end of file
......@@ -110,7 +110,7 @@
<br />
</p:panel>
<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>
</p:tab>
</p:wizard>
......
......@@ -13,9 +13,47 @@
<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" > -->
<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:composition>
</h:body>
......
......@@ -982,10 +982,21 @@ topnavi.usermgmt = Users
topnavi.userplaces = Computer Places
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.create_a_game = Create a game
tournaments.admin.create_new_ruleset = Create a new ruleset
tournaments.admin.create_tournament = Create a tournament
tournaments.admin.description = Manage tournaments
tournaments.admin.game_description = Game description
tournaments.admin.game_name = Game name
tournaments.admin.registration_time_constraints = Registration time constraints
......@@ -993,6 +1004,7 @@ tournaments.admin.rules = Rules
tournaments.admin.select_a_game = Select a game
tournaments.admin.select_a_ruleset = Select a ruleset
tournaments.admin.set_time_constraints = Set time constraints
tournaments.admin.title = Tournaments management
tournaments.registration_closes = Set registration closing time
tournaments.registration_opens = Set registration opening time
tournaments.ruleset_description = Ruleset description
......
......@@ -965,10 +965,21 @@ topnavi.usermgmt = K\u00E4ytt\u00E4j\u00E4t
topnavi.userplaces = Konepaikat
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.create_a_game = Luo peli
tournaments.admin.create_new_ruleset = Luo uusi s\u00E4\u00E4nn\u00F6st\u00F6
tournaments.admin.create_tournament = Luo turnaus
tournaments.admin.description = Hallinnoi turnauksia
tournaments.admin.game_description = Pelin kuvaus
tournaments.admin.game_name = Pelin nimi
tournaments.admin.registration_time_constraints = Rekister\u00F6itymisaika
......@@ -976,6 +987,7 @@ tournaments.admin.rules = S\u00E4\u00E4nn\u00F6t
tournaments.admin.select_a_game = Valitse peli
tournaments.admin.select_a_ruleset = Valitse s\u00E4\u00E4nn\u00F6st\u00F6
tournaments.admin.set_time_constraints = Aseta aikarajat
tournaments.admin.title = Turnauksien hallinnointi
tournaments.registration_closes = Rekister\u00F6itymisen sulkeutumisaika
tournaments.registration_opens = Rekister\u00F6itymisen aukeamisaika
tournaments.ruleset_description = S\u00E4\u00E4nn\u00F6st\u00F6n kuvaus
......
......@@ -41,6 +41,10 @@ public abstract class GenericCDIView implements Serializable {
}
}
public void endConversation() {
if(!conversation.isTransient()) conversation.end();
}
public boolean hasPermission(IAppPermission perm) {
// boolean ret =
// FacesContext.getCurrentInstance().getExternalContext().isUserInRole(perm.getFullName());
......
......@@ -15,6 +15,11 @@ public class TournamentAdminView {
@EJB private TournamentBeanLocal tournamentBean;
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;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.ejb.EJB;
import javax.ejb.Remove;
import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
......@@ -54,7 +55,7 @@ public class TournamentCreateView extends GenericCDIView {
}
}
public void save(ActionEvent actionEvent) {
public String save() {
tournament.setPlayersPerTeam(tournament.getPlayersPerMatch() + backupPlayers);
tournament.setLanEvent(eventBean.getCurrentEvent());
tournament.setTournamentStatus(TournamentStatus.SETUP);
......@@ -62,6 +63,9 @@ public class TournamentCreateView extends GenericCDIView {
tournament.setRules(rules);
tournamentBean.createTournament(tournament);
this.endConversation();
return "success";
}
public List<TournamentGame> getTournamentGames() {
......
......@@ -156,8 +156,7 @@ public class LayoutView {
LanEventProperty logo = eventbean.getProperty(LanEventPropertyKey.EVENT_LOGO);
if (logo != null)
{
if (logo.getByteMime() == null)
{
if (logo.getByteMime() == null || logo.getByteValue() == null) {
headertext = logo.getTextvalue();
} else {
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!