View Javadoc

1   package org.melati.example.contacts;
2   
3   import org.melati.poem.PoemTask;
4   import org.melati.example.contacts.generated.ContactsDatabaseBase;
5   
6   /**
7    * Melati POEM generated, programmer modifyable 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  
21          Contact adam =
22            getContactTable().ensure(
23              "Adam",
24              null,
25              "Eden");
26          getContactTable().ensure(
27              "Seth",
28              adam,
29              "Eden");
30          getContactTable().ensure(
31              "Abel",
32              adam,
33              "Eden");
34          Contact lamech =
35            getContactTable().ensure(
36              "Lamech",
37               getContactTable().ensure(
38                "Methusael",
39                getContactTable().ensure(
40                  "Mehujael",
41                  getContactTable().ensure(
42                    "Irad",
43                    getContactTable().ensure(
44                      "Enoch",
45                      getContactTable().ensure(
46                        "Cain",
47                        adam,
48                        "Nod"),
49                      "Enoch"),
50                    "Enoch"),
51                  "Enoch"),
52                "Enoch"),
53              "Enoch");
54          getContactTable().ensure(
55              "Adah",
56              lamech,
57              "Enoch");
58          getContactTable().ensure(
59              "Jabal",
60              lamech,
61              "Enoch");
62          getContactTable().ensure(
63              "Jubal",
64              lamech,
65              "Enoch");
66          getContactTable().ensure(
67              "Naamah",
68              lamech,
69              "Enoch");
70          getContactTable().ensure(
71              "Tubal-cain",
72              lamech,
73              "Enoch");
74          getContactTable().ensure(
75              "Zilla",
76              lamech,
77              "Enoch");
78  
79  
80  
81        }
82      });
83    }
84  }