View Javadoc
1   package org.melati.example.contacts;
2   
3   import org.melati.example.contacts.generated.ContactsDatabaseBase;
4   import org.melati.poem.PoemTask;
5   
6   /**
7    * Melati POEM generated, programmer modifiable stub.
8    */
9   public class ContactsDatabase extends ContactsDatabaseBase
10                              implements ContactsDatabaseTables {
11    // programmer's domain-specific code here
12    public void connect(String name, String dbmsclass, String url, String username,
13                        String password, int maxConnections) {
14      super.connect(name, dbmsclass, url, username, password, maxConnections);
15  
16      // We can't use the normal AccessToken.root
17      // as we need the troid to set lastupdateuser
18      inSession(getUserTable().administratorUser(), new PoemTask() {
19        public void run() {
20          Contact eve =
21              getContactTable().ensure(
22                  "Eve",
23                  null,
24                  "Eden");
25          Contact adam =
26              getContactTable().ensure(
27                  "Adam",
28                  null,
29                  "Eden");
30          Contact seth =
31          getContactTable().ensure(
32              "Seth",
33              adam,
34              "Eden");
35          Contact abel =
36              getContactTable().ensure(
37                  "Abel",
38                  adam,
39                  "Eden");
40          Contact lamech =
41            getContactTable().ensure(
42              "Lamech",
43               getContactTable().ensure(
44                "Methusael",
45                getContactTable().ensure(
46                  "Mehujael",
47                  getContactTable().ensure(
48                    "Irad",
49                    getContactTable().ensure(
50                      "Enoch",
51                      getContactTable().ensure(
52                        "Cain",
53                        adam,
54                        "Nod"),
55                      "Enoch"),
56                    "Enoch"),
57                  "Enoch"),
58                "Enoch"),
59              "Enoch");
60          Contact adah =
61              getContactTable().ensure(
62                  "Adah",
63                  lamech,
64                  "Enoch");
65          Contact jabal =
66              getContactTable().ensure(
67                  "Jabal",
68                  lamech,
69                  "Enoch");
70          Contact jubal =
71              getContactTable().ensure(
72                  "Jubal",
73                  lamech,
74                  "Enoch");
75          Contact naamah =
76              getContactTable().ensure(
77                  "Naamah",
78                  lamech,
79                  "Enoch");
80          Contact tc =
81              getContactTable().ensure(
82                  "Tubal-cain",
83                  lamech,
84                  "Enoch");
85          Contact zilla =
86              getContactTable().ensure(
87                  "Zilla",
88                  lamech,
89                  "Enoch");
90  
91          Category son = getCategoryTable().ensure("son");
92          Category daughter = getCategoryTable().ensure("daughter");
93          Category other = getCategoryTable().ensure("other");
94  
95          getContactCategoryTable().ensure(eve, other);
96          getContactCategoryTable().ensure(adam, other);
97          getContactCategoryTable().ensure(seth, son);
98          getContactCategoryTable().ensure(abel, son);
99          getContactCategoryTable().ensure(lamech, son);
100         getContactCategoryTable().ensure(adah, daughter);
101         getContactCategoryTable().ensure(jabal, son);
102         getContactCategoryTable().ensure(jubal, son);
103         getContactCategoryTable().ensure(naamah, son);
104         getContactCategoryTable().ensure(tc, son);
105         getContactCategoryTable().ensure(zilla, daughter);
106 
107       }
108     });
109   }
110 }