Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 695806c2
authored
Sep 01, 2013
by
Antti Tonkyra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tournament creation
1 parent
c5592bac
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
161 additions
and
22 deletions
code/MoyaAuthModuleClient/.settings/org.eclipse.core.resources.prefs
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/TournamentBeanLocal.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Tournament.java
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentRule.java
code/MoyaWeb/WebContent/tournaments/admin/createwizard.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
code/MoyaAuthModuleClient/.settings/org.eclipse.core.resources.prefs
deleted
100644 → 0
View file @
c5592ba
eclipse.preferences.version=1
encoding/<project>=UTF-8
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
695806c
...
@@ -28,6 +28,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -28,6 +28,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
// {"Query1","Query2",...}
// {"Query1","Query2",...}
dbUpdates
.
add
(
new
String
[]
{
""
});
// first version, no changes
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 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" });
// dbUpdates.add(new String[] { "ALTER TABLE users ALTER COLUMN birthday TYPE date" });
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
View file @
695806c
...
@@ -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.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
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
...
@@ -21,6 +22,7 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -21,6 +22,7 @@ public class TournamentBean implements TournamentBeanLocal {
@EJB
private
TournamentRuleFacade
tournamentRuleFacade
;
@EJB
private
TournamentRuleFacade
tournamentRuleFacade
;
@EJB
private
TournamentGameFacade
tournamentGameFacade
;
@EJB
private
TournamentGameFacade
tournamentGameFacade
;
@EJB
private
TournamentFacade
tournamentFacade
;
/**
/**
* Default constructor.
* Default constructor.
...
@@ -45,8 +47,8 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -45,8 +47,8 @@ public class TournamentBean implements TournamentBeanLocal {
}
}
@Override
@Override
public
void
createRule
(
TournamentRule
tr
)
{
public
TournamentRule
createRule
(
TournamentRule
tr
)
{
tournamentRuleFacade
.
create
(
tr
);
return
tournamentRuleFacade
.
create
(
tr
);
}
}
@Override
@Override
...
@@ -58,4 +60,9 @@ public class TournamentBean implements TournamentBeanLocal {
...
@@ -58,4 +60,9 @@ public class TournamentBean implements TournamentBeanLocal {
public
TournamentRule
findRule
(
Integer
id
)
{
public
TournamentRule
findRule
(
Integer
id
)
{
return
tournamentRuleFacade
.
find
(
id
);
return
tournamentRuleFacade
.
find
(
id
);
}
}
@Override
public
void
createTournament
(
Tournament
tournament
)
{
tournamentFacade
.
create
(
tournament
);
}
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/TournamentBeanLocal.java
View file @
695806c
...
@@ -4,6 +4,7 @@ import java.util.List;
...
@@ -4,6 +4,7 @@ import java.util.List;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
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
;
...
@@ -13,8 +14,9 @@ public interface TournamentBeanLocal {
...
@@ -13,8 +14,9 @@ public interface TournamentBeanLocal {
List
<
TournamentGame
>
getGames
();
List
<
TournamentGame
>
getGames
();
List
<
TournamentRule
>
getRulesByGame
(
TournamentGame
tg
);
List
<
TournamentRule
>
getRulesByGame
(
TournamentGame
tg
);
void
createGame
(
TournamentGame
tg
);
void
createGame
(
TournamentGame
tg
);
void
createRule
(
TournamentRule
tr
);
TournamentRule
createRule
(
TournamentRule
tr
);
TournamentGame
findGame
(
Integer
id
);
TournamentGame
findGame
(
Integer
id
);
TournamentRule
findRule
(
Integer
id
);
TournamentRule
findRule
(
Integer
id
);
void
createTournament
(
Tournament
tournament
);
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/Tournament.java
View file @
695806c
...
@@ -63,6 +63,17 @@ public class Tournament extends GenericEntity implements Serializable {
...
@@ -63,6 +63,17 @@ public class Tournament extends GenericEntity implements Serializable {
@JoinColumn
(
name
=
"game"
,
nullable
=
false
)
@JoinColumn
(
name
=
"game"
,
nullable
=
false
)
private
TournamentGame
tournamentGame
;
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
@OneToMany
@OrderBy
(
"id ASC"
)
@OrderBy
(
"id ASC"
)
private
List
<
Tournament
>
subTournaments
;
private
List
<
Tournament
>
subTournaments
;
...
@@ -116,4 +127,60 @@ public class Tournament extends GenericEntity implements Serializable {
...
@@ -116,4 +127,60 @@ public class Tournament extends GenericEntity implements Serializable {
public
void
setTournamentGame
(
TournamentGame
tournamentGame
)
{
public
void
setTournamentGame
(
TournamentGame
tournamentGame
)
{
this
.
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
;
}
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentRule.java
View file @
695806c
...
@@ -62,6 +62,14 @@ public class TournamentRule extends GenericEntity implements Serializable {
...
@@ -62,6 +62,14 @@ public class TournamentRule extends GenericEntity implements Serializable {
public
void
setRules
(
String
rules
)
{
public
void
setRules
(
String
rules
)
{
this
.
rules
=
rules
;
this
.
rules
=
rules
;
}
}
public
TournamentGame
getTournamentGame
()
{
return
tournamentGame
;
}
public
void
setTournamentGame
(
TournamentGame
tournamentGame
)
{
this
.
tournamentGame
=
tournamentGame
;
}
}
}
code/MoyaWeb/WebContent/tournaments/admin/createwizard.xhtml
View file @
695806c
...
@@ -16,13 +16,11 @@
...
@@ -16,13 +16,11 @@
<p:tab
id=
"selectGame"
title=
"#{i18n['tournaments.admin.select_a_game']}"
>
<p:tab
id=
"selectGame"
title=
"#{i18n['tournaments.admin.select_a_game']}"
>
<p:panel>
<p:panel>
<h:messages
errorClass=
"error"
/>
<h:messages
errorClass=
"error"
/>
<h:panelGroup
rendered=
"#{tournamentCreateView.tournamentGames.isEmpty() eq false}"
>
<h:panelGroup
rendered=
"#{tournamentCreateView.tournamentGames.isEmpty() eq false}"
>
<h2>
#{i18n['tournaments.admin.select_a_game']}
</h2>
<h2>
#{i18n['tournaments.admin.select_a_game']}
</h2>
<h:selectOneMenu
value=
"#{tournamentCreateView.game}"
converter=
"#{tournamentGameConverter}"
>
<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:selectOneMenu>
</h:panelGroup>
</h:panelGroup>
...
@@ -40,15 +38,13 @@
...
@@ -40,15 +38,13 @@
<p:tab
id=
"selectRuleset"
title=
"#{i18n['tournaments.admin.rules']}"
>
<p:tab
id=
"selectRuleset"
title=
"#{i18n['tournaments.admin.rules']}"
>
<p:panel>
<p:panel>
<h:messages
errorClass=
"error"
/>
<h:messages
errorClass=
"error"
/>
<h:panelGroup
rendered=
"#{tournamentCreateView.tournamentRules.isEmpty() eq false}"
>
<h:panelGroup
rendered=
"#{tournamentCreateView.tournamentRules.isEmpty() eq false}"
>
<h2>
#{i18n['tournaments.admin.select_a_ruleset']}
</h2>
<h2>
#{i18n['tournaments.admin.select_a_ruleset']}
</h2>
<h:selectOneMenu
value=
"#{tournamentCreateView.rules}"
converter=
"#{tournamentRuleConverter}"
>
<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:selectOneMenu>
</h:panelGroup>
</h:panelGroup>
<br
/>
<h2>
#{i18n['tournaments.admin.create_new_ruleset']}
</h2>
<h2>
#{i18n['tournaments.admin.create_new_ruleset']}
</h2>
<h:outputText
value=
"#{i18n['tournaments.ruleset_name']}"
/>
<h:outputText
value=
"#{i18n['tournaments.ruleset_name']}"
/>
...
@@ -65,22 +61,48 @@
...
@@ -65,22 +61,48 @@
<p:tab
id=
"selectRegTimes"
title=
"#{i18n['tournaments.admin.set_time_constraints']}"
>
<p:tab
id=
"selectRegTimes"
title=
"#{i18n['tournaments.admin.set_time_constraints']}"
>
<p:panel>
<p:panel>
<h:messages
errorClass=
"error"
/>
<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:panelGrid
columns=
"2"
>
<h:outputText
value=
"#{i18n['tournaments.registration_opens']}"
/>
<h:outputText
value=
"#{i18n['tournaments.registration_opens']}"
/>
<h:outputText
value=
"#{i18n['tournaments.registration_closes']}"
/>
<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"
value=
"#{tournamentCreateView.tournament.registrationOpensAt}"
/>
<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.registrationClosesAt}"
/>
</h:panelGrid>
</h:panelGrid>
<h2>
#{i18n['tournaments.admin.begin_time_constraints']}
</h2>
<h2>
#{i18n['tournaments.admin.begin_time_constraints']}
</h2>
<h:panelGrid>
<h:panelGrid>
<h:outputText
value=
"Start time"
/>
<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>
</h:panelGrid>
</p:panel>
</p:panel>
<div
style=
"float: right;"
>
<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>
</div>
</p:tab>
</p:tab>
</p:wizard>
</p:wizard>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
View file @
695806c
...
@@ -5,6 +5,8 @@ import java.util.List;
...
@@ -5,6 +5,8 @@ import java.util.List;
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.TournamentType
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentGame
;
...
@@ -36,6 +38,8 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -36,6 +38,8 @@ public class TournamentCreateView extends GenericCDIView {
private
String
rulesetName
;
private
String
rulesetName
;
private
String
rulesetDescription
;
private
String
rulesetDescription
;
private
Integer
backupPlayers
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
EventBeanLocal
eventBean
;
@EJB
EventBeanLocal
eventBean
;
...
@@ -43,13 +47,20 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -43,13 +47,20 @@ public class TournamentCreateView extends GenericCDIView {
if
(
tournament
==
null
)
{
if
(
tournament
==
null
)
{
this
.
beginConversation
();
this
.
beginConversation
();
tournament
=
new
Tournament
();
tournament
=
new
Tournament
();
tournament
.
setPlayersPerMatch
(
0
);
backupPlayers
=
0
;
tournamentGames
=
tournamentBean
.
getGames
();
tournamentGames
=
tournamentBean
.
getGames
();
}
}
}
}
public
void
save
(
ActionEvent
actionEvent
)
{
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
()
{
public
List
<
TournamentGame
>
getTournamentGames
()
{
...
@@ -63,6 +74,11 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -63,6 +74,11 @@ public class TournamentCreateView extends GenericCDIView {
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
()
{
TournamentType
[]
items
=
TournamentType
.
values
();
return
items
;
}
public
String
onFlowProcess
(
FlowEvent
event
)
{
public
String
onFlowProcess
(
FlowEvent
event
)
{
switch
(
event
.
getOldStep
())
{
switch
(
event
.
getOldStep
())
{
...
@@ -77,19 +93,21 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -77,19 +93,21 @@ public class TournamentCreateView extends GenericCDIView {
tournamentBean
.
createGame
(
tg
);
tournamentBean
.
createGame
(
tg
);
}
}
tournamentRules
=
tournamentBean
.
getRulesByGame
(
this
.
getGame
());
tournamentRules
=
tournamentBean
.
getRulesByGame
(
game
);
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
.
setRules
(
rulesetDescription
);
tr
.
setTournamentGame
(
game
);
rules
=
tournamentBean
.
createRule
(
tr
);
tournament
Bean
.
createRule
(
tr
);
tournament
Rules
=
tournamentBean
.
getRulesByGame
(
game
);
}
}
break
;
break
;
}
}
System
.
out
.
println
(
event
.
getOldStep
());
return
event
.
getNewStep
();
return
event
.
getNewStep
();
}
}
...
@@ -140,4 +158,20 @@ public class TournamentCreateView extends GenericCDIView {
...
@@ -140,4 +158,20 @@ public class TournamentCreateView extends GenericCDIView {
public
void
setRulesetDescription
(
String
rulesetDescription
)
{
public
void
setRulesetDescription
(
String
rulesetDescription
)
{
this
.
rulesetDescription
=
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
;
}
}
}
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