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.Parent;
9   import org.melati.admin.test.UploadedImage;
10  import org.melati.poem.AccessPoemException;
11  import org.melati.poem.Column;
12  import org.melati.poem.Database;
13  import org.melati.poem.DefinitionSource;
14  import org.melati.poem.DisplayLevel;
15  import org.melati.poem.Field;
16  import org.melati.poem.JdbcPersistent;
17  import org.melati.poem.Persistent;
18  import org.melati.poem.PoemException;
19  import org.melati.poem.ReferencePoemType;
20  import org.melati.poem.Searchability;
21  import org.melati.poem.StringPoemType;
22  import org.melati.poem.TroidPoemType;
23  import org.melati.poem.ValidationPoemException;
24  
25  
26  /**
27   * Melati POEM generated base class for <code>Table</code> <code>Parent</code>.
28   *
29   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
30   */
31  
32  public class ParentTableBase<T extends Parent> extends AdminTestTable<T> {
33  
34    private Column<Integer> col_id = null;
35    private Column<String> col_name = null;
36    private Column<Integer> col_image = null;
37  
38   /**
39    * Constructor. 
40    * 
41    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
42    * @param database          the POEM database we are using
43    * @param name              the name of this <code>Table</code>
44    * @param definitionSource  which definition is being used
45    * @throws PoemException    if anything goes wrong
46    */
47  
48    public ParentTableBase(
49        Database database, String name,
50        DefinitionSource definitionSource) throws PoemException {
51      super(database, name, definitionSource);
52    }
53  
54  
55   /**
56    * Get the database tables.
57    *
58    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
59    * @return the database tables
60    */
61    public AdminTestDatabaseTables getAdminTestDatabaseTables() {
62      return (AdminTestDatabaseTables)getDatabase();
63    }
64  
65  
66   /**
67    * Initialise this table by defining its columns.
68    *
69    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
70    */
71    public void init() throws PoemException {
72      super.init();
73      defineColumn(col_id =
74          new Column<Integer>(this, "id",
75                     new TroidPoemType(),
76                     DefinitionSource.dsd) { 
77            public Object getCooked(Persistent g)
78                throws AccessPoemException, PoemException {
79              return ((Parent)g).getId();
80            }
81  
82            public void setCooked(Persistent g, Object cooked)
83                throws AccessPoemException, ValidationPoemException {
84              ((Parent)g).setId((Integer)cooked);
85            }
86  
87            public Field<Integer> asField(Persistent g) {
88              return ((Parent)g).getIdField();
89            }
90  
91            public boolean defaultUserEditable() {
92              return false;
93            }
94  
95            public boolean defaultUserCreateable() {
96              return false;
97            }
98  
99            public DisplayLevel defaultDisplayLevel() {
100             return DisplayLevel.summary;
101           }
102 
103           public boolean defaultSortDescending() {
104             return true;
105           }
106 
107           public int defaultDisplayOrder() {
108             return 0;
109           }
110 
111           public Object getRaw_unsafe(Persistent g)
112               throws AccessPoemException {
113             return ((Parent)g).getId_unsafe();
114           }
115 
116           public void setRaw_unsafe(Persistent g, Object raw)
117               throws AccessPoemException {
118             ((Parent)g).setId_unsafe((Integer)raw);
119           }
120 
121           public Object getRaw(Persistent g)
122               throws AccessPoemException {
123             return ((Parent)g).getId();
124           }
125 
126           public void setRaw(Persistent g, Object raw)
127               throws AccessPoemException {
128             ((Parent)g).setId((Integer)raw);
129           }
130         });
131 
132     defineColumn(col_name =
133         new Column<String>(this, "name",
134                    new StringPoemType(false, -1),
135                    DefinitionSource.dsd) { 
136           public Object getCooked(Persistent g)
137               throws AccessPoemException, PoemException {
138             return ((Parent)g).getName();
139           }
140 
141           public void setCooked(Persistent g, Object cooked)
142               throws AccessPoemException, ValidationPoemException {
143             ((Parent)g).setName((String)cooked);
144           }
145 
146           public Field<String> asField(Persistent g) {
147             return ((Parent)g).getNameField();
148           }
149 
150           public DisplayLevel defaultDisplayLevel() {
151             return DisplayLevel.primary;
152           }
153 
154           public Searchability defaultSearchability() {
155             return Searchability.yes;
156           }
157 
158           public Integer defaultDisplayOrderPriority() {
159             return new Integer(0);
160           }
161 
162           public int defaultDisplayOrder() {
163             return 1;
164           }
165 
166           public String defaultDescription() {
167             return "The name";
168           }
169 
170           public int defaultWidth() {
171             return 40;
172           }
173 
174           public Object getRaw_unsafe(Persistent g)
175               throws AccessPoemException {
176             return ((Parent)g).getName_unsafe();
177           }
178 
179           public void setRaw_unsafe(Persistent g, Object raw)
180               throws AccessPoemException {
181             ((Parent)g).setName_unsafe((String)raw);
182           }
183 
184           public Object getRaw(Persistent g)
185               throws AccessPoemException {
186             return ((Parent)g).getName();
187           }
188 
189           public void setRaw(Persistent g, Object raw)
190               throws AccessPoemException {
191             ((Parent)g).setName((String)raw);
192           }
193         });
194 
195     defineColumn(col_image =
196         new Column<Integer>(this, "image",
197                    new ReferencePoemType(getAdminTestDatabaseTables().
198                                              getUploadedImageTable(), true),
199                    DefinitionSource.dsd) { 
200           public Object getCooked(Persistent g)
201               throws AccessPoemException, PoemException {
202             return ((Parent)g).getImage();
203           }
204 
205           public void setCooked(Persistent g, Object cooked)
206               throws AccessPoemException, ValidationPoemException {
207             ((Parent)g).setImage((UploadedImage)cooked);
208           }
209 
210           public Field<Integer> asField(Persistent g) {
211             return ((Parent)g).getImageField();
212           }
213 
214           public int defaultDisplayOrder() {
215             return 2;
216           }
217 
218           public String defaultDescription() {
219             return "The image";
220           }
221 
222           public Object getRaw_unsafe(Persistent g)
223               throws AccessPoemException {
224             return ((Parent)g).getImage_unsafe();
225           }
226 
227           public void setRaw_unsafe(Persistent g, Object raw)
228               throws AccessPoemException {
229             ((Parent)g).setImage_unsafe((Integer)raw);
230           }
231 
232           public Object getRaw(Persistent g)
233               throws AccessPoemException {
234             return ((Parent)g).getImageTroid();
235           }
236 
237           public void setRaw(Persistent g, Object raw)
238               throws AccessPoemException {
239             ((Parent)g).setImageTroid((Integer)raw);
240           }
241         });
242   }
243 
244 
245  /**
246   * Retrieves the <code>Id</code> <code>Column</code> for this 
247   * <code>Parent</code> <code>Table</code>.
248   * 
249   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
250   * @return the id <code>Column</code>
251   */
252   public final Column<Integer> getIdColumn() {
253     return col_id;
254   }
255 
256 
257  /**
258   * Retrieves the <code>Name</code> <code>Column</code> for this 
259   * <code>Parent</code> <code>Table</code>.
260   * 
261   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
262   * @return the name <code>Column</code>
263   */
264   public final Column<String> getNameColumn() {
265     return col_name;
266   }
267 
268 
269  /**
270   * Retrieves the <code>Image</code> <code>Column</code> for this 
271   * <code>Parent</code> <code>Table</code>.
272   * 
273   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
274   * @return the image <code>Column</code>
275   */
276   public final Column<Integer> getImageColumn() {
277     return col_image;
278   }
279 
280 
281  /**
282   * Retrieve the <code>Parent</code> as a <code>Parent</code>.
283   *
284   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
285   * @param troid a Table Row Object ID
286   * @return the <code>Persistent</code> identified by the <code>troid</code>
287   */
288   public Parent getParentObject(Integer troid) {
289     return (Parent)getObject(troid);
290   }
291 
292 
293  /**
294   * Retrieve the <code>Parent</code> 
295   * as a <code>Parent</code>.
296   *
297   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
298   * @param troid a Table Row Object ID
299   * @return the <code>Persistent</code> identified   */
300   public Parent getParentObject(int troid) {
301     return (Parent)getObject(troid);
302   }
303 
304   protected JdbcPersistent _newPersistent() {
305     return new Parent();
306   }
307   public String defaultDescription() {
308     return "A node with zero or more children";
309   }
310 
311   public boolean defaultRememberAllTroids() {
312     return true;
313   }
314 
315   public Integer defaultCacheLimit() {
316     return new Integer(999999999);
317   }
318 
319   public String defaultCategory() {
320     return "Data";
321   }
322 
323   public int defaultDisplayOrder() {
324     return 2;
325   }
326 }
327