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 org.melati.admin.test.AdminTestDatabaseTables;
7   import org.melati.admin.test.AdminTestTable;
8   import org.melati.admin.test.Child;
9   import org.melati.admin.test.Parent;
10  import org.melati.admin.test.UploadedImage;
11  import org.melati.poem.AccessPoemException;
12  import org.melati.poem.Column;
13  import org.melati.poem.Database;
14  import org.melati.poem.DefinitionSource;
15  import org.melati.poem.DeletedPoemType;
16  import org.melati.poem.DisplayLevel;
17  import org.melati.poem.Field;
18  import org.melati.poem.JdbcPersistent;
19  import org.melati.poem.Persistent;
20  import org.melati.poem.PoemException;
21  import org.melati.poem.ReferencePoemType;
22  import org.melati.poem.Searchability;
23  import org.melati.poem.StringPoemType;
24  import org.melati.poem.TroidPoemType;
25  import org.melati.poem.ValidationPoemException;
26  
27  
28  /**
29   * Melati POEM generated base class for <code>Table</code> <code>Child</code>.
30   *
31   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
32   */
33  
34  public class ChildTableBase<T extends Child> extends AdminTestTable<T> {
35  
36    private Column<Integer> col_id = null;
37    private Column<Integer> col_parent = null;
38    private Column<String> col_name = null;
39    private Column<Integer> col_image = null;
40    private Column<Boolean> col_deleted = null;
41  
42   /**
43    * Constructor. 
44    * 
45    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
46    * @param database          the POEM database we are using
47    * @param name              the name of this <code>Table</code>
48    * @param definitionSource  which definition is being used
49    * @throws PoemException    if anything goes wrong
50    */
51  
52    public ChildTableBase(
53        Database database, String name,
54        DefinitionSource definitionSource) throws PoemException {
55      super(database, name, definitionSource);
56    }
57  
58  
59   /**
60    * Get the database tables.
61    *
62    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
63    * @return the database tables
64    */
65    public AdminTestDatabaseTables getAdminTestDatabaseTables() {
66      return (AdminTestDatabaseTables)getDatabase();
67    }
68  
69  
70   /**
71    * Initialise this table by defining its columns.
72    *
73    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
74    */
75    public void init() throws PoemException {
76      super.init();
77      defineColumn(col_id =
78          new Column<Integer>(this, "id",
79                     new TroidPoemType(),
80                     DefinitionSource.dsd) { 
81            public Object getCooked(Persistent g)
82                throws AccessPoemException, PoemException {
83              return ((Child)g).getId();
84            }
85  
86            public void setCooked(Persistent g, Object cooked)
87                throws AccessPoemException, ValidationPoemException {
88              ((Child)g).setId((Integer)cooked);
89            }
90  
91            public Field<Integer> asField(Persistent g) {
92              return ((Child)g).getIdField();
93            }
94  
95            public boolean defaultUserEditable() {
96              return false;
97            }
98  
99            public boolean defaultUserCreateable() {
100             return false;
101           }
102 
103           public DisplayLevel defaultDisplayLevel() {
104             return DisplayLevel.summary;
105           }
106 
107           public int defaultDisplayOrder() {
108             return 0;
109           }
110 
111           public Object getRaw_unsafe(Persistent g)
112               throws AccessPoemException {
113             return ((Child)g).getId_unsafe();
114           }
115 
116           public void setRaw_unsafe(Persistent g, Object raw)
117               throws AccessPoemException {
118             ((Child)g).setId_unsafe((Integer)raw);
119           }
120 
121           public Object getRaw(Persistent g)
122               throws AccessPoemException {
123             return ((Child)g).getId();
124           }
125 
126           public void setRaw(Persistent g, Object raw)
127               throws AccessPoemException {
128             ((Child)g).setId((Integer)raw);
129           }
130         });
131 
132     defineColumn(col_parent =
133         new Column<Integer>(this, "parent",
134                    new ReferencePoemType(getAdminTestDatabaseTables().
135                                              getParentTable(), false),
136                    DefinitionSource.dsd) { 
137           public Object getCooked(Persistent g)
138               throws AccessPoemException, PoemException {
139             return ((Child)g).getParent();
140           }
141 
142           public void setCooked(Persistent g, Object cooked)
143               throws AccessPoemException, ValidationPoemException {
144             ((Child)g).setParent((Parent)cooked);
145           }
146 
147           public Field<Integer> asField(Persistent g) {
148             return ((Child)g).getParentField();
149           }
150 
151           public int defaultDisplayOrder() {
152             return 1;
153           }
154 
155           public String defaultDescription() {
156             return "The parent";
157           }
158 
159           public Object getRaw_unsafe(Persistent g)
160               throws AccessPoemException {
161             return ((Child)g).getParent_unsafe();
162           }
163 
164           public void setRaw_unsafe(Persistent g, Object raw)
165               throws AccessPoemException {
166             ((Child)g).setParent_unsafe((Integer)raw);
167           }
168 
169           public Object getRaw(Persistent g)
170               throws AccessPoemException {
171             return ((Child)g).getParentTroid();
172           }
173 
174           public void setRaw(Persistent g, Object raw)
175               throws AccessPoemException {
176             ((Child)g).setParentTroid((Integer)raw);
177           }
178         });
179 
180     defineColumn(col_name =
181         new Column<String>(this, "name",
182                    new StringPoemType(false, -1),
183                    DefinitionSource.dsd) { 
184           public Object getCooked(Persistent g)
185               throws AccessPoemException, PoemException {
186             return ((Child)g).getName();
187           }
188 
189           public void setCooked(Persistent g, Object cooked)
190               throws AccessPoemException, ValidationPoemException {
191             ((Child)g).setName((String)cooked);
192           }
193 
194           public Field<String> asField(Persistent g) {
195             return ((Child)g).getNameField();
196           }
197 
198           public DisplayLevel defaultDisplayLevel() {
199             return DisplayLevel.primary;
200           }
201 
202           public Searchability defaultSearchability() {
203             return Searchability.yes;
204           }
205 
206           public Integer defaultDisplayOrderPriority() {
207             return new Integer(0);
208           }
209 
210           public int defaultDisplayOrder() {
211             return 2;
212           }
213 
214           public String defaultDescription() {
215             return "The name";
216           }
217 
218           public int defaultWidth() {
219             return 40;
220           }
221 
222           public Object getRaw_unsafe(Persistent g)
223               throws AccessPoemException {
224             return ((Child)g).getName_unsafe();
225           }
226 
227           public void setRaw_unsafe(Persistent g, Object raw)
228               throws AccessPoemException {
229             ((Child)g).setName_unsafe((String)raw);
230           }
231 
232           public Object getRaw(Persistent g)
233               throws AccessPoemException {
234             return ((Child)g).getName();
235           }
236 
237           public void setRaw(Persistent g, Object raw)
238               throws AccessPoemException {
239             ((Child)g).setName((String)raw);
240           }
241         });
242 
243     defineColumn(col_image =
244         new Column<Integer>(this, "image",
245                    new ReferencePoemType(getAdminTestDatabaseTables().
246                                              getUploadedImageTable(), true),
247                    DefinitionSource.dsd) { 
248           public Object getCooked(Persistent g)
249               throws AccessPoemException, PoemException {
250             return ((Child)g).getImage();
251           }
252 
253           public void setCooked(Persistent g, Object cooked)
254               throws AccessPoemException, ValidationPoemException {
255             ((Child)g).setImage((UploadedImage)cooked);
256           }
257 
258           public Field<Integer> asField(Persistent g) {
259             return ((Child)g).getImageField();
260           }
261 
262           public int defaultDisplayOrder() {
263             return 3;
264           }
265 
266           public String defaultDescription() {
267             return "The image";
268           }
269 
270           public Object getRaw_unsafe(Persistent g)
271               throws AccessPoemException {
272             return ((Child)g).getImage_unsafe();
273           }
274 
275           public void setRaw_unsafe(Persistent g, Object raw)
276               throws AccessPoemException {
277             ((Child)g).setImage_unsafe((Integer)raw);
278           }
279 
280           public Object getRaw(Persistent g)
281               throws AccessPoemException {
282             return ((Child)g).getImageTroid();
283           }
284 
285           public void setRaw(Persistent g, Object raw)
286               throws AccessPoemException {
287             ((Child)g).setImageTroid((Integer)raw);
288           }
289         });
290 
291     defineColumn(col_deleted =
292         new Column<Boolean>(this, "deleted",
293                    new DeletedPoemType(),
294                    DefinitionSource.dsd) { 
295           public Object getCooked(Persistent g)
296               throws AccessPoemException, PoemException {
297             return ((Child)g).getDeleted();
298           }
299 
300           public void setCooked(Persistent g, Object cooked)
301               throws AccessPoemException, ValidationPoemException {
302             ((Child)g).setDeleted((Boolean)cooked);
303           }
304 
305           public Field<Boolean> asField(Persistent g) {
306             return ((Child)g).getDeletedField();
307           }
308 
309           public DisplayLevel defaultDisplayLevel() {
310             return DisplayLevel.record;
311           }
312 
313           public Searchability defaultSearchability() {
314             return Searchability.no;
315           }
316 
317           public int defaultDisplayOrder() {
318             return 4;
319           }
320 
321           public String defaultDescription() {
322             return "Whether deleted";
323           }
324 
325           public boolean defaultIndexed() {
326             return true;
327           }
328 
329           public Object getRaw_unsafe(Persistent g)
330               throws AccessPoemException {
331             return ((Child)g).getDeleted_unsafe();
332           }
333 
334           public void setRaw_unsafe(Persistent g, Object raw)
335               throws AccessPoemException {
336             ((Child)g).setDeleted_unsafe((Boolean)raw);
337           }
338 
339           public Object getRaw(Persistent g)
340               throws AccessPoemException {
341             return ((Child)g).getDeleted();
342           }
343 
344           public void setRaw(Persistent g, Object raw)
345               throws AccessPoemException {
346             ((Child)g).setDeleted((Boolean)raw);
347           }
348         });
349   }
350 
351 
352  /**
353   * Retrieves the <code>Id</code> <code>Column</code> for this 
354   * <code>Child</code> <code>Table</code>.
355   * 
356   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
357   * @return the id <code>Column</code>
358   */
359   public final Column<Integer> getIdColumn() {
360     return col_id;
361   }
362 
363 
364  /**
365   * Retrieves the <code>Parent</code> <code>Column</code> for this 
366   * <code>Child</code> <code>Table</code>.
367   * 
368   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
369   * @return the parent <code>Column</code>
370   */
371   public final Column<Integer> getParentColumn() {
372     return col_parent;
373   }
374 
375 
376  /**
377   * Retrieves the <code>Name</code> <code>Column</code> for this 
378   * <code>Child</code> <code>Table</code>.
379   * 
380   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
381   * @return the name <code>Column</code>
382   */
383   public final Column<String> getNameColumn() {
384     return col_name;
385   }
386 
387 
388  /**
389   * Retrieves the <code>Image</code> <code>Column</code> for this 
390   * <code>Child</code> <code>Table</code>.
391   * 
392   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
393   * @return the image <code>Column</code>
394   */
395   public final Column<Integer> getImageColumn() {
396     return col_image;
397   }
398 
399 
400  /**
401   * Retrieves the <code>Deleted</code> <code>Column</code> for this 
402   * <code>Child</code> <code>Table</code>.
403   * 
404   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
405   * @return the deleted <code>Column</code>
406   */
407   public final Column<Boolean> getDeletedColumn() {
408     return col_deleted;
409   }
410 
411 
412  /**
413   * Retrieve the <code>Child</code> as a <code>Child</code>.
414   *
415   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
416   * @param troid a Table Row Object ID
417   * @return the <code>Persistent</code> identified by the <code>troid</code>
418   */
419   public Child getChildObject(Integer troid) {
420     return (Child)getObject(troid);
421   }
422 
423 
424  /**
425   * Retrieve the <code>Child</code> 
426   * as a <code>Child</code>.
427   *
428   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
429   * @param troid a Table Row Object ID
430   * @return the <code>Persistent</code> identified   */
431   public Child getChildObject(int troid) {
432     return (Child)getObject(troid);
433   }
434 
435   protected JdbcPersistent _newPersistent() {
436     return new Child();
437   }
438   public String defaultDescription() {
439     return "A node with a parent";
440   }
441 
442   public String defaultCategory() {
443     return "Data";
444   }
445 
446   public int defaultDisplayOrder() {
447     return 3;
448   }
449 }
450