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