View Javadoc
1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.poem.test.generated;
4   
5   
6   import org.melati.poem.AccessPoemException;
7   import org.melati.poem.Column;
8   import org.melati.poem.Database;
9   import org.melati.poem.DefinitionSource;
10  import org.melati.poem.DisplayLevel;
11  import org.melati.poem.Field;
12  import org.melati.poem.JdbcPersistent;
13  import org.melati.poem.Persistent;
14  import org.melati.poem.PoemException;
15  import org.melati.poem.ReferencePoemType;
16  import org.melati.poem.Searchability;
17  import org.melati.poem.StringKeyReferencePoemType;
18  import org.melati.poem.StringPoemType;
19  import org.melati.poem.TroidPoemType;
20  import org.melati.poem.ValidationPoemException;
21  import org.melati.poem.test.Account;
22  import org.melati.poem.test.EverythingDatabaseTables;
23  import org.melati.poem.test.EverythingTable;
24  // Extended table 
25  import org.melati.poem.test.User;
26  
27  
28  /**
29   * Melati POEM generated base class for <code>Table</code> <code>Account</code>.
30   *
31   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
32   */
33  
34  public class AccountTableBase<T extends Account> extends EverythingTable<T> {
35  
36    private Column<Integer> col_id = null;
37    private Column<Integer> col_user = null;
38    private Column<String> col_emailAddress = null;
39    private Column<String> col_name = null;
40  
41   /**
42    * Constructor. 
43    * 
44    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
45    * @param database          the POEM database we are using
46    * @param name              the name of this <code>Table</code>
47    * @param definitionSource  which definition is being used
48    * @throws PoemException    if anything goes wrong
49    */
50  
51    public AccountTableBase(
52        Database database, String name,
53        DefinitionSource definitionSource) throws PoemException {
54      super(database, name, definitionSource);
55    }
56  
57  
58   /**
59    * Get the database tables.
60    *
61    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
62    * @return the database tables
63    */
64    public EverythingDatabaseTables getEverythingDatabaseTables() {
65      return (EverythingDatabaseTables)getDatabase();
66    }
67  
68  
69   /**
70    * Initialise this table by defining its columns.
71    *
72    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
73    */
74    public void init() throws PoemException {
75      super.init();
76      defineColumn(col_id =
77          new Column<Integer>(this, "id",
78                     new TroidPoemType(),
79                     DefinitionSource.dsd) { 
80            public Object getCooked(Persistent g)
81                throws AccessPoemException, PoemException {
82              return ((Account)g).getId();
83            }
84  
85            public void setCooked(Persistent g, Object cooked)
86                throws AccessPoemException, ValidationPoemException {
87              ((Account)g).setId((Integer)cooked);
88            }
89  
90            public Field<Integer> asField(Persistent g) {
91              return ((Account)g).getIdField();
92            }
93  
94            public boolean defaultUserEditable() {
95              return false;
96            }
97  
98            public boolean defaultUserCreateable() {
99              return false;
100           }
101 
102           public DisplayLevel defaultDisplayLevel() {
103             return DisplayLevel.record;
104           }
105 
106           public Searchability defaultSearchability() {
107             return Searchability.no;
108           }
109 
110           public int defaultDisplayOrder() {
111             return 0;
112           }
113 
114           public Object getRaw_unsafe(Persistent g)
115               throws AccessPoemException {
116             return ((Account)g).getId_unsafe();
117           }
118 
119           public void setRaw_unsafe(Persistent g, Object raw)
120               throws AccessPoemException {
121             ((Account)g).setId_unsafe((Integer)raw);
122           }
123 
124           public Object getRaw(Persistent g)
125               throws AccessPoemException {
126             return ((Account)g).getId();
127           }
128 
129           public void setRaw(Persistent g, Object raw)
130               throws AccessPoemException {
131             ((Account)g).setId((Integer)raw);
132           }
133         });
134 
135     defineColumn(col_user =
136         new Column<Integer>(this, "user",
137                    new ReferencePoemType(getEverythingDatabaseTables().
138                                              getUserTable(), false),
139                    DefinitionSource.dsd) { 
140           public Object getCooked(Persistent g)
141               throws AccessPoemException, PoemException {
142             return ((Account)g).getUser();
143           }
144 
145           public void setCooked(Persistent g, Object cooked)
146               throws AccessPoemException, ValidationPoemException {
147             ((Account)g).setUser((User)cooked);
148           }
149 
150           public Field<Integer> asField(Persistent g) {
151             return ((Account)g).getUserField();
152           }
153 
154           public DisplayLevel defaultDisplayLevel() {
155             return DisplayLevel.summary;
156           }
157 
158           public Searchability defaultSearchability() {
159             return Searchability.yes;
160           }
161 
162           public int defaultDisplayOrder() {
163             return 60;
164           }
165 
166           public String defaultDescription() {
167             return "The owner";
168           }
169 
170           public Object getRaw_unsafe(Persistent g)
171               throws AccessPoemException {
172             return ((Account)g).getUser_unsafe();
173           }
174 
175           public void setRaw_unsafe(Persistent g, Object raw)
176               throws AccessPoemException {
177             ((Account)g).setUser_unsafe((Integer)raw);
178           }
179 
180           public Object getRaw(Persistent g)
181               throws AccessPoemException {
182             return ((Account)g).getUserTroid();
183           }
184 
185           public void setRaw(Persistent g, Object raw)
186               throws AccessPoemException {
187             ((Account)g).setUserTroid((Integer)raw);
188           }
189         });
190 
191     defineColumn(col_emailAddress =
192         new Column<String>(this, "emailAddress",
193                    new StringKeyReferencePoemType(getEverythingDatabaseTables().
194                                              getEverythingUserTable(), "email", false, -1),
195                    DefinitionSource.dsd) { 
196           public Object getCooked(Persistent g)
197               throws AccessPoemException, PoemException {
198             return ((Account)g).getEmailAddress();
199           }
200 
201           public void setCooked(Persistent g, Object cooked)
202               throws AccessPoemException, ValidationPoemException {
203             ((Account)g).setEmailAddress((User)cooked);
204           }
205 
206           public Field<String> asField(Persistent g) {
207             return ((Account)g).getEmailAddressField();
208           }
209 
210           public DisplayLevel defaultDisplayLevel() {
211             return DisplayLevel.summary;
212           }
213 
214           public Searchability defaultSearchability() {
215             return Searchability.yes;
216           }
217 
218           public int defaultDisplayOrder() {
219             return 50;
220           }
221 
222           public String defaultDescription() {
223             return "The owner's email address";
224           }
225 
226           public int defaultWidth() {
227             return 40;
228           }
229 
230           public Object getRaw_unsafe(Persistent g)
231               throws AccessPoemException {
232             return ((Account)g).getEmailAddress_unsafe();
233           }
234 
235           public void setRaw_unsafe(Persistent g, Object raw)
236               throws AccessPoemException {
237             ((Account)g).setEmailAddress_unsafe((String)raw);
238           }
239 
240           public Object getRaw(Persistent g)
241               throws AccessPoemException {
242             return ((Account)g).getEmailAddress();
243           }
244 
245           public void setRaw(Persistent g, Object raw)
246               throws AccessPoemException {
247             ((Account)g).setEmailAddress((String)raw);
248           }
249         });
250 
251     defineColumn(col_name =
252         new Column<String>(this, "name",
253                    new StringPoemType(true, -1),
254                    DefinitionSource.dsd) { 
255           public Object getCooked(Persistent g)
256               throws AccessPoemException, PoemException {
257             return ((Account)g).getName();
258           }
259 
260           public void setCooked(Persistent g, Object cooked)
261               throws AccessPoemException, ValidationPoemException {
262             ((Account)g).setName((String)cooked);
263           }
264 
265           public Field<String> asField(Persistent g) {
266             return ((Account)g).getNameField();
267           }
268 
269           public DisplayLevel defaultDisplayLevel() {
270             return DisplayLevel.summary;
271           }
272 
273           public Searchability defaultSearchability() {
274             return Searchability.yes;
275           }
276 
277           public int defaultDisplayOrder() {
278             return 150;
279           }
280 
281           public String defaultDescription() {
282             return "The user's name";
283           }
284 
285           public int defaultWidth() {
286             return 40;
287           }
288 
289           public Object getRaw_unsafe(Persistent g)
290               throws AccessPoemException {
291             return ((Account)g).getName_unsafe();
292           }
293 
294           public void setRaw_unsafe(Persistent g, Object raw)
295               throws AccessPoemException {
296             ((Account)g).setName_unsafe((String)raw);
297           }
298 
299           public Object getRaw(Persistent g)
300               throws AccessPoemException {
301             return ((Account)g).getName();
302           }
303 
304           public void setRaw(Persistent g, Object raw)
305               throws AccessPoemException {
306             ((Account)g).setName((String)raw);
307           }
308         });
309   }
310 
311 
312  /**
313   * Retrieves the <code>Id</code> <code>Column</code> for this 
314   * <code>Account</code> <code>Table</code>.
315   * 
316   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
317   * @return the id <code>Column</code>
318   */
319   public final Column<Integer> getIdColumn() {
320     return col_id;
321   }
322 
323 
324  /**
325   * Retrieves the <code>User</code> <code>Column</code> for this 
326   * <code>Account</code> <code>Table</code>.
327   * 
328   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
329   * @return the user <code>Column</code>
330   */
331   public final Column<Integer> getUserColumn() {
332     return col_user;
333   }
334 
335 
336  /**
337   * Retrieves the <code>EmailAddress</code> <code>Column</code> for this 
338   * <code>Account</code> <code>Table</code>.
339   * 
340   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
341   * @return the emailAddress <code>Column</code>
342   */
343   public final Column<String> getEmailAddressColumn() {
344     return col_emailAddress;
345   }
346 
347 
348  /**
349   * Retrieves the <code>Name</code> <code>Column</code> for this 
350   * <code>Account</code> <code>Table</code>.
351   * 
352   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
353   * @return the name <code>Column</code>
354   */
355   public final Column<String> getNameColumn() {
356     return col_name;
357   }
358 
359 
360  /**
361   * Retrieve the <code>Account</code> as a <code>Account</code>.
362   *
363   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
364   * @param troid a Table Row Object ID
365   * @return the <code>Persistent</code> identified by the <code>troid</code>
366   */
367   public Account getAccountObject(Integer troid) {
368     return (Account)getObject(troid);
369   }
370 
371 
372  /**
373   * Retrieve the <code>Account</code> 
374   * as a <code>Account</code>.
375   *
376   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
377   * @param troid a Table Row Object ID
378   * @return the <code>Persistent</code> identified   */
379   public Account getAccountObject(int troid) {
380     return (Account)getObject(troid);
381   }
382 
383   protected JdbcPersistent _newPersistent() {
384     return new Account();
385   }
386   public String defaultDescription() {
387     return "An account owned by a User";
388   }
389 
390   public String defaultCategory() {
391     return "User";
392   }
393 
394   public int defaultDisplayOrder() {
395     return 2020;
396   }
397 }
398