TournamentCreateView.java
3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package fi.codecrew.moya.web.cdiview.tournaments;
import java.io.Serializable;
import java.util.List;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.TournamentBeanLocal;
import fi.codecrew.moya.model.Role;
import fi.codecrew.moya.model.Tournament;
import fi.codecrew.moya.model.TournamentGame;
import fi.codecrew.moya.model.TournamentRule;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
import org.primefaces.event.FlowEvent;
@Named
@ConversationScoped
public class TournamentCreateView extends GenericCDIView {
private static final long serialVersionUID = 2547358764980373797L;
private List<TournamentGame> tournamentGames;
private List<TournamentRule> tournamentRules;
private TournamentRule rules = null;
private TournamentGame game = null;
private Tournament tournament = null;
private String tournamentGameName;
private String tournamentGameDescription;
private String rulesetName;
private String rulesetDescription;
@EJB TournamentBeanLocal tournamentBean;
@EJB EventBeanLocal eventBean;
public void initView() {
if(tournament == null) {
this.beginConversation();
tournament = new Tournament();
tournamentGames = tournamentBean.getGames();
}
}
public void save(ActionEvent actionEvent) {
}
public List<TournamentGame> getTournamentGames() {
return tournamentGames;
}
public List<TournamentRule> getTournamentRules() {
return tournamentRules;
}
public void uploadListener(org.primefaces.event.FileUploadEvent event) {
System.out.println("ZZ");
}
public String onFlowProcess(FlowEvent event) {
switch(event.getOldStep()) {
case "selectGame":
if(tournamentGameName.length() > 0) {
// oh lurd, we want to create a new gamy now
TournamentGame tg = new TournamentGame();
tg.setName(tournamentGameName);
tg.setDescription(tournamentGameDescription);
tg.setLanEvent(eventBean.getCurrentEvent());
tournamentBean.createGame(tg);
}
tournamentRules = tournamentBean.getRulesByGame(this.getGame());
break;
case "selectRuleset":
if(rulesetName != null && rulesetName.length() > 0) {
TournamentRule tr = new TournamentRule();
tr.setName(rulesetName);
tr.setDescription(rulesetDescription);
tournamentBean.createRule(tr);
}
break;
}
System.out.println(event.getOldStep());
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;
}
}