Commit 8c45e26c authored by Fjen Undso's avatar Fjen Undso
Browse files

models: add contructors and modelfinder

parent d2b703ea
......@@ -22,6 +22,7 @@ public class Question extends Model {
public String id;
@ManyToOne
@Constraints.Required
public Session session;
@Constraints.Required
......@@ -36,4 +37,11 @@ public class Question extends Model {
@Column(nullable = true)
public List<QuestionAnswer> answers = new ArrayList<>();
public static Finder find = new Finder(Long.class, Question.class);
public Question(Session session, String question) {
this.session = session;
this.question = question;
}
}
......@@ -19,6 +19,7 @@ public class QuestionAnswer extends Model {
public String id;
@ManyToOne
@Constraints.Required
public Question question;
@Constraints.Required
......@@ -44,4 +45,12 @@ public class QuestionAnswer extends Model {
D,
}
public static Finder find = new Finder(Long.class, QuestionAnswer.class);
public QuestionAnswer(Question question, String owner, Answer answer) {
this.question = question;
this.owner = owner;
this.answer = answer;
}
}
......@@ -40,4 +40,11 @@ public class Session extends Model {
@Column(nullable = true)
public List<Question> questions = new ArrayList<>();
public static Finder find = new Finder(Long.class, Session.class);
public Session(String owner, String name) {
this.owner = owner;
this.name = name;
this.open = true;
}
}
......@@ -20,6 +20,7 @@ public class Vote extends Model {
public String id;
@ManyToOne
@Constraints.Required
public Session session;
@Constraints.Required
......@@ -45,4 +46,13 @@ public class Vote extends Model {
REQUEST,
}
public static Finder find = new Finder(Long.class, Vote.class);
public Vote(Session session, String owner, Type type, Integer vote) {
this.session = session;
this.owner = owner;
this.type = type;
this.vote = vote;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment