Commit 1aaf2bac by Antti Tonkyra

Add game to tournament and update db

1 parent 155aceb3
......@@ -27,6 +27,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
static {
// {"Query1","Query2",...}
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 users ALTER COLUMN birthday TYPE date" });
}
......
......@@ -8,7 +8,7 @@ import javax.ejb.Stateless;
*/
@Stateless
@LocalBean
public class TournamentBean {
public class TournamentBean implements TournamentBeanLocal {
/**
* Default constructor.
......@@ -16,6 +16,5 @@ public class TournamentBean {
public TournamentBean() {
// TODO Auto-generated constructor stub
}
}
package fi.codecrew.moya.beans;
import javax.ejb.Local;
@Local
public interface TournamentBeanLocal {
}
......@@ -60,6 +60,9 @@ public class Tournament extends GenericEntity implements Serializable {
@Column(name="players_per_team")
private Integer playersPerTeam;
@JoinColumn(name="game", nullable=false)
private TournamentGame tournamentGame;
@OneToMany
@OrderBy("id ASC")
private List<Tournament> subTournaments;
......@@ -105,4 +108,12 @@ public class Tournament extends GenericEntity implements Serializable {
public void setTournamentType(TournamentType tournamentType) {
this.tournamentType = tournamentType;
}
public TournamentGame getTournamentGame() {
return tournamentGame;
}
public void setTournamentGame(TournamentGame tournamentGame) {
this.tournamentGame = tournamentGame;
}
}
......@@ -2,7 +2,11 @@ package fi.codecrew.moya.web.cdiview.tournaments;
import java.io.Serializable;
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;
......@@ -14,26 +18,29 @@ import org.primefaces.event.FlowEvent;
@Named
@ConversationScoped
public class TournamentCreateView implements Serializable {
/**
*
*/
public class TournamentCreateView extends GenericCDIView {
private static final long serialVersionUID = 2547358764980373797L;
private TournamentRule rules = null;
private TournamentGame game = null;
private Tournament tournament = null;
@EJB TournamentBeanLocal tournamentBean;
public void initView() {
System.out.println("MOI");
if(tournament == null) {
this.beginConversation();
tournament = new Tournament();
}
}
// called on finish
public void save(ActionEvent actionEvent) {
}
public String onFlowProcess(FlowEvent event) {
System.out.println(event.getOldStep());
return event.getNewStep();
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!