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