Commit 8474ad8c by Tuomas Riihimäki

Testidataa polleihin

1 parent d6de95c1
...@@ -34,7 +34,7 @@ public abstract class GenericEventChild implements EventChildInterface { ...@@ -34,7 +34,7 @@ public abstract class GenericEventChild implements EventChildInterface {
} }
public GenericEventChild(EventPk eventPk) { public GenericEventChild(EventPk eventPk) {
id = eventPk; id = new EventPk(eventPk.getEventId());
} }
@Override @Override
......
...@@ -3,6 +3,7 @@ package fi.insomnia.bortal.model; ...@@ -3,6 +3,7 @@ package fi.insomnia.bortal.model;
import static javax.persistence.TemporalType.TIMESTAMP; import static javax.persistence.TemporalType.TIMESTAMP;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
...@@ -43,7 +44,7 @@ public class Poll extends GenericEventChild implements Serializable { ...@@ -43,7 +44,7 @@ public class Poll extends GenericEventChild implements Serializable {
private String description; private String description;
@OneToMany(mappedBy = "poll", fetch = FetchType.EAGER) @OneToMany(mappedBy = "poll", fetch = FetchType.EAGER)
private List<PollQuestion> questions; private List<PollQuestion> questions = new ArrayList<PollQuestion>();
public Poll() { public Poll() {
super(); super();
......
package fi.insomnia.bortal.model; package fi.insomnia.bortal.model;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
...@@ -15,6 +16,16 @@ import javax.persistence.Table; ...@@ -15,6 +16,16 @@ import javax.persistence.Table;
@Table(name = "poll_question") @Table(name = "poll_question")
public class PollQuestion extends GenericEventChild { public class PollQuestion extends GenericEventChild {
public PollQuestion() {
super();
}
public PollQuestion(Poll p) {
super(p.getId());
this.poll = p;
}
/** /**
* *
*/ */
...@@ -27,7 +38,7 @@ public class PollQuestion extends GenericEventChild { ...@@ -27,7 +38,7 @@ public class PollQuestion extends GenericEventChild {
private Poll poll; private Poll poll;
@OneToMany(mappedBy = "question") @OneToMany(mappedBy = "question")
private List<PossibleAnswer> answers; private List<PossibleAnswer> answers = new ArrayList<PossibleAnswer>();
@Lob @Lob
private String question; private String question;
...@@ -41,10 +52,11 @@ public class PollQuestion extends GenericEventChild { ...@@ -41,10 +52,11 @@ public class PollQuestion extends GenericEventChild {
public String getQuestion() { public String getQuestion() {
return question; return question;
} }
public boolean isFreeText()
{ public boolean isFreeText() {
return (answers.size() == 1 && answers.get(0).isText()); return (answers.size() == 1 && answers.get(0).isText());
} }
public void setQuestion(String question) { public void setQuestion(String question) {
this.question = question; this.question = question;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!