Commit 83830fd0 by Tuomas Riihimäki

Lisätty polliin liittyviä entityjä

1 parent 7ddb68ae
...@@ -3,8 +3,10 @@ package fi.insomnia.bortal.model; ...@@ -3,8 +3,10 @@ package fi.insomnia.bortal.model;
import fi.insomnia.bortal.model.GenericEntity; import fi.insomnia.bortal.model.GenericEntity;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import javax.persistence.*; import javax.persistence.*;
import static javax.persistence.TemporalType.TIMESTAMP; import static javax.persistence.TemporalType.TIMESTAMP;
/** /**
...@@ -12,21 +14,33 @@ import static javax.persistence.TemporalType.TIMESTAMP; ...@@ -12,21 +14,33 @@ import static javax.persistence.TemporalType.TIMESTAMP;
* *
*/ */
@Entity @Entity
public class Poll extends GenericEntity implements Serializable { @Table(name = "poll")
public class Poll extends GenericEventChild implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -5655775315722028984L; private static final long serialVersionUID = -5655775315722028984L;
@Temporal(TIMESTAMP) @Temporal(TIMESTAMP)
private Calendar begin = Calendar.getInstance(); private Calendar begin = Calendar.getInstance();
@Temporal(TIMESTAMP) @Temporal(TIMESTAMP)
private Calendar end = Calendar.getInstance(); private Calendar end = Calendar.getInstance();
private String name;
@Lob
private String description;
@OneToMany(mappedBy="poll")
private List<PollQuestion> questions;
public Poll() { public Poll() {
super(); super();
} }
public Poll(LanEvent e) {
super(e);
}
public Calendar getBegin() { public Calendar getBegin() {
return begin; return begin;
} }
...@@ -43,4 +57,20 @@ public class Poll extends GenericEntity implements Serializable { ...@@ -43,4 +57,20 @@ public class Poll extends GenericEntity implements Serializable {
this.end = end; this.end = end;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
} }
package fi.insomnia.bortal.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "poll_question")
public class PollQuestion extends GenericEventChild {
/**
*
*/
private static final long serialVersionUID = 821112669474215823L;
@JoinColumns({
@JoinColumn(name = "poll_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne
private Poll poll;
@OneToMany(mappedBy = "question")
private List<PossibleAnswer> answers;
@Lob
private String question;
@Column(nullable = false)
private Integer choices = 1;
@Column(nullable = false)
private Integer sort = 100;
@Column(nullable = false)
private Integer page = 1;
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
public Integer getChoices() {
return choices;
}
public void setChoices(Integer choices) {
this.choices = choices;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Poll getPoll() {
return poll;
}
public void setPoll(Poll poll) {
this.poll = poll;
}
public List<PossibleAnswers> getAnswers() {
return answers;
}
public void setAnswers(List<PossibleAnswers> answers) {
this.answers = answers;
}
}
package fi.insomnia.bortal.model;
import javax.annotation.Generated;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value="Dali", date="2010-10-31T00:13:19.391+0300")
@StaticMetamodel(PollQuestion.class)
public class PollQuestion_ extends GenericEventChild_ {
public static volatile SingularAttribute<PollQuestion, String> question;
public static volatile SingularAttribute<PollQuestion, Integer> choices;
public static volatile SingularAttribute<PollQuestion, Integer> sort;
public static volatile SingularAttribute<PollQuestion, Integer> page;
public static volatile ListAttribute<PollQuestion, PossibleAnswer> answers;
public static volatile SingularAttribute<PollQuestion, Poll> poll;
}
package fi.insomnia.bortal.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "poll_question")
public class PossibleAnswer extends GenericEventChild {
/**
*
*/
private static final long serialVersionUID = 1686553713211996800L;
@Column(nullable = false)
private String answer;
@Column(nullable = false)
private Integer sort = 100;
@Column(nullable = false)
private boolean text = false;
@Lob
private String description;
@JoinColumns({
@JoinColumn(name = "question_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne
private PollQuestion question;
@OneToMany(mappedBy="choice")
private List<PollAnswer> answers;
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public boolean isText() {
return text;
}
public void setText(boolean text) {
this.text = text;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public PollQuestion getQuestion() {
return question;
}
public void setQuestion(PollQuestion question) {
this.question = question;
}
public List<PollAnswer> getAnswers() {
return answers;
}
public void setAnswers(List<PollAnswer> answers) {
this.answers = answers;
}
}
package fi.insomnia.bortal.model;
import javax.annotation.Generated;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value="Dali", date="2010-10-31T00:21:50.963+0300")
@StaticMetamodel(PossibleAnswer.class)
public class PossibleAnswer_ extends GenericEventChild_ {
public static volatile SingularAttribute<PossibleAnswer, Integer> sort;
public static volatile SingularAttribute<PossibleAnswer, Boolean> text;
public static volatile SingularAttribute<PossibleAnswer, String> description;
public static volatile SingularAttribute<PossibleAnswer, String> answer;
public static volatile SingularAttribute<PossibleAnswer, PollQuestion> question;
public static volatile ListAttribute<PossibleAnswer, PollAnswer> answers;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!