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