@Override public void onStart(Application app) { // Check if the database is empty if (User.finder.findRowCount() == 0) { Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml.load("initial-data.yml"); Ebean.save(all.get("users")); Ebean.save(all.get("projects")); Ebean.save(all.get("tasks")); } }
public static Result loadData() { @SuppressWarnings("unchecked") Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml.load("initial-data.yml"); // Insert books first Ebean.save(all.get("books")); Ebean.save(all.get("chapters")); // Insert paragraphs Ebean.save(all.get("paragraphs")); // Insert sentences Ebean.save(all.get("sentences")); return ok(""); }
public static void insert(Application app) { if (Ebean.find(User.class).findRowCount() == 0) { Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml.load("initial-data.yml"); // Insert users first Ebean.save(all.get("users")); // Insert tapps Ebean.save(all.get("apps")); // // Insert projects // Ebean.save(all.get("projects")); // for(Object project: all.get("projects")) { // // Insert the project/user relation // Ebean.saveManyToManyAssociations(project, "members"); // } // // } }
@Override public void onStart(Application application) { if (User.find.findRowCount() == 0) { Ebean.save((List) Yaml.load("initial-data.yml")); } }
@Before public void setUp() { start(fakeApplication(inMemoryDatabase(), fakeGlobal())); Ebean.save((List) Yaml.load("test-data.yml")); }