View Javadoc
1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.admin.test.generated;
4   
5   
6   import java.util.Collections;
7   import java.util.Enumeration;
8   import java.util.List;
9   import org.melati.admin.test.AdminTestDatabaseTables;
10  // ours
11  //import org.melati.admin.test.User;
12  // ours
13  //import org.melati.admin.test.UserTable;
14  import org.melati.poem.AccessPoemException;
15  import org.melati.poem.CachedSelection;
16  import org.melati.poem.Column;
17  import org.melati.poem.Field;
18  import org.melati.poem.GroupMembership;
19  // base extension
20  import org.melati.poem.User;
21  import org.melati.poem.ValidationPoemException;
22  import org.melati.poem.util.EmptyEnumeration;
23  
24  
25  /**
26   * Melati POEM generated abstract base class for a <code>Persistent</code> 
27   * <code>User</code> Object.
28   *
29   * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
30   */
31  public abstract class UserBase extends org.melati.poem.User {
32  
33  
34   /**
35    * Retrieves the Database object.
36    * 
37    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
38    * @return the database
39    */
40    public AdminTestDatabaseTables getAdminTestDatabaseTables() {
41      return (AdminTestDatabaseTables)getDatabase();
42    }
43  
44  
45   /**
46    * Retrieves the  <code>UserTable</code> table 
47    * which this <code>Persistent</code> is from.
48    * 
49    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
50    * @return the org.melati.poem.UserTable
51    */
52    @SuppressWarnings("unchecked")
53    public org.melati.poem.UserTable<org.melati.poem.User> getUserTable() {
54      return (org.melati.poem.UserTable<org.melati.poem.User>)getTable();
55    }
56  
57    @SuppressWarnings("unchecked")
58    private org.melati.admin.test.UserTable<org.melati.admin.test.User> _getUserTable() {
59      return (org.melati.admin.test.UserTable<org.melati.admin.test.User>)getTable();
60    }
61  
62    // Fields in this table 
63   /**
64    * email - The user's email address 
65    */
66    protected String email;
67  
68  
69   /**
70    * Retrieves the <code>Email</code> value, without locking, 
71    * for this <code>User</code> <code>Persistent</code>.
72    *
73    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
74    * @return the String email
75    */
76    public String getEmail_unsafe() {
77      return email;
78    }
79  
80  
81   /**
82    * Sets the <code>Email</code> value directly, without checking, 
83    * for this User <code>Persistent</code>.
84    * 
85    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
86    * @param cooked  the pre-validated value to set
87    */
88    public void setEmail_unsafe(String cooked) {
89      email = cooked;
90    }
91  
92   /**
93    * Retrieves the Email value, with locking, for this 
94    * <code>User</code> <code>Persistent</code>.
95    * Field description: 
96    *   The user's email address 
97    * 
98    * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
99    * @throws AccessPoemException 
100   *         if the current <code>AccessToken</code> 
101   *         does not confer write access rights 
102   * @return the value of the field <code>Email</code> for this 
103   *         <code>User</code> <code>Persistent</code>  
104   */
105 
106   public String getEmail()
107       throws AccessPoemException {
108     readLock();
109     return getEmail_unsafe();
110   }
111 
112 
113  /**
114   * Sets the <code>Email</code> value, with checking, for this 
115   * <code>User</code> <code>Persistent</code>.
116   * Field description: 
117   *   The user's email address 
118   * 
119   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
120   * @param cooked  a validated <code>int</code> 
121   * @throws AccessPoemException 
122   *         if the current <code>AccessToken</code> 
123   *         does not confer write access rights
124   * @throws ValidationPoemException 
125   *         if the value is not valid
126   */
127   public void setEmail(String cooked)
128       throws AccessPoemException, ValidationPoemException {
129     _getUserTable().getEmailColumn().
130       getType().assertValidCooked(cooked);
131     writeLock();
132     setEmail_unsafe(cooked);
133   }
134 
135 
136  /**
137   * Retrieves the <code>Email</code> value as a <code>Field</code>
138   * from this <code>User</code> <code>Persistent</code>.
139   * 
140   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
141   * @throws AccessPoemException 
142   *         if the current <code>AccessToken</code> 
143   *         does not confer write access rights
144   * @return the String email
145   */
146   public Field<String> getEmailField() throws AccessPoemException {
147     Column<String> c = _getUserTable().getEmailColumn();
148     return new Field<String>((String)c.getRaw(this), c);
149   }
150 
151   private CachedSelection<GroupMembership> userGroupMemberships = null;
152   /** References to this User in the GroupMembership table via its user field.*/
153   @SuppressWarnings("unchecked")
154   public Enumeration<GroupMembership> getUserGroupMemberships() {
155     if (getTroid() == null)
156       return new EmptyEnumeration<GroupMembership>();
157     else {
158       if (userGroupMemberships == null)
159         userGroupMemberships =
160           getAdminTestDatabaseTables().getGroupMembershipTable().getUserColumn().cachedSelectionWhereEq(getTroid());
161       return userGroupMemberships.objects();
162     }
163   }
164 
165 
166   /** References to this User in the GroupMembership table via its user field, as a List.*/
167   public List<GroupMembership> getUserGroupMembershipList() {
168     return Collections.list(getUserGroupMemberships());
169   }
170 
171 
172 
173 }
174