Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2cf56407
authored
Oct 13, 2013
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Participate role checking.
1 parent
1eeae2e4
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
175 additions
and
110 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/MoyaEar/.project
code/MoyaEar/EarContent/META-INF/application.xml
code/MoyaWeb/WebContent/WEB-INF/web.xml
code/MoyaWeb/WebContent/tournaments/admin/delete.xhtml
code/MoyaWeb/WebContent/tournaments/admin/edit.xhtml
code/MoyaWeb/WebContent/tournaments/admin/index.xhtml
code/MoyaWeb/WebContent/tournaments/index.xhtml
code/MoyaWeb/WebContent/tournaments/participate_multi.xhtml
code/MoyaWeb/WebContent/tournaments/participate_single.xhtml
code/MoyaWeb/pom.xml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentAdminView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentDeleteView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentEditView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentListView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentRulesView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
2cf5640
...
@@ -118,9 +118,9 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -118,9 +118,9 @@ public class MenuBean implements MenuBeanLocal {
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/edit"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/changePassword"
),
UserPermission
.
VIEW_SELF
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/gameids"
),
TournamentPermission
.
VIEW
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/user/gameids"
),
TournamentPermission
.
PARTICIPATE
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/logout"
),
UserPermission
.
LOGOUT
);
userprofile
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/logout"
),
UserPermission
.
LOGOUT
);
MenuNavigation
tournaments
=
usermenu
.
addPage
(
null
,
null
);
MenuNavigation
tournaments
=
usermenu
.
addPage
(
null
,
null
);
tournaments
.
setKey
(
"tournaments.menutitle"
);
tournaments
.
setKey
(
"tournaments.menutitle"
);
tournaments
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/tournaments/index"
),
TournamentPermission
.
VIEW
);
tournaments
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/tournaments/index"
),
TournamentPermission
.
VIEW
);
...
@@ -240,7 +240,7 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -240,7 +240,7 @@ public class MenuBean implements MenuBeanLocal {
// shopnavi.addPage(menuitemfacade.findOrCreate("/index3"),
// shopnavi.addPage(menuitemfacade.findOrCreate("/index3"),
// UserPermission.ANYUSER);
// UserPermission.ANYUSER);
navifacade
.
create
(
shopmenu
);
navifacade
.
create
(
shopmenu
);
MenuNavigation
tournamentsadm
=
adminmenu
.
addPage
(
null
,
null
);
MenuNavigation
tournamentsadm
=
adminmenu
.
addPage
(
null
,
null
);
tournamentsadm
.
setKey
(
"tournaments.menutitle"
);
tournamentsadm
.
setKey
(
"tournaments.menutitle"
);
tournamentsadm
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/tournaments/admin/index"
),
TournamentPermission
.
MANAGE_ALL
);
tournamentsadm
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/tournaments/admin/index"
),
TournamentPermission
.
MANAGE_ALL
);
...
...
code/MoyaEar/.project
View file @
2cf5640
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<project>
lib-AuthModule-depends
</project>
<project>
lib-AuthModule-depends
</project>
<project>
MoyaAuthModule
</project>
<project>
MoyaAuthModule
</project>
<project>
MoyaCardPrinter
</project>
<project>
MoyaCardPrinter
</project>
<project>
MoyaEventMgmtWeb
</project>
</projects>
</projects>
<buildSpec>
<buildSpec>
<buildCommand>
<buildCommand>
...
...
code/MoyaEar/EarContent/META-INF/application.xml
View file @
2cf5640
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version=
"7"
>
<application
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<display-name>
moya-ear
</display-name>
xmlns=
"http://xmlns.jcp.org/xml/ns/javaee"
<module>
xsi:schemaLocation=
"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
<ejb>
moya-beans-0.2.0.jar
</ejb>
version=
"7"
>
</module>
<display-name>
moya-ear
</display-name>
<module>
<module>
<web>
<ejb>
moya-beans-0.2.0.jar
</ejb>
<web-uri>
moya-web-0.2.0.war
</web-uri>
</module>
<context-root>
/MoyaWeb
</context-root>
<module>
</web>
<web>
</module>
<web-uri>
moya-web-0.2.0.war
</web-uri>
<library-directory>
lib
</library-directory>
<context-root>
/MoyaWeb
</context-root>
</web>
</module>
<!-- <module> <web> <web-uri>MoyaEventMgmtWeb.war</web-uri> <context-root>EventMgmt</context-root>
</web> </module> -->
<library-directory>
lib
</library-directory>
</application>
</application>
\ No newline at end of file
code/MoyaWeb/WebContent/WEB-INF/web.xml
View file @
2cf5640
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-name>
javax.faces.PROJECT_STAGE
</param-name>
<param-value>
Development
</param-value>
<param-value>
Development
</param-value>
</context-param>
</context-param>
<filter>
<filter>
<display-name>
PrimefacesFileupload
</display-name>
<display-name>
PrimefacesFileupload
</display-name>
<filter-name>
PrimefacesFileupload
</filter-name>
<filter-name>
PrimefacesFileupload
</filter-name>
...
...
code/MoyaWeb/WebContent/tournaments/admin/delete.xhtml
View file @
2cf5640
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentDeleteView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/admin/edit.xhtml
View file @
2cf5640
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentEditView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/admin/index.xhtml
View file @
2cf5640
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentAdminView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/index.xhtml
View file @
2cf5640
<!DOCTYPE html
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
"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"
>
<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>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentListView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
@@ -14,10 +17,10 @@
...
@@ -14,10 +17,10 @@
<p>
#{i18n['tournaments.description']}
</p>
<p>
#{i18n['tournaments.description']}
</p>
<h2>
#{i18n['tournaments.open_tournaments']}
</h2>
<h2>
#{i18n['tournaments.open_tournaments']}
</h2>
<p:dataTable
value=
"#{tournamentListView.setupPhaseTournaments}"
var=
"tournament"
>
<p:dataTable
value=
"#{tournamentListView.setupPhaseTournaments}"
var=
"tournament"
>
<p:column
style=
"width:2%"
>
<p:column
style=
"width:2%"
>
<p:rowToggler
/>
<p:rowToggler
/>
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['tournament.name']}"
/>
<h:outputText
value=
"#{i18n['tournament.name']}"
/>
</f:facet>
</f:facet>
...
@@ -49,7 +52,7 @@
...
@@ -49,7 +52,7 @@
</p:column>
</p:column>
<p:column>
<p:column>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['tournament.participation_time']}"
/>
<h:outputText
value=
"#{i18n['tournament.participation_time']}"
/>
</f:facet>
</f:facet>
<h:outputText
value=
"#{tournament.registrationOpensAt}"
>
<h:outputText
value=
"#{tournament.registrationOpensAt}"
>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
<f:convertDateTime
pattern=
"#{sessionHandler.datetimeFormat}"
timeZone=
"#{sessionHandler.timezone}"
/>
...
@@ -67,32 +70,31 @@
...
@@ -67,32 +70,31 @@
<f:param
name=
"tournament_id"
value=
"#{tournament.id}"
/>
<f:param
name=
"tournament_id"
value=
"#{tournament.id}"
/>
</h:link>
</h:link>
</p:column>
</p:column>
<p:column>
<p:column
rendered=
"#{tournamentListView.canParticipate()}"
>
<f:facet
name=
"header"
>
<f:facet
name=
"header"
>
<h:outputText
value=
"#{i18n['tournament.control']}"
/>
<h:outputText
value=
"#{i18n['tournament.control']}"
/>
</f:facet>
</f:facet>
<h:panelGroup>
<h:panelGroup>
<p:commandButton
value=
"#{i18n['tournament.participate']}"
action=
"#{tournamentParticipateView.participate(tournament.id)}"
rendered=
"#{tournament.participants.size() lt tournament.maxParticipants}"
ajax=
"false"
/>
<p:commandButton
value=
"#{i18n['tournament.participate']}"
action=
"#{tournamentParticipateView.participate(tournament.id)}"
<h:outputText
value=
"#{i18n['tournament.full']}"
rendered=
"#{tournament.participants.size() ge tournament.maxParticipants}"
/>
rendered=
"#{tournament.participants.size() lt tournament.maxParticipants}"
ajax=
"false"
/>
<h:outputText
value=
"#{i18n['tournament.full']}"
rendered=
"#{tournament.participants.size() ge tournament.maxParticipants}"
/>
</h:panelGroup>
</h:panelGroup>
</p:column>
</p:column>
<p:rowExpansion>
<p:rowExpansion>
<h:panelGrid
id=
"display"
columns=
"2"
cellpadding=
"4"
styleClass=
" ui-widget-content grid"
>
<h:panelGrid
id=
"display"
columns=
"2"
cellpadding=
"4"
styleClass=
" ui-widget-content grid"
>
<h:outputText
value=
"#{i18n['tournament.participants']}"
/>
<h:outputText
value=
"#{i18n['tournament.participants']}"
/>
<h:panelGroup>
<h:panelGroup>
<ul>
<ul>
<ui:repeat
var=
"participant"
value=
"#{tournament.participants}"
>
<ui:repeat
var=
"participant"
value=
"#{tournament.participants}"
>
<li>
<li><h:outputText
value=
"#{participant.teamName}"
rendered=
"#{not empty participant.teamName}"
/>
<h:outputText
value=
"#{participant.participator.user.nick}"
<h:outputText
value=
"#{participant.teamName}"
rendered=
"#{not empty participant.teamName}"
/>
rendered=
"#{empty participant.teamName}"
/></li>
<h:outputText
value=
"#{participant.participator.user.nick}"
rendered=
"#{empty participant.teamName}"
/>
</ui:repeat>
</li>
</ul>
</ui:repeat>
</h:panelGroup>
</ul>
</h:panelGrid>
</h:panelGroup>
</h:panelGrid>
</p:rowExpansion>
</p:rowExpansion>
</p:dataTable>
</p:dataTable>
</h:form>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</h:body>
...
...
code/MoyaWeb/WebContent/tournaments/participate_multi.xhtml
View file @
2cf5640
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentParticipateView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/WebContent/tournaments/participate_single.xhtml
View file @
2cf5640
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<h:body>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{tournamentParticipateView.initView()}"
/>
</f:metadata>
</f:metadata>
<ui:define
name=
"content"
>
<ui:define
name=
"content"
>
...
...
code/MoyaWeb/pom.xml
View file @
2cf5640
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
<dependency>
<dependency>
<groupId>
org.primefaces
</groupId>
<groupId>
org.primefaces
</groupId>
<artifactId>
primefaces
</artifactId>
<artifactId>
primefaces
</artifactId>
<version>
4.0
-SNAPSHOT
</version>
<version>
4.0
.RC1
</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentAdminView.java
View file @
2cf5640
...
@@ -7,18 +7,30 @@ import javax.enterprise.context.RequestScoped;
...
@@ -7,18 +7,30 @@ import javax.enterprise.context.RequestScoped;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@RequestScoped
@RequestScoped
@Named
@Named
public
class
TournamentAdminView
{
public
class
TournamentAdminView
extends
GenericCDIView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
/**
*
*/
private
static
final
long
serialVersionUID
=
-
9079431236226432769L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
List
<
Tournament
>
getActiveTournaments
()
{
public
List
<
Tournament
>
getActiveTournaments
()
{
List
<
Tournament
>
tl
=
tournamentBean
.
getActiveTournaments
();
List
<
Tournament
>
tl
=
tournamentBean
.
getActiveTournaments
();
return
tl
;
return
tl
;
}
}
public
String
create
()
{
public
String
create
()
{
return
"create"
;
return
"create"
;
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
View file @
2cf5640
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.inject.Named
;
import
org.primefaces.event.FlowEvent
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.TournamentStatus
;
import
fi.codecrew.moya.enums.TournamentStatus
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.
model.Role
;
import
fi.codecrew.moya.
enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
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
;
import
org.primefaces.event.FlowEvent
;
@Named
@Named
@ConversationScoped
@ConversationScoped
public
class
TournamentCreateView
extends
GenericCDIView
{
public
class
TournamentCreateView
extends
GenericCDIView
{
...
@@ -29,26 +26,28 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -29,26 +26,28 @@ public class TournamentCreateView extends GenericCDIView {
private
List
<
TournamentGame
>
tournamentGames
;
private
List
<
TournamentGame
>
tournamentGames
;
private
List
<
TournamentRule
>
tournamentRules
;
private
List
<
TournamentRule
>
tournamentRules
;
private
TournamentRule
rules
=
null
;
private
TournamentRule
rules
=
null
;
private
TournamentGame
game
=
null
;
private
TournamentGame
game
=
null
;
private
Tournament
tournament
=
null
;
private
Tournament
tournament
=
null
;
private
String
tournamentGameName
;
private
String
tournamentGameName
;
private
String
tournamentGameDescription
;
private
String
tournamentGameDescription
;
private
String
rulesetName
;
private
String
rulesetName
;
private
String
rulesetDescription
;
private
String
rulesetDescription
;
private
String
rulesetRules
;
private
String
rulesetRules
;
private
Integer
backupPlayers
;
private
Integer
backupPlayers
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
@EJB
EventBeanLocal
eventBean
;
TournamentBeanLocal
tournamentBean
;
@EJB
EventBeanLocal
eventBean
;
public
void
initView
()
{
public
void
initView
()
{
if
(
tournament
==
null
)
{
if
(
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
)
&&
tournament
==
null
)
{
this
.
beginConversation
();
this
.
beginConversation
();
tournament
=
new
Tournament
();
tournament
=
new
Tournament
();
tournament
.
setPlayersPerMatch
(
0
);
tournament
.
setPlayersPerMatch
(
0
);
tournament
.
setMaxParticipants
(
0
);
tournament
.
setMaxParticipants
(
0
);
...
@@ -57,66 +56,65 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -57,66 +56,65 @@ public class TournamentCreateView extends GenericCDIView {
}
}
}
}
public
String
save
()
{
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
);
tournament
.
setTournamentGame
(
game
);
tournament
.
setTournamentGame
(
game
);
tournament
.
setRules
(
rules
);
tournament
.
setRules
(
rules
);
try
{
try
{
tournamentBean
.
createTournament
(
tournament
);
tournamentBean
.
createTournament
(
tournament
);
this
.
endConversation
();
this
.
endConversation
();
return
"success"
;
return
"success"
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
e
.
getMessage
());
MessageHelper
.
err
(
e
.
getMessage
());
return
""
;
return
""
;
}
}
}
}
public
List
<
TournamentGame
>
getTournamentGames
()
{
public
List
<
TournamentGame
>
getTournamentGames
()
{
return
tournamentGames
;
return
tournamentGames
;
}
}
public
List
<
TournamentRule
>
getTournamentRules
()
{
public
List
<
TournamentRule
>
getTournamentRules
()
{
return
tournamentRules
;
return
tournamentRules
;
}
}
public
void
uploadListener
(
org
.
primefaces
.
event
.
FileUploadEvent
event
)
{
public
void
uploadListener
(
org
.
primefaces
.
event
.
FileUploadEvent
event
)
{
System
.
out
.
println
(
"ZZ"
);
System
.
out
.
println
(
"ZZ"
);
}
}
public
TournamentType
[]
getTournamentTypes
()
{
public
TournamentType
[]
getTournamentTypes
()
{
TournamentType
[]
items
=
TournamentType
.
values
();
TournamentType
[]
items
=
TournamentType
.
values
();
return
items
;
return
items
;
}
}
public
String
onFlowProcess
(
FlowEvent
event
)
{
public
String
onFlowProcess
(
FlowEvent
event
)
{
switch
(
event
.
getOldStep
())
{
switch
(
event
.
getOldStep
())
{
case
"selectGame"
:
case
"selectGame"
:
if
(
tournamentGameName
.
length
()
>
0
)
{
if
(
tournamentGameName
.
length
()
>
0
)
{
// oh lurd, we want to create a new gamy now
// oh lurd, we want to create a new gamy now
TournamentGame
tg
=
new
TournamentGame
();
TournamentGame
tg
=
new
TournamentGame
();
tg
.
setName
(
tournamentGameName
);
tg
.
setName
(
tournamentGameName
);
tg
.
setDescription
(
tournamentGameDescription
);
tg
.
setDescription
(
tournamentGameDescription
);
tg
.
setLanEvent
(
eventBean
.
getCurrentEvent
());
tg
.
setLanEvent
(
eventBean
.
getCurrentEvent
());
game
=
tournamentBean
.
createGame
(
tg
);
game
=
tournamentBean
.
createGame
(
tg
);
}
}
tournamentRules
=
tournamentBean
.
getRulesByGame
(
game
);
tournamentRules
=
tournamentBean
.
getRulesByGame
(
game
);
System
.
out
.
println
(
tournamentRules
);
System
.
out
.
println
(
tournamentRules
);
break
;
break
;
case
"selectRuleset"
:
case
"selectRuleset"
:
if
(
rulesetName
!=
null
&&
rulesetName
.
length
()
>
0
)
{
if
(
rulesetName
!=
null
&&
rulesetName
.
length
()
>
0
)
{
TournamentRule
tr
=
new
TournamentRule
();
TournamentRule
tr
=
new
TournamentRule
();
tr
.
setName
(
rulesetName
);
tr
.
setName
(
rulesetName
);
tr
.
setDescription
(
rulesetDescription
);
tr
.
setDescription
(
rulesetDescription
);
tr
.
setRules
(
rulesetRules
);
tr
.
setRules
(
rulesetRules
);
tr
.
setTournamentGame
(
game
);
tr
.
setTournamentGame
(
game
);
rules
=
tournamentBean
.
createRule
(
tr
);
rules
=
tournamentBean
.
createRule
(
tr
);
tournamentRules
=
tournamentBean
.
getRulesByGame
(
game
);
tournamentRules
=
tournamentBean
.
getRulesByGame
(
game
);
}
}
break
;
break
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentDeleteView.java
View file @
2cf5640
...
@@ -2,11 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
...
@@ -2,11 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.bean.ManagedProperty
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
...
@@ -16,31 +15,37 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
...
@@ -16,31 +15,37 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
public
class
TournamentDeleteView
extends
GenericCDIView
{
public
class
TournamentDeleteView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
7283815262506163537L
;
private
static
final
long
serialVersionUID
=
7283815262506163537L
;
private
Integer
id
=
null
;
private
Integer
id
=
null
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
String
showConfirm
(
Integer
id
)
{
public
String
showConfirm
(
Integer
id
)
{
this
.
beginConversation
();
this
.
beginConversation
();
this
.
id
=
id
;
this
.
id
=
id
;
return
"/tournaments/admin/delete.xhtml"
;
return
"/tournaments/admin/delete.xhtml"
;
}
}
public
String
delete
()
{
public
String
delete
()
{
if
(
this
.
id
!=
null
)
{
if
(
this
.
id
!=
null
)
{
try
{
try
{
tournamentBean
.
deleteTournament
(
tournamentBean
.
getTournamentById
(
this
.
id
));
tournamentBean
.
deleteTournament
(
tournamentBean
.
getTournamentById
(
this
.
id
));
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_deleted_successfully"
));
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_deleted_successfully"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_delete_failed"
));
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_delete_failed"
));
}
}
}
else
{
}
else
{
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_delete_failed"
));
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_delete_failed"
));
}
}
this
.
endConversation
();
this
.
endConversation
();
return
"/tournaments/admin/index.xhtml"
;
return
"/tournaments/admin/index.xhtml"
;
}
}
public
String
cancel
()
{
public
String
cancel
()
{
this
.
endConversation
();
this
.
endConversation
();
return
"/tournaments/admin/index.xhtml"
;
return
"/tournaments/admin/index.xhtml"
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentEditView.java
View file @
2cf5640
...
@@ -2,10 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
...
@@ -2,10 +2,10 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.ConversationScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.I18n
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
import
fi.codecrew.moya.utilities.jsf.MessageHelper
;
...
@@ -14,22 +14,32 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
...
@@ -14,22 +14,32 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@Named
@ConversationScoped
@ConversationScoped
public
class
TournamentEditView
extends
GenericCDIView
{
public
class
TournamentEditView
extends
GenericCDIView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
/**
*
*/
private
static
final
long
serialVersionUID
=
-
2655058086651272660L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
private
Tournament
tournament
=
null
;
private
Tournament
tournament
=
null
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
MANAGE_ALL
);
}
public
String
showEdit
(
Integer
tournamentId
)
{
public
String
showEdit
(
Integer
tournamentId
)
{
this
.
beginConversation
();
this
.
beginConversation
();
this
.
setTournament
(
tournamentBean
.
getTournamentById
(
tournamentId
));
this
.
setTournament
(
tournamentBean
.
getTournamentById
(
tournamentId
));
return
"/tournaments/admin/edit.xhtml"
;
return
"/tournaments/admin/edit.xhtml"
;
}
}
public
String
commit
()
{
public
String
commit
()
{
if
(
this
.
tournament
!=
null
)
{
if
(
this
.
tournament
!=
null
)
{
try
{
try
{
this
.
tournamentBean
.
editTournament
(
tournament
);
this
.
tournamentBean
.
editTournament
(
tournament
);
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_edited_successfully"
));
MessageHelper
.
info
(
I18n
.
get
(
"tournament.admin.tournament_edited_successfully"
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_edit_failed"
));
MessageHelper
.
err
(
I18n
.
get
(
"tournament.admin.tournament_edit_failed"
));
}
}
}
else
{
}
else
{
...
@@ -38,7 +48,7 @@ public class TournamentEditView extends GenericCDIView {
...
@@ -38,7 +48,7 @@ public class TournamentEditView extends GenericCDIView {
this
.
endConversation
();
this
.
endConversation
();
return
"/tournaments/admin/index.xhtml"
;
return
"/tournaments/admin/index.xhtml"
;
}
}
public
String
cancel
()
{
public
String
cancel
()
{
this
.
endConversation
();
this
.
endConversation
();
return
"/tournaments/admin/index.xhtml"
;
return
"/tournaments/admin/index.xhtml"
;
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentListView.java
View file @
2cf5640
...
@@ -16,6 +16,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
...
@@ -16,6 +16,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@RequestScoped
@RequestScoped
public
class
TournamentListView
extends
GenericCDIView
{
public
class
TournamentListView
extends
GenericCDIView
{
/**
*
*/
private
static
final
long
serialVersionUID
=
5401481953726472887L
;
@EJB
@EJB
private
TournamentBeanLocal
tournamentBean
;
private
TournamentBeanLocal
tournamentBean
;
...
@@ -23,6 +27,10 @@ public class TournamentListView extends GenericCDIView {
...
@@ -23,6 +27,10 @@ public class TournamentListView extends GenericCDIView {
super
.
requirePermissions
(
TournamentPermission
.
VIEW
);
super
.
requirePermissions
(
TournamentPermission
.
VIEW
);
}
}
public
boolean
canParticipate
()
{
return
super
.
hasPermission
(
TournamentPermission
.
PARTICIPATE
);
}
public
List
<
Tournament
>
getSetupPhaseTournaments
()
{
public
List
<
Tournament
>
getSetupPhaseTournaments
()
{
return
tournamentBean
.
getTournamentsInStatus
(
TournamentStatus
.
SETUP
,
true
);
return
tournamentBean
.
getTournamentsInStatus
(
TournamentStatus
.
SETUP
,
true
);
}
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentParticipateView.java
View file @
2cf5640
...
@@ -29,6 +29,10 @@ public class TournamentParticipateView extends GenericCDIView {
...
@@ -29,6 +29,10 @@ public class TournamentParticipateView extends GenericCDIView {
@EJB
@EJB
private
PermissionBeanLocal
permissionBean
;
private
PermissionBeanLocal
permissionBean
;
public
void
initView
()
{
super
.
requirePermissions
(
TournamentPermission
.
PARTICIPATE
);
}
private
String
selectedPlayerLogin
;
private
String
selectedPlayerLogin
;
private
String
selectedBackupPlayerLogin
;
private
String
selectedBackupPlayerLogin
;
...
@@ -66,6 +70,11 @@ public class TournamentParticipateView extends GenericCDIView {
...
@@ -66,6 +70,11 @@ public class TournamentParticipateView extends GenericCDIView {
}
}
public
String
participate
(
Integer
tournamentId
)
{
public
String
participate
(
Integer
tournamentId
)
{
if
(!
super
.
hasPermission
(
TournamentPermission
.
PARTICIPATE
))
{
super
.
addFaceMessage
(
"tournament.notRightsToParticipate"
);
return
null
;
}
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
if
(
tournamentBean
.
hasParticipations
(
permissionBean
.
getCurrentUser
(),
tournament
))
{
if
(
tournamentBean
.
hasParticipations
(
permissionBean
.
getCurrentUser
(),
tournament
))
{
MessageHelper
.
err
(
"tournament.already_participated_into_tournament"
);
MessageHelper
.
err
(
"tournament.already_participated_into_tournament"
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentRulesView.java
View file @
2cf5640
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.bean.ManagedProperty
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.enums.
TournamentStatus
;
import
fi.codecrew.moya.enums.
apps.TournamentPermission
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.web.cdiview.GenericCDIView
;
@Named
@Named
@RequestScoped
@RequestScoped
public
class
TournamentRulesView
{
public
class
TournamentRulesView
extends
GenericCDIView
{
@EJB
private
TournamentBeanLocal
tournamentBean
;
/**
*
*/
private
static
final
long
serialVersionUID
=
590702851593367871L
;
@EJB
private
TournamentBeanLocal
tournamentBean
;
private
Tournament
tournament
;
private
Tournament
tournament
;
private
Integer
tournamentId
;
private
Integer
tournamentId
;
public
void
init
()
{
public
void
init
()
{
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
if
(
super
.
requirePermissions
(
TournamentPermission
.
VIEW
))
{
tournament
=
tournamentBean
.
getTournamentById
(
tournamentId
);
}
}
}
public
Integer
getTournamentId
()
{
public
Integer
getTournamentId
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment