View Javadoc

1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.paneris.bibliomania.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.JdbcPersistent;
14  import org.melati.poem.NoSuchRowPoemException;
15  import org.melati.poem.ValidationPoemException;
16  import org.melati.poem.util.EmptyEnumeration;
17  import org.paneris.bibliomania.BibliomaniaDatabaseTables;
18  import org.paneris.bibliomania.Country;
19  import org.paneris.bibliomania.CountryTable;
20  import org.paneris.bibliomania.DeliveryChargeBand;
21  import org.paneris.bibliomania.ShopOrder;
22  
23  
24  /**
25   * Melati POEM generated abstract base class for a <code>Persistent</code> 
26   * <code>Country</code> Object.
27   *
28   * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
29   */
30  public abstract class CountryBase extends JdbcPersistent {
31  
32  
33   /**
34    * Retrieves the Database object.
35    * 
36    * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
37    * @return the database
38    */
39    public BibliomaniaDatabaseTables getBibliomaniaDatabaseTables() {
40      return (BibliomaniaDatabaseTables)getDatabase();
41    }
42  
43  
44   /**
45    * Retrieves the  <code>CountryTable</code> table 
46    * which this <code>Persistent</code> is from.
47    * 
48    * see org.melati.poem.prepro.TableDef#generatePersistentBaseJava 
49    * @return the CountryTable
50    */
51    @SuppressWarnings("unchecked")
52    public CountryTable<Country> getCountryTable() {
53      return (CountryTable<Country>)getTable();
54    }
55  
56    @SuppressWarnings("unchecked")
57    private CountryTable<Country> _getCountryTable() {
58      return (CountryTable<Country>)getTable();
59    }
60  
61    // Fields in this table 
62   /**
63    * id 
64    */
65    protected Integer id;
66   /**
67    * Display name - The country's name 
68    */
69    protected String displayname;
70   /**
71    * Delivery Charge Band 
72    */
73    protected Integer deliverycharge;
74  
75  
76   /**
77    * Retrieves the <code>Id</code> value, without locking, 
78    * for this <code>Country</code> <code>Persistent</code>.
79    *
80    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
81    * @return the Integer id
82    */
83    public Integer getId_unsafe() {
84      return id;
85    }
86  
87  
88   /**
89    * Sets the <code>Id</code> value directly, without checking, 
90    * for this Country <code>Persistent</code>.
91    * 
92    * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
93    * @param cooked  the pre-validated value to set
94    */
95    public void setId_unsafe(Integer cooked) {
96      id = cooked;
97    }
98  
99   /**
100   * Retrieves the Id value, with locking, for this 
101   * <code>Country</code> <code>Persistent</code>.
102   * 
103   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
104   * @throws AccessPoemException 
105   *         if the current <code>AccessToken</code> 
106   *         does not confer write access rights 
107   * @return the value of the field <code>Id</code> for this 
108   *         <code>Country</code> <code>Persistent</code>  
109   */
110 
111   public Integer getId()
112       throws AccessPoemException {
113     readLock();
114     return getId_unsafe();
115   }
116 
117 
118  /**
119   * Sets the <code>Id</code> value, with checking, for this 
120   * <code>Country</code> <code>Persistent</code>.
121   * 
122   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
123   * @param cooked  a validated <code>int</code> 
124   * @throws AccessPoemException 
125   *         if the current <code>AccessToken</code> 
126   *         does not confer write access rights
127   * @throws ValidationPoemException 
128   *         if the value is not valid
129   */
130   public void setId(Integer cooked)
131       throws AccessPoemException, ValidationPoemException {
132     _getCountryTable().getIdColumn().
133       getType().assertValidCooked(cooked);
134     writeLock();
135     setId_unsafe(cooked);
136   }
137 
138  /**
139   * Sets the <code>Id</code> value, with checking, for this 
140   * <code>Country</code> <code>Persistent</code>.
141   * 
142   * Generated by org.melati.poem.prepro.IntegerFieldDef#generateBaseMethods 
143   * @param cooked  a validated <code>int</code>
144   * @throws AccessPoemException 
145   *         if the current <code>AccessToken</code> 
146   *         does not confer write access rights
147   * @throws ValidationPoemException 
148   *         if the value is not valid
149   */
150 
151   public final void setId(int cooked)
152       throws AccessPoemException, ValidationPoemException {
153     setId(new Integer(cooked));
154   }
155 
156 
157  /**
158   * Retrieves the <code>Id</code> value as a <code>Field</code>
159   * from this <code>Country</code> <code>Persistent</code>.
160   * 
161   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
162   * @throws AccessPoemException 
163   *         if the current <code>AccessToken</code> 
164   *         does not confer write access rights
165   * @return the Integer id
166   */
167   public Field<Integer> getIdField() throws AccessPoemException {
168     Column<Integer> c = _getCountryTable().getIdColumn();
169     return new Field<Integer>((Integer)c.getRaw(this), c);
170   }
171 
172 
173  /**
174   * Retrieves the <code>Displayname</code> value, without locking, 
175   * for this <code>Country</code> <code>Persistent</code>.
176   *
177   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
178   * @return the String displayname
179   */
180   public String getDisplayname_unsafe() {
181     return displayname;
182   }
183 
184 
185  /**
186   * Sets the <code>Displayname</code> value directly, without checking, 
187   * for this Country <code>Persistent</code>.
188   * 
189   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
190   * @param cooked  the pre-validated value to set
191   */
192   public void setDisplayname_unsafe(String cooked) {
193     displayname = cooked;
194   }
195 
196  /**
197   * Retrieves the Displayname value, with locking, for this 
198   * <code>Country</code> <code>Persistent</code>.
199   * Field description: 
200   *   The country's name 
201   * 
202   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods 
203   * @throws AccessPoemException 
204   *         if the current <code>AccessToken</code> 
205   *         does not confer write access rights 
206   * @return the value of the field <code>Displayname</code> for this 
207   *         <code>Country</code> <code>Persistent</code>  
208   */
209 
210   public String getDisplayname()
211       throws AccessPoemException {
212     readLock();
213     return getDisplayname_unsafe();
214   }
215 
216 
217  /**
218   * Sets the <code>Displayname</code> value, with checking, for this 
219   * <code>Country</code> <code>Persistent</code>.
220   * Field description: 
221   *   The country's name 
222   * 
223   * Generated by org.melati.poem.prepro.AtomFieldDef#generateBaseMethods  
224   * @param cooked  a validated <code>int</code> 
225   * @throws AccessPoemException 
226   *         if the current <code>AccessToken</code> 
227   *         does not confer write access rights
228   * @throws ValidationPoemException 
229   *         if the value is not valid
230   */
231   public void setDisplayname(String cooked)
232       throws AccessPoemException, ValidationPoemException {
233     _getCountryTable().getDisplaynameColumn().
234       getType().assertValidCooked(cooked);
235     writeLock();
236     setDisplayname_unsafe(cooked);
237   }
238 
239 
240  /**
241   * Retrieves the <code>Displayname</code> value as a <code>Field</code>
242   * from this <code>Country</code> <code>Persistent</code>.
243   * 
244   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
245   * @throws AccessPoemException 
246   *         if the current <code>AccessToken</code> 
247   *         does not confer write access rights
248   * @return the String displayname
249   */
250   public Field<String> getDisplaynameField() throws AccessPoemException {
251     Column<String> c = _getCountryTable().getDisplaynameColumn();
252     return new Field<String>((String)c.getRaw(this), c);
253   }
254 
255 
256  /**
257   * Retrieves the <code>Deliverycharge</code> value, without locking, 
258   * for this <code>Country</code> <code>Persistent</code>.
259   *
260   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
261   * @return the Integer deliverycharge
262   */
263   public Integer getDeliverycharge_unsafe() {
264     return deliverycharge;
265   }
266 
267 
268  /**
269   * Sets the <code>Deliverycharge</code> value directly, without checking, 
270   * for this Country <code>Persistent</code>.
271   * 
272   * see org.melati.poem.prepro.FieldDef#generateBaseMethods 
273   * @param cooked  the pre-validated value to set
274   */
275   public void setDeliverycharge_unsafe(Integer cooked) {
276     deliverycharge = cooked;
277   }
278 
279  /**
280   * Retrieves the Table Row Object ID. 
281   *
282   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
283   * @throws AccessPoemException  
284   *         if the current <code>AccessToken</code> 
285   *         does not confer read access rights 
286   * @return the TROID as an <code>Integer</code> 
287   */
288 
289   public Integer getDeliverychargeTroid()
290       throws AccessPoemException {
291     readLock();
292     return getDeliverycharge_unsafe();
293   }
294 
295 
296  /**
297   * Sets the Table Row Object ID. 
298   * 
299   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
300   * @param raw  a Table Row Object Id 
301   * @throws AccessPoemException  
302   *         if the current <code>AccessToken</code> 
303   *         does not confer write access rights
304   */
305   public void setDeliverychargeTroid(Integer raw)
306       throws AccessPoemException {
307     setDeliverycharge(raw == null ? null : 
308         getBibliomaniaDatabaseTables().getDeliveryChargeBandTable().getDeliveryChargeBandObject(raw));
309   }
310 
311 
312  /**
313   * Retrieves the <code>Deliverycharge</code> object referred to.
314   *  
315   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
316   * @throws AccessPoemException  
317   *         if the current <code>AccessToken</code> 
318   *         does not confer read access rights 
319   * @throws NoSuchRowPoemException  
320   *         if the <code>Persistent</code> has yet to be allocated a TROID 
321   * @return the <code>Deliverycharge</code> as a <code>DeliveryChargeBand</code> 
322   */
323   public DeliveryChargeBand getDeliverycharge()
324       throws AccessPoemException, NoSuchRowPoemException {
325     Integer troid = getDeliverychargeTroid();
326     return troid == null ? null :
327         getBibliomaniaDatabaseTables().getDeliveryChargeBandTable().getDeliveryChargeBandObject(troid);
328   }
329 
330 
331  /**
332   * Set the Deliverycharge.
333   * 
334   * Generated by org.melati.poem.prepro.ReferenceFieldDef#generateBaseMethods 
335   * @param cooked  a validated <code>DeliveryChargeBand</code>
336   * @throws AccessPoemException  
337   *         if the current <code>AccessToken</code> 
338   *         does not confer write access rights 
339   */
340   public void setDeliverycharge(DeliveryChargeBand cooked)
341       throws AccessPoemException {
342     _getCountryTable().
343       getDeliverychargeColumn().
344         getType().assertValidCooked(cooked);
345     writeLock();
346     if (cooked == null)
347       setDeliverycharge_unsafe(null);
348     else {
349       cooked.existenceLock();
350       setDeliverycharge_unsafe(cooked.troid());
351     }
352   }
353 
354 
355  /**
356   * Retrieves the <code>Deliverycharge</code> value as a <code>Field</code>
357   * from this <code>Country</code> <code>Persistent</code>.
358   * 
359   * see org.melati.poem.prepro.FieldDef#generateFieldCreator 
360   * @throws AccessPoemException 
361   *         if the current <code>AccessToken</code> 
362   *         does not confer write access rights
363   * @return the Integer deliverycharge
364   */
365   public Field<Integer> getDeliverychargeField() throws AccessPoemException {
366     Column<Integer> c = _getCountryTable().getDeliverychargeColumn();
367     return new Field<Integer>((Integer)c.getRaw(this), c);
368   }
369 
370   private CachedSelection<ShopOrder> countryShopOrders = null;
371   /** References to this Country in the ShopOrder table via its country field.*/
372   @SuppressWarnings("unchecked")
373   public Enumeration<ShopOrder> getCountryShopOrders() {
374     if (getTroid() == null)
375       return new EmptyEnumeration<ShopOrder>();
376     else {
377       if (countryShopOrders == null)
378         countryShopOrders =
379           getBibliomaniaDatabaseTables().getShopOrderTable().getCountryColumn().cachedSelectionWhereEq(getTroid());
380       return countryShopOrders.objects();
381     }
382   }
383 
384 
385   /** References to this Country in the ShopOrder table via its country field, as a List.*/
386   public List<ShopOrder> getCountryShopOrderList() {
387     return Collections.list(getCountryShopOrders());
388   }
389 
390 
391 
392 }
393