Commit eef1b57e authored by Fjen Undso's avatar Fjen Undso
Browse files

add test data

parent 28fe6a42
import play.*;
import play.libs.*;
import com.avaje.ebean.Ebean;
import models.*;
import java.util.*;
public class Global extends GlobalSettings {
@Override
public void onStart(Application app) {
Logger.info("Application has started");
// Check if the database is empty
if (Session.find.findRowCount() == 0) {
List list = (List) Yaml.load("test-data.yml");
Ebean.save(list);
}
}
public void onStop(Application app) {
Logger.info("Application shutdown...");
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import play.data.validation.Constraints;
import play.db.ebean.Model;
import com.avaje.ebean.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
public class QuestionAnswer extends Model {
......@@ -18,6 +19,7 @@ public class QuestionAnswer extends Model {
@Id
public Long id;
@JsonIgnore
@ManyToOne
@Constraints.Required
public Session session;
......
......@@ -16,6 +16,8 @@ import play.data.format.Formats;
import play.data.validation.Constraints;
import play.db.ebean.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
public class Session extends Model {
......@@ -34,16 +36,18 @@ public class Session extends Model {
public Boolean open;
@JsonIgnore
@OneToMany(mappedBy = "session", cascade = CascadeType.ALL)
@Column(nullable = true)
public List<Vote> votes = new ArrayList<>();
public List<Vote> votes = new ArrayList<Vote>();
@Formats.DateTime(pattern = "yyyy-MM-dd HH:mm:ss")
public Date resetDate = new Date();
@JsonIgnore
@OneToMany(mappedBy = "session", cascade = CascadeType.ALL)
@Column(nullable = true)
public List<QuestionAnswer> questionAnswers = new ArrayList<>();
public List<QuestionAnswer> questionAnswers = new ArrayList<QuestionAnswer>();
public static Finder<String, Session> find = new Finder<String, Session>(
String.class, Session.class);
......
......@@ -12,6 +12,7 @@ import play.data.validation.Constraints;
import play.db.ebean.Model;
import com.avaje.ebean.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
public class Vote extends Model {
......@@ -19,6 +20,7 @@ public class Vote extends Model {
@Id
public Long id;
@JsonIgnore
@ManyToOne
@Constraints.Required
public Session session;
......
......@@ -48,6 +48,7 @@ db.default.url="jdbc:h2:mem:play"
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
applyEvolutions.default=true
# Ebean configuration
# ~~~~~
......
- !!models.Session
id: aaaaaa
owner: s1owner
name: Applab
date: 2015-05-25
open: false
resetDate: 2015-05-25 13:13:00
votes:
- !!models.Vote
owner: v1owner
vote: 0
type: SPEED
date: 2015-05-25 13:14:00
- !!models.Vote
owner: v2owner
vote: 2
type: UNDERSTANDABILITY
date: 2015-05-25 13:14:00
- !!models.Vote
owner: v3owner
vote: 0
type: REQUEST
date: 2015-05-25 13:14:00
- !!models.Session
id: bbbbbb
owner: s2owner
name: SWQ
date: 2015-05-26
open: true
resetDate: 2015-05-26 13:13:00
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