Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 39393d8f
authored
Aug 31, 2013
by
Antti Tonkyra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More on tournament creation
1 parent
24efb803
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
161 additions
and
9 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentGameFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentRuleFacade.java
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/TournamentBeanLocal.java
code/MoyaWeb/WebContent/tournaments/admin/createwizard.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/TournamentBean.java
View file @
39393d8
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.util.List
;
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.TournamentGameFacade
;
import
fi.codecrew.moya.facade.TournamentRuleFacade
;
import
fi.codecrew.moya.model.Tournament
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentRule
;
/**
/**
* Session Bean implementation class TournamentBean
* Session Bean implementation class TournamentBean
*/
*/
...
@@ -10,11 +19,24 @@ import javax.ejb.Stateless;
...
@@ -10,11 +19,24 @@ import javax.ejb.Stateless;
@LocalBean
@LocalBean
public
class
TournamentBean
implements
TournamentBeanLocal
{
public
class
TournamentBean
implements
TournamentBeanLocal
{
@EJB
private
TournamentRuleFacade
tournamentRuleFacade
;
@EJB
private
TournamentGameFacade
tournamentGameFacade
;
/**
/**
* Default constructor.
* Default constructor.
*/
*/
public
TournamentBean
()
{
public
TournamentBean
()
{
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
@Override
public
List
<
TournamentRule
>
getRulesByGame
(
TournamentGame
tg
)
{
return
tournamentRuleFacade
.
getRulesByGame
(
tg
);
}
@Override
public
List
<
TournamentGame
>
getGames
()
{
return
tournamentGameFacade
.
getGames
();
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentGameFacade.java
View file @
39393d8
package
fi
.
codecrew
.
moya
.
facade
;
package
fi
.
codecrew
.
moya
.
facade
;
import
java.util.List
;
import
javax.ejb.EJB
;
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.beans.EventBean
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentGame_
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.model.TournamentRule_
;
@Stateless
@Stateless
@LocalBean
@LocalBean
public
class
TournamentGameFacade
extends
IntegerPkGenericFacade
<
TournamentGame
>
{
public
class
TournamentGameFacade
extends
IntegerPkGenericFacade
<
TournamentGame
>
{
@EJB
private
EventBean
eventBean
;
public
TournamentGameFacade
()
{
public
TournamentGameFacade
()
{
super
(
TournamentGame
.
class
);
super
(
TournamentGame
.
class
);
}
}
public
List
<
TournamentGame
>
getGames
()
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
TournamentGame
>
cq
=
cb
.
createQuery
(
TournamentGame
.
class
);
Root
<
TournamentGame
>
root
=
cq
.
from
(
TournamentGame
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
TournamentGame_
.
lanEvent
),
eventBean
.
getCurrentEvent
()));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentRuleFacade.java
View file @
39393d8
package
fi
.
codecrew
.
moya
.
facade
;
package
fi
.
codecrew
.
moya
.
facade
;
import
java.util.List
;
import
javax.ejb.EJB
;
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.beans.EventBean
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role_
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.model.TournamentRule
;
import
fi.codecrew.moya.model.TournamentRule_
;
@Stateless
@Stateless
@LocalBean
@LocalBean
public
class
TournamentRuleFacade
extends
IntegerPkGenericFacade
<
TournamentRule
>
{
public
class
TournamentRuleFacade
extends
IntegerPkGenericFacade
<
TournamentRule
>
{
public
TournamentRuleFacade
()
{
public
TournamentRuleFacade
()
{
super
(
TournamentRule
.
class
);
super
(
TournamentRule
.
class
);
}
}
public
List
<
TournamentRule
>
getRulesByGame
(
TournamentGame
tg
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
TournamentRule
>
cq
=
cb
.
createQuery
(
TournamentRule
.
class
);
Root
<
TournamentRule
>
root
=
cq
.
from
(
TournamentRule
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
TournamentRule_
.
tournamentGame
),
tg
));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
}
code/MoyaBeansClient/ejbModule/fi/codecrew/moya/beans/TournamentBeanLocal.java
View file @
39393d8
package
fi
.
codecrew
.
moya
.
beans
;
package
fi
.
codecrew
.
moya
.
beans
;
import
java.util.List
;
import
javax.ejb.Local
;
import
javax.ejb.Local
;
import
fi.codecrew.moya.model.TournamentGame
;
import
fi.codecrew.moya.model.TournamentRule
;
@Local
@Local
public
interface
TournamentBeanLocal
{
public
interface
TournamentBeanLocal
{
List
<
TournamentGame
>
getGames
();
List
<
TournamentRule
>
getRulesByGame
(
TournamentGame
tg
);
}
}
code/MoyaWeb/WebContent/tournaments/admin/createwizard.xhtml
View file @
39393d8
...
@@ -19,12 +19,12 @@
...
@@ -19,12 +19,12 @@
<h:messages
errorClass=
"error"
/>
<h:messages
errorClass=
"error"
/>
<h
2>
#{i18n['actionlog.tournaments.admin.select_a_game']}
</h2
>
<h
:panelGroup
rendered=
"#{tournamentCreateView.tournamentGames.isEmpty() eq false}"
>
<p:selectOneMenu
>
<h2>
#{i18n['actionlog.tournaments.admin.select_a_game']}
</h2
>
<
f:selectItem
itemLabel=
""
/
>
<
p:selectOneMenu
>
<f:selectItem
itemLabel=
"spurdo spärde"
/
>
<f:selectItems
value=
"#{tournamentCreateView.tournamentGames}"
></f:selectItems
>
<
f:selectItem
itemLabel=
"cockmaster"
/
>
<
/p:selectOneMenu
>
</
p:selectOneMenu
>
</
h:panelGroup
>
<h2>
#{i18n['actionlog.tournaments.admin.create_a_game']}
</h2>
<h2>
#{i18n['actionlog.tournaments.admin.create_a_game']}
</h2>
...
@@ -48,9 +48,7 @@
...
@@ -48,9 +48,7 @@
<h:messages
errorClass=
"error"
/>
<h:messages
errorClass=
"error"
/>
<h2>
#{i18n['actionlog.tournaments.admin.select_a_ruleset']}
</h2>
<h2>
#{i18n['actionlog.tournaments.admin.select_a_ruleset']}
</h2>
<p:selectOneMenu>
<p:selectOneMenu>
<f:selectItem
itemLabel=
""
/>
<f:selectItems
value=
"#{tournamentCreateView.tournamentRules}"
></f:selectItems>
<f:selectItem
itemLabel=
"Pro-rules"
/>
<f:selectItem
itemLabel=
"N00b-rules"
/>
</p:selectOneMenu>
</p:selectOneMenu>
<br
/>
<br
/>
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/tournaments/TournamentCreateView.java
View file @
39393d8
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
package
fi
.
codecrew
.
moya
.
web
.
cdiview
.
tournaments
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.beans.TournamentBeanLocal
;
import
fi.codecrew.moya.model.Role
;
import
fi.codecrew.moya.model.Role
;
...
@@ -21,26 +22,106 @@ import org.primefaces.event.FlowEvent;
...
@@ -21,26 +22,106 @@ import org.primefaces.event.FlowEvent;
public
class
TournamentCreateView
extends
GenericCDIView
{
public
class
TournamentCreateView
extends
GenericCDIView
{
private
static
final
long
serialVersionUID
=
2547358764980373797L
;
private
static
final
long
serialVersionUID
=
2547358764980373797L
;
private
List
<
TournamentGame
>
tournamentGames
;
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
tournamentGameDescription
;
private
String
rulesetName
;
private
String
rulesetDescription
;
@EJB
TournamentBeanLocal
tournamentBean
;
@EJB
TournamentBeanLocal
tournamentBean
;
public
void
initView
()
{
public
void
initView
()
{
if
(
tournament
==
null
)
{
if
(
tournament
==
null
)
{
this
.
beginConversation
();
this
.
beginConversation
();
tournament
=
new
Tournament
();
tournament
=
new
Tournament
();
tournamentGames
=
tournamentBean
.
getGames
();
}
}
}
}
public
void
save
(
ActionEvent
actionEvent
)
{
public
void
save
(
ActionEvent
actionEvent
)
{
}
}
public
List
<
TournamentGame
>
getTournamentGames
()
{
return
tournamentGames
;
}
public
List
<
TournamentRule
>
getTournamentRules
()
{
return
tournamentRules
;
}
public
String
onFlowProcess
(
FlowEvent
event
)
{
public
String
onFlowProcess
(
FlowEvent
event
)
{
switch
(
event
.
getOldStep
())
{
case
"selectGame"
:
if
(
tournamentGameName
.
length
()
>
0
)
{
// logic-create-new
}
tournamentRules
=
tournamentBean
.
getRulesByGame
(
this
.
getGame
());
break
;
case
"selectRuleset"
:
if
(
rulesetName
.
length
()
>
0
)
{
// logic-create-new
}
break
;
}
System
.
out
.
println
(
event
.
getOldStep
());
System
.
out
.
println
(
event
.
getOldStep
());
return
event
.
getNewStep
();
return
event
.
getNewStep
();
}
}
public
TournamentGame
getGame
()
{
return
game
;
}
public
void
setGame
(
TournamentGame
game
)
{
this
.
game
=
game
;
}
public
TournamentRule
getRules
()
{
return
rules
;
}
public
void
setRules
(
TournamentRule
rules
)
{
this
.
rules
=
rules
;
}
public
String
getTournamentGameName
()
{
return
tournamentGameName
;
}
public
void
setTournamentGameName
(
String
tournamentGameName
)
{
this
.
tournamentGameName
=
tournamentGameName
;
}
public
String
getTournamentGameDescription
()
{
return
tournamentGameDescription
;
}
public
void
setTournamentGameDescription
(
String
tournamentGameDescription
)
{
this
.
tournamentGameDescription
=
tournamentGameDescription
;
}
public
String
getRulesetName
()
{
return
rulesetName
;
}
public
void
setRulesetName
(
String
rulesetName
)
{
this
.
rulesetName
=
rulesetName
;
}
public
String
getRulesetDescription
()
{
return
rulesetDescription
;
}
public
void
setRulesetDescription
(
String
rulesetDescription
)
{
this
.
rulesetDescription
=
rulesetDescription
;
}
}
}
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