Commit 7db910bf authored by Fjen Undso's avatar Fjen Undso
Browse files

add initial models

parent 04a48ed2
package models;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;
@Entity
public class Question extends Model {
@Id
public String id;
@ManyToOne
public Session session;
@Constraints.Required
public String question;
@Formats.DateTime(pattern = "yyyy-MM-dd HH:mm:ss")
public Date date = new Date();
public Boolean open;
@OneToMany(mappedBy = "question", cascade = CascadeType.ALL)
public List<QuestionAnswer> answers = new ArrayList<>();
}
package models;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;
@Entity
public class QuestionAnswer extends Model {
@Id
public String id;
@ManyToOne
public Question question;
@Constraints.Required
public String owner;
@Formats.DateTime(pattern = "yyyy-MM-dd HH:mm:ss")
public Date date = new Date();
public Integer vote;
}
package models;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;
@Entity
public class Session extends Model {
@Id
@Constraints.Max(6)
public String id;
@Constraints.Required
public String owner;
@Constraints.Required
public String name;
@Formats.DateTime(pattern = "yyyy-MM-dd")
public Date date = new Date();
public Boolean open;
@OneToMany(mappedBy = "session", cascade = CascadeType.ALL)
public List<Vote> votes = new ArrayList<>();
@OneToMany(mappedBy = "session", cascade = CascadeType.ALL)
public List<Question> questions = new ArrayList<>();
}
package models;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;
@Entity
public class Vote extends Model {
@Id
public String id;
@ManyToOne
public Session session;
@Constraints.Required
public String owner;
@Formats.DateTime(pattern = "yyyy-MM-dd HH:mm:ss")
public Date date = new Date();
public Integer 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