View Javadoc
1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.example.contacts.generated;
4   
5   
6   import java.sql.Date;
7   import org.melati.example.contacts.Contact;
8   import org.melati.example.contacts.ContactsDatabaseTables;
9   import org.melati.example.contacts.ContactsTable;
10  import org.melati.poem.AccessPoemException;
11  import org.melati.poem.Column;
12  import org.melati.poem.Database;
13  import org.melati.poem.DatePoemType;
14  import org.melati.poem.DefinitionSource;
15  import org.melati.poem.DisplayLevel;
16  import org.melati.poem.Field;
17  import org.melati.poem.IntegerPoemType;
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.User;
26  import org.melati.poem.ValidationPoemException;
27  
28  
29  /**
30   * Melati POEM generated base class for <code>Table</code> <code>Contact</code>.
31   *
32   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
33   */
34  
35  public class ContactTableBase<T extends Contact> extends ContactsTable<T> {
36  
37    private Column<Integer> col_id = null;
38    private Column<String> col_name = null;
39    private Column<Integer> col_owner = null;
40    private Column<String> col_address = null;
41    private Column<Integer> col_updates = null;
42    private Column<Date> col_lastupdated = null;
43    private Column<Integer> col_lastupdateuser = null;
44  
45   /**
46    * Constructor. 
47    * 
48    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
49    * @param database          the POEM database we are using
50    * @param name              the name of this <code>Table</code>
51    * @param definitionSource  which definition is being used
52    * @throws PoemException    if anything goes wrong
53    */
54  
55    public ContactTableBase(
56        Database database, String name,
57        DefinitionSource definitionSource) throws PoemException {
58      super(database, name, definitionSource);
59    }
60  
61  
62   /**
63    * Get the database tables.
64    *
65    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
66    * @return the database tables
67    */
68    public ContactsDatabaseTables getContactsDatabaseTables() {
69      return (ContactsDatabaseTables)getDatabase();
70    }
71  
72  
73   /**
74    * Initialise this table by defining its columns.
75    *
76    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
77    */
78    public void init() throws PoemException {
79      super.init();
80      defineColumn(col_id =
81          new Column<Integer>(this, "id",
82                     new TroidPoemType(),
83                     DefinitionSource.dsd) { 
84            public Object getCooked(Persistent g)
85                throws AccessPoemException, PoemException {
86              return ((Contact)g).getId();
87            }
88  
89            public void setCooked(Persistent g, Object cooked)
90                throws AccessPoemException, ValidationPoemException {
91              ((Contact)g).setId((Integer)cooked);
92            }
93  
94            public Field<Integer> asField(Persistent g) {
95              return ((Contact)g).getIdField();
96            }
97  
98            public boolean defaultUserEditable() {
99              return false;
100           }
101 
102           public boolean defaultUserCreateable() {
103             return false;
104           }
105 
106           public DisplayLevel defaultDisplayLevel() {
107             return DisplayLevel.record;
108           }
109 
110           public Searchability defaultSearchability() {
111             return Searchability.no;
112           }
113 
114           public int defaultDisplayOrder() {
115             return 0;
116           }
117 
118           public Object getRaw_unsafe(Persistent g)
119               throws AccessPoemException {
120             return ((Contact)g).getId_unsafe();
121           }
122 
123           public void setRaw_unsafe(Persistent g, Object raw)
124               throws AccessPoemException {
125             ((Contact)g).setId_unsafe((Integer)raw);
126           }
127 
128           public Object getRaw(Persistent g)
129               throws AccessPoemException {
130             return ((Contact)g).getId();
131           }
132 
133           public void setRaw(Persistent g, Object raw)
134               throws AccessPoemException {
135             ((Contact)g).setId((Integer)raw);
136           }
137         });
138 
139     defineColumn(col_name =
140         new Column<String>(this, "name",
141                    new StringPoemType(false, -1),
142                    DefinitionSource.dsd) { 
143           public Object getCooked(Persistent g)
144               throws AccessPoemException, PoemException {
145             return ((Contact)g).getName();
146           }
147 
148           public void setCooked(Persistent g, Object cooked)
149               throws AccessPoemException, ValidationPoemException {
150             ((Contact)g).setName((String)cooked);
151           }
152 
153           public Field<String> asField(Persistent g) {
154             return ((Contact)g).getNameField();
155           }
156 
157           public DisplayLevel defaultDisplayLevel() {
158             return DisplayLevel.primary;
159           }
160 
161           public Searchability defaultSearchability() {
162             return Searchability.primary;
163           }
164 
165           public Integer defaultDisplayOrderPriority() {
166             return new Integer(0);
167           }
168 
169           public int defaultDisplayOrder() {
170             return 1;
171           }
172 
173           public String defaultDescription() {
174             return "Contact Name";
175           }
176 
177           public int defaultWidth() {
178             return 20;
179           }
180 
181           public Object getRaw_unsafe(Persistent g)
182               throws AccessPoemException {
183             return ((Contact)g).getName_unsafe();
184           }
185 
186           public void setRaw_unsafe(Persistent g, Object raw)
187               throws AccessPoemException {
188             ((Contact)g).setName_unsafe((String)raw);
189           }
190 
191           public Object getRaw(Persistent g)
192               throws AccessPoemException {
193             return ((Contact)g).getName();
194           }
195 
196           public void setRaw(Persistent g, Object raw)
197               throws AccessPoemException {
198             ((Contact)g).setName((String)raw);
199           }
200         });
201 
202     defineColumn(col_owner =
203         new Column<Integer>(this, "owner",
204                    new ReferencePoemType(getContactsDatabaseTables().
205                                              getContactTable(), true),
206                    DefinitionSource.dsd) { 
207           public Object getCooked(Persistent g)
208               throws AccessPoemException, PoemException {
209             return ((Contact)g).getOwner();
210           }
211 
212           public void setCooked(Persistent g, Object cooked)
213               throws AccessPoemException, ValidationPoemException {
214             ((Contact)g).setOwner((Contact)cooked);
215           }
216 
217           public Field<Integer> asField(Persistent g) {
218             return ((Contact)g).getOwnerField();
219           }
220 
221           public DisplayLevel defaultDisplayLevel() {
222             return DisplayLevel.summary;
223           }
224 
225           public Searchability defaultSearchability() {
226             return Searchability.yes;
227           }
228 
229           public Integer defaultDisplayOrderPriority() {
230             return new Integer(1);
231           }
232 
233           public int defaultDisplayOrder() {
234             return 2;
235           }
236 
237           public String defaultDescription() {
238             return "Contact who owns this contact";
239           }
240 
241           public Object getRaw_unsafe(Persistent g)
242               throws AccessPoemException {
243             return ((Contact)g).getOwner_unsafe();
244           }
245 
246           public void setRaw_unsafe(Persistent g, Object raw)
247               throws AccessPoemException {
248             ((Contact)g).setOwner_unsafe((Integer)raw);
249           }
250 
251           public Object getRaw(Persistent g)
252               throws AccessPoemException {
253             return ((Contact)g).getOwnerTroid();
254           }
255 
256           public void setRaw(Persistent g, Object raw)
257               throws AccessPoemException {
258             ((Contact)g).setOwnerTroid((Integer)raw);
259           }
260         });
261 
262     defineColumn(col_address =
263         new Column<String>(this, "address",
264                    new StringPoemType(false, -1),
265                    DefinitionSource.dsd) { 
266           public Object getCooked(Persistent g)
267               throws AccessPoemException, PoemException {
268             return ((Contact)g).getAddress();
269           }
270 
271           public void setCooked(Persistent g, Object cooked)
272               throws AccessPoemException, ValidationPoemException {
273             ((Contact)g).setAddress((String)cooked);
274           }
275 
276           public Field<String> asField(Persistent g) {
277             return ((Contact)g).getAddressField();
278           }
279 
280           public DisplayLevel defaultDisplayLevel() {
281             return DisplayLevel.record;
282           }
283 
284           public Searchability defaultSearchability() {
285             return Searchability.no;
286           }
287 
288           public int defaultDisplayOrder() {
289             return 3;
290           }
291 
292           public String defaultDescription() {
293             return "Contact Address";
294           }
295 
296           public int defaultWidth() {
297             return 40;
298           }
299 
300           public int defaultHeight() {
301             return 5;
302           }
303 
304           public Object getRaw_unsafe(Persistent g)
305               throws AccessPoemException {
306             return ((Contact)g).getAddress_unsafe();
307           }
308 
309           public void setRaw_unsafe(Persistent g, Object raw)
310               throws AccessPoemException {
311             ((Contact)g).setAddress_unsafe((String)raw);
312           }
313 
314           public Object getRaw(Persistent g)
315               throws AccessPoemException {
316             return ((Contact)g).getAddress();
317           }
318 
319           public void setRaw(Persistent g, Object raw)
320               throws AccessPoemException {
321             ((Contact)g).setAddress((String)raw);
322           }
323         });
324 
325     defineColumn(col_updates =
326         new Column<Integer>(this, "updates",
327                    new IntegerPoemType(false),
328                    DefinitionSource.dsd) { 
329           public Object getCooked(Persistent g)
330               throws AccessPoemException, PoemException {
331             return ((Contact)g).getUpdates();
332           }
333 
334           public void setCooked(Persistent g, Object cooked)
335               throws AccessPoemException, ValidationPoemException {
336             ((Contact)g).setUpdates((Integer)cooked);
337           }
338 
339           public Field<Integer> asField(Persistent g) {
340             return ((Contact)g).getUpdatesField();
341           }
342 
343           public boolean defaultUserEditable() {
344             return false;
345           }
346 
347           public boolean defaultUserCreateable() {
348             return false;
349           }
350 
351           public DisplayLevel defaultDisplayLevel() {
352             return DisplayLevel.record;
353           }
354 
355           public Searchability defaultSearchability() {
356             return Searchability.no;
357           }
358 
359           public int defaultDisplayOrder() {
360             return 4;
361           }
362 
363           public String defaultDescription() {
364             return "How many times has this record been updated?";
365           }
366 
367           public int defaultWidth() {
368             return 5;
369           }
370 
371           public Object getRaw_unsafe(Persistent g)
372               throws AccessPoemException {
373             return ((Contact)g).getUpdates_unsafe();
374           }
375 
376           public void setRaw_unsafe(Persistent g, Object raw)
377               throws AccessPoemException {
378             ((Contact)g).setUpdates_unsafe((Integer)raw);
379           }
380 
381           public Object getRaw(Persistent g)
382               throws AccessPoemException {
383             return ((Contact)g).getUpdates();
384           }
385 
386           public void setRaw(Persistent g, Object raw)
387               throws AccessPoemException {
388             ((Contact)g).setUpdates((Integer)raw);
389           }
390         });
391 
392     defineColumn(col_lastupdated =
393         new Column<Date>(this, "lastupdated",
394                    new DatePoemType(false),
395                    DefinitionSource.dsd) { 
396           public Object getCooked(Persistent g)
397               throws AccessPoemException, PoemException {
398             return ((Contact)g).getLastupdated();
399           }
400 
401           public void setCooked(Persistent g, Object cooked)
402               throws AccessPoemException, ValidationPoemException {
403             ((Contact)g).setLastupdated((Date)cooked);
404           }
405 
406           public Field<Date> asField(Persistent g) {
407             return ((Contact)g).getLastupdatedField();
408           }
409 
410           public boolean defaultUserEditable() {
411             return false;
412           }
413 
414           public boolean defaultUserCreateable() {
415             return false;
416           }
417 
418           public DisplayLevel defaultDisplayLevel() {
419             return DisplayLevel.record;
420           }
421 
422           public Searchability defaultSearchability() {
423             return Searchability.no;
424           }
425 
426           public int defaultDisplayOrder() {
427             return 5;
428           }
429 
430           public String defaultDescription() {
431             return "When was this last updated?";
432           }
433 
434           public String defaultRenderinfo() {
435             return "org.melati.poem.DatePoemType-dropdown";
436           }
437 
438           public Object getRaw_unsafe(Persistent g)
439               throws AccessPoemException {
440             return ((Contact)g).getLastupdated_unsafe();
441           }
442 
443           public void setRaw_unsafe(Persistent g, Object raw)
444               throws AccessPoemException {
445             ((Contact)g).setLastupdated_unsafe((Date)raw);
446           }
447 
448           public Object getRaw(Persistent g)
449               throws AccessPoemException {
450             return ((Contact)g).getLastupdated();
451           }
452 
453           public void setRaw(Persistent g, Object raw)
454               throws AccessPoemException {
455             ((Contact)g).setLastupdated((Date)raw);
456           }
457         });
458 
459     defineColumn(col_lastupdateuser =
460         new Column<Integer>(this, "lastupdateuser",
461                    new ReferencePoemType(getContactsDatabaseTables().
462                                              getUserTable(), false),
463                    DefinitionSource.dsd) { 
464           public Object getCooked(Persistent g)
465               throws AccessPoemException, PoemException {
466             return ((Contact)g).getLastupdateuser();
467           }
468 
469           public void setCooked(Persistent g, Object cooked)
470               throws AccessPoemException, ValidationPoemException {
471             ((Contact)g).setLastupdateuser((User)cooked);
472           }
473 
474           public Field<Integer> asField(Persistent g) {
475             return ((Contact)g).getLastupdateuserField();
476           }
477 
478           public boolean defaultUserEditable() {
479             return false;
480           }
481 
482           public boolean defaultUserCreateable() {
483             return false;
484           }
485 
486           public DisplayLevel defaultDisplayLevel() {
487             return DisplayLevel.record;
488           }
489 
490           public Searchability defaultSearchability() {
491             return Searchability.yes;
492           }
493 
494           public int defaultDisplayOrder() {
495             return 6;
496           }
497 
498           public String defaultDescription() {
499             return "Who last updated this?";
500           }
501 
502           public Object getRaw_unsafe(Persistent g)
503               throws AccessPoemException {
504             return ((Contact)g).getLastupdateuser_unsafe();
505           }
506 
507           public void setRaw_unsafe(Persistent g, Object raw)
508               throws AccessPoemException {
509             ((Contact)g).setLastupdateuser_unsafe((Integer)raw);
510           }
511 
512           public Object getRaw(Persistent g)
513               throws AccessPoemException {
514             return ((Contact)g).getLastupdateuserTroid();
515           }
516 
517           public void setRaw(Persistent g, Object raw)
518               throws AccessPoemException {
519             ((Contact)g).setLastupdateuserTroid((Integer)raw);
520           }
521         });
522   }
523 
524 
525  /**
526   * Retrieves the <code>Id</code> <code>Column</code> for this 
527   * <code>Contact</code> <code>Table</code>.
528   * 
529   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
530   * @return the id <code>Column</code>
531   */
532   public final Column<Integer> getIdColumn() {
533     return col_id;
534   }
535 
536 
537  /**
538   * Retrieves the <code>Name</code> <code>Column</code> for this 
539   * <code>Contact</code> <code>Table</code>.
540   * 
541   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
542   * @return the name <code>Column</code>
543   */
544   public final Column<String> getNameColumn() {
545     return col_name;
546   }
547 
548 
549  /**
550   * Retrieves the <code>Owner</code> <code>Column</code> for this 
551   * <code>Contact</code> <code>Table</code>.
552   * 
553   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
554   * @return the owner <code>Column</code>
555   */
556   public final Column<Integer> getOwnerColumn() {
557     return col_owner;
558   }
559 
560 
561  /**
562   * Retrieves the <code>Address</code> <code>Column</code> for this 
563   * <code>Contact</code> <code>Table</code>.
564   * 
565   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
566   * @return the address <code>Column</code>
567   */
568   public final Column<String> getAddressColumn() {
569     return col_address;
570   }
571 
572 
573  /**
574   * Retrieves the <code>Updates</code> <code>Column</code> for this 
575   * <code>Contact</code> <code>Table</code>.
576   * 
577   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
578   * @return the updates <code>Column</code>
579   */
580   public final Column<Integer> getUpdatesColumn() {
581     return col_updates;
582   }
583 
584 
585  /**
586   * Retrieves the <code>Lastupdated</code> <code>Column</code> for this 
587   * <code>Contact</code> <code>Table</code>.
588   * 
589   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
590   * @return the lastupdated <code>Column</code>
591   */
592   public final Column<Date> getLastupdatedColumn() {
593     return col_lastupdated;
594   }
595 
596 
597  /**
598   * Retrieves the <code>Lastupdateuser</code> <code>Column</code> for this 
599   * <code>Contact</code> <code>Table</code>.
600   * 
601   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
602   * @return the lastupdateuser <code>Column</code>
603   */
604   public final Column<Integer> getLastupdateuserColumn() {
605     return col_lastupdateuser;
606   }
607 
608 
609  /**
610   * Retrieve the <code>Contact</code> as a <code>Contact</code>.
611   *
612   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
613   * @param troid a Table Row Object ID
614   * @return the <code>Persistent</code> identified by the <code>troid</code>
615   */
616   public Contact getContactObject(Integer troid) {
617     return (Contact)getObject(troid);
618   }
619 
620 
621  /**
622   * Retrieve the <code>Contact</code> 
623   * as a <code>Contact</code>.
624   *
625   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
626   * @param troid a Table Row Object ID
627   * @return the <code>Persistent</code> identified   */
628   public Contact getContactObject(int troid) {
629     return (Contact)getObject(troid);
630   }
631 
632   protected JdbcPersistent _newPersistent() {
633     return new Contact();
634   }
635   public String defaultDescription() {
636     return "A Contact";
637   }
638 
639   public String defaultCategory() {
640     return "Data";
641   }
642 
643   public int defaultDisplayOrder() {
644     return 10;
645   }
646 }
647