View Javadoc
1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.example.odmg.generated;
4   
5   
6   import java.util.Collections;
7   import java.util.Enumeration;
8   import java.util.List;
9   import org.melati.example.odmg.Child;
10  import org.melati.example.odmg.OdmgDatabaseTables;
11  import org.melati.example.odmg.Parent;
12  import org.melati.example.odmg.ParentTable;
13  import org.melati.poem.AccessPoemException;
14  import org.melati.poem.CachedSelection;
15  import org.melati.poem.Column;
16  import org.melati.poem.Field;
17  import org.melati.poem.JdbcPersistent;
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>Parent</code> Object.
25   *
26   * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
27   */
28  public abstract class ParentBase extends JdbcPersistent {
29  
30  
31   /**
32    * Retrieves the Database object.
33    * 
34    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
35    * @return the database
36    */
37    public OdmgDatabaseTables getOdmgDatabaseTables() {
38      return (OdmgDatabaseTables)getDatabase();
39    }
40  
41  
42   /**
43    * Retrieves the  <code>ParentTable</code> table 
44    * which this <code>Persistent</code> is from.
45    * 
46    * See org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
47    * @return the ParentTable
48    */
49    @SuppressWarnings("unchecked")
50    public ParentTable<Parent> getParentTable() {
51      return (ParentTable<Parent>)getTable();
52    }
53  
54    @SuppressWarnings("unchecked")
55    private ParentTable<Parent> _getParentTable() {
56      return (ParentTable<Parent>)getTable();
57    }
58  
59    // Fields in this table 
60   /**
61    * id 
62    */
63    protected Integer id;
64   /**
65    * name 
66    */
67    protected String name;
68  
69  
70   /**
71    * Retrieves the <code>Id</code> value, without locking, 
72    * for this <code>Parent</code> <code>Persistent</code>.
73    *
74    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
75    * @return the Integer id
76    */
77    public Integer getId_unsafe() {
78      return id;
79    }
80  
81  
82   /**
83    * Sets the <code>Id</code> value directly, without checking, 
84    * for this Parent <code>Persistent</code>.
85    * 
86    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
87    * @param cooked  the pre-validated value to set
88    */
89    public void setId_unsafe(Integer cooked) {
90      id = cooked;
91    }
92  
93   /**
94    * Retrieves the Id value, with locking, for this 
95    * <code>Parent</code> <code>Persistent</code>.
96    * 
97    * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
98    * @throws AccessPoemException 
99    *         if the current <code>AccessToken</code> 
100   *         does not confer write access rights 
101   * @return the value of the field <code>Id</code> for this 
102   *         <code>Parent</code> <code>Persistent</code>  
103   */
104 
105   public Integer getId()
106       throws AccessPoemException {
107     readLock();
108     return getId_unsafe();
109   }
110 
111 
112  /**
113   * Sets the <code>Id</code> value, with checking, for this 
114   * <code>Parent</code> <code>Persistent</code>.
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 setId(Integer cooked)
125       throws AccessPoemException, ValidationPoemException {
126     _getParentTable().getIdColumn().
127       getType().assertValidCooked(cooked);
128     writeLock();
129     setId_unsafe(cooked);
130   }
131 
132  /**
133   * Sets the <code>Id</code> value, with checking, for this 
134   * <code>Parent</code> <code>Persistent</code>.
135   * 
136   * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods 
137   * @param cooked  a validated <code>int</code>
138   * @throws AccessPoemException 
139   *         if the current <code>AccessToken</code> 
140   *         does not confer write access rights
141   * @throws ValidationPoemException 
142   *         if the value is not valid
143   */
144 
145   public final void setId(int cooked)
146       throws AccessPoemException, ValidationPoemException {
147     setId(new Integer(cooked));
148   }
149 
150 
151  /**
152   * Retrieves the <code>Id</code> value as a <code>Field</code>
153   * from this <code>Parent</code> <code>Persistent</code>.
154   * 
155   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
156   * @throws AccessPoemException 
157   *         if the current <code>AccessToken</code> 
158   *         does not confer write access rights
159   * @return the Integer id
160   */
161   public Field<Integer> getIdField() throws AccessPoemException {
162     Column<Integer> c = _getParentTable().getIdColumn();
163     return new Field<Integer>((Integer)c.getRaw(this), c);
164   }
165 
166 
167  /**
168   * Retrieves the <code>Name</code> value, without locking, 
169   * for this <code>Parent</code> <code>Persistent</code>.
170   *
171   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
172   * @return the String name
173   */
174   public String getName_unsafe() {
175     return name;
176   }
177 
178 
179  /**
180   * Sets the <code>Name</code> value directly, without checking, 
181   * for this Parent <code>Persistent</code>.
182   * 
183   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
184   * @param cooked  the pre-validated value to set
185   */
186   public void setName_unsafe(String cooked) {
187     name = cooked;
188   }
189 
190  /**
191   * Retrieves the Name value, with locking, for this 
192   * <code>Parent</code> <code>Persistent</code>.
193   * 
194   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
195   * @throws AccessPoemException 
196   *         if the current <code>AccessToken</code> 
197   *         does not confer write access rights 
198   * @return the value of the field <code>Name</code> for this 
199   *         <code>Parent</code> <code>Persistent</code>  
200   */
201 
202   public String getName()
203       throws AccessPoemException {
204     readLock();
205     return getName_unsafe();
206   }
207 
208 
209  /**
210   * Sets the <code>Name</code> value, with checking, for this 
211   * <code>Parent</code> <code>Persistent</code>.
212   * 
213   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
214   * @param cooked  a validated <code>int</code> 
215   * @throws AccessPoemException 
216   *         if the current <code>AccessToken</code> 
217   *         does not confer write access rights
218   * @throws ValidationPoemException 
219   *         if the value is not valid
220   */
221   public void setName(String cooked)
222       throws AccessPoemException, ValidationPoemException {
223     _getParentTable().getNameColumn().
224       getType().assertValidCooked(cooked);
225     writeLock();
226     setName_unsafe(cooked);
227   }
228 
229 
230  /**
231   * Retrieves the <code>Name</code> value as a <code>Field</code>
232   * from this <code>Parent</code> <code>Persistent</code>.
233   * 
234   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
235   * @throws AccessPoemException 
236   *         if the current <code>AccessToken</code> 
237   *         does not confer write access rights
238   * @return the String name
239   */
240   public Field<String> getNameField() throws AccessPoemException {
241     Column<String> c = _getParentTable().getNameColumn();
242     return new Field<String>((String)c.getRaw(this), c);
243   }
244 
245   private CachedSelection<Child> parentChilds = null;
246   /** References to this Parent in the Child table via its parent field.*/
247   @SuppressWarnings("unchecked")
248   public Enumeration<Child> getParentChilds() {
249     if (getTroid() == null)
250       return new EmptyEnumeration<Child>();
251     else {
252       if (parentChilds == null)
253         parentChilds =
254           getOdmgDatabaseTables().getChildTable().getParentColumn().cachedSelectionWhereEq(getTroid());
255       return parentChilds.objects();
256     }
257   }
258 
259 
260   /** References to this Parent in the Child table via its parent field, as a List.*/
261   public List<Child> getParentChildList() {
262     return Collections.list(getParentChilds());
263   }
264 
265 
266 
267 }
268