source: Dev/branches/play-2.0.1/samples/java/zentasks/app/Global.java @ 322

Last change on this file since 322 was 322, checked in by hendrikvanantwerpen, 13 years ago

Added Play! framework and application with Jena dependency. Working on
the basic things now (login/register), after that start implementing
our data model.

File size: 1.0 KB
Line 
1import play.*;
2import play.libs.*;
3
4import java.util.*;
5
6import com.avaje.ebean.*;
7
8import models.*;
9
10public class Global extends GlobalSettings {
11   
12    public void onStart(Application app) {
13        InitialData.insert(app);
14    }
15   
16    static class InitialData {
17       
18        public static void insert(Application app) {
19            if(Ebean.find(User.class).findRowCount() == 0) {
20               
21                Map<String,List<Object>> all = (Map<String,List<Object>>)Yaml.load("initial-data.yml");
22
23                // Insert users first
24                Ebean.save(all.get("users"));
25
26                // Insert projects
27                Ebean.save(all.get("projects"));
28                for(Object project: all.get("projects")) {
29                    // Insert the project/user relation
30                    Ebean.saveManyToManyAssociations(project, "members");
31                }
32
33                // Insert tasks
34                Ebean.save(all.get("tasks"));
35               
36            }
37        }
38       
39    }
40   
41}
Note: See TracBrowser for help on using the repository browser.