View Javadoc

1   // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
2   
3   package org.melati.example.odmg.generated;
4   
5   import org.melati.example.odmg.Child;
6   import org.melati.example.odmg.OdmgDatabaseTables;
7   import org.melati.example.odmg.OdmgTable;
8   import org.melati.example.odmg.Parent;
9   import org.melati.poem.AccessPoemException;
10  import org.melati.poem.Column;
11  import org.melati.poem.Database;
12  import org.melati.poem.DefinitionSource;
13  import org.melati.poem.Field;
14  import org.melati.poem.JdbcPersistent;
15  import org.melati.poem.Persistent;
16  import org.melati.poem.PoemException;
17  import org.melati.poem.ReferencePoemType;
18  import org.melati.poem.StringPoemType;
19  import org.melati.poem.TroidPoemType;
20  import org.melati.poem.ValidationPoemException;
21  
22  
23  /**
24   * Melati POEM generated base class for 
25  <code>Table</code> <code>Child</code>.
26   *
27   * @generator org.melati.poem.prepro.TableDef#generateTableBaseJava 
28   */
29  
30  public class ChildTableBase extends OdmgTable {
31  
32    private Column col_id = null;
33    private Column col_name = null;
34    private Column col_parent = null;
35  
36   /**
37    * Constructor. 
38    * 
39    * @generator org.melati.poem.prepro.TableDef#generateTableBaseJava 
40    * @param database          the POEM database we are using
41    * @param name              the name of this <code>Table</code>
42    * @param definitionSource  which definition is being used
43    * @throws PoemException    if anything goes wrong
44    */
45  
46    public ChildTableBase(
47        Database database, String name,
48        DefinitionSource definitionSource) throws PoemException {
49      super(database, name, definitionSource);
50    }
51  
52  
53   /**
54    * Get the database tables.
55    *
56    * @generator org.melati.poem.prepro.TableDef#generateTableBaseJava 
57    * @return the database tables
58    */
59    public OdmgDatabaseTables getOdmgDatabaseTables() {
60      return (OdmgDatabaseTables)getDatabase();
61    }
62  
63    public void init() throws PoemException {
64      super.init();
65      defineColumn(col_id =
66          new Column(this, "id",
67                     new TroidPoemType(),
68                     DefinitionSource.dsd) { 
69            public Object getCooked(Persistent g)
70                throws AccessPoemException, PoemException {
71              return ((Child)g).getId();
72            }
73  
74            public void setCooked(Persistent g, Object cooked)
75                throws AccessPoemException, ValidationPoemException {
76              ((Child)g).setId((Integer)cooked);
77            }
78  
79            public Field asField(Persistent g) {
80              return ((Child)g).getIdField();
81            }
82  
83            protected boolean defaultUserEditable() {
84              return false;
85            }
86  
87            protected boolean defaultUserCreateable() {
88              return false;
89            }
90  
91            protected int defaultDisplayOrder() {
92              return 0;
93            }
94  
95            public Object getRaw_unsafe(Persistent g)
96                throws AccessPoemException {
97              return ((Child)g).getId_unsafe();
98            }
99  
100           public void setRaw_unsafe(Persistent g, Object raw)
101               throws AccessPoemException {
102             ((Child)g).setId_unsafe((Integer)raw);
103           }
104 
105           public Object getRaw(Persistent g)
106               throws AccessPoemException {
107             return ((Child)g).getId();
108           }
109 
110           public void setRaw(Persistent g, Object raw)
111               throws AccessPoemException {
112             ((Child)g).setId((Integer)raw);
113           }
114         });
115 
116     defineColumn(col_name =
117         new Column(this, "name",
118                    new StringPoemType(false, 60),
119                    DefinitionSource.dsd) { 
120           public Object getCooked(Persistent g)
121               throws AccessPoemException, PoemException {
122             return ((Child)g).getName();
123           }
124 
125           public void setCooked(Persistent g, Object cooked)
126               throws AccessPoemException, ValidationPoemException {
127             ((Child)g).setName((String)cooked);
128           }
129 
130           public Field asField(Persistent g) {
131             return ((Child)g).getNameField();
132           }
133 
134           protected int defaultDisplayOrder() {
135             return 1;
136           }
137 
138           public Object getRaw_unsafe(Persistent g)
139               throws AccessPoemException {
140             return ((Child)g).getName_unsafe();
141           }
142 
143           public void setRaw_unsafe(Persistent g, Object raw)
144               throws AccessPoemException {
145             ((Child)g).setName_unsafe((String)raw);
146           }
147 
148           public Object getRaw(Persistent g)
149               throws AccessPoemException {
150             return ((Child)g).getName();
151           }
152 
153           public void setRaw(Persistent g, Object raw)
154               throws AccessPoemException {
155             ((Child)g).setName((String)raw);
156           }
157         });
158 
159     defineColumn(col_parent =
160         new Column(this, "parent",
161                    new ReferencePoemType(getOdmgDatabaseTables().
162                                              getParentTable(), false),
163                    DefinitionSource.dsd) { 
164           public Object getCooked(Persistent g)
165               throws AccessPoemException, PoemException {
166             return ((Child)g).getParent();
167           }
168 
169           public void setCooked(Persistent g, Object cooked)
170               throws AccessPoemException, ValidationPoemException {
171             ((Child)g).setParent((Parent)cooked);
172           }
173 
174           public Field asField(Persistent g) {
175             return ((Child)g).getParentField();
176           }
177 
178           protected int defaultDisplayOrder() {
179             return 2;
180           }
181 
182           public Object getRaw_unsafe(Persistent g)
183               throws AccessPoemException {
184             return ((Child)g).getParent_unsafe();
185           }
186 
187           public void setRaw_unsafe(Persistent g, Object raw)
188               throws AccessPoemException {
189             ((Child)g).setParent_unsafe((Integer)raw);
190           }
191 
192           public Object getRaw(Persistent g)
193               throws AccessPoemException {
194             return ((Child)g).getParentTroid();
195           }
196 
197           public void setRaw(Persistent g, Object raw)
198               throws AccessPoemException {
199             ((Child)g).setParentTroid((Integer)raw);
200           }
201         });
202   }
203 
204 
205  /**
206   * Retrieves the <code>Id</code> <code>Column</code> for this 
207   * <code>Child</code> <code>Table</code>.
208   * 
209   * @generator org.melati.poem.prepro.FieldDef#generateColAccessor 
210   * @return the id <code>Column</code>
211   */
212   public final Column getIdColumn() {
213     return col_id;
214   }
215 
216 
217  /**
218   * Retrieves the <code>Name</code> <code>Column</code> for this 
219   * <code>Child</code> <code>Table</code>.
220   * 
221   * @generator org.melati.poem.prepro.FieldDef#generateColAccessor 
222   * @return the name <code>Column</code>
223   */
224   public final Column getNameColumn() {
225     return col_name;
226   }
227 
228 
229  /**
230   * Retrieves the <code>Parent</code> <code>Column</code> for this 
231   * <code>Child</code> <code>Table</code>.
232   * 
233   * @generator org.melati.poem.prepro.FieldDef#generateColAccessor 
234   * @return the parent <code>Column</code>
235   */
236   public final Column getParentColumn() {
237     return col_parent;
238   }
239 
240 
241  /**
242   * Retrieve the <code>Child</code> as a <code>Child</code>.
243   *
244   * @generator org.melati.poem.prepro.TableDef#generateTableBaseJava 
245   * @param troid a Table Row Oject ID
246   * @return the <code>Persistent</code> identified by the <code>troid</code>
247   */
248   public Child getChildObject(Integer troid) {
249     return (Child)getObject(troid);
250   }
251 
252 
253  /**
254   * Retrieve the <code>Child</code> 
255   * as a <code>Child</code>.
256   *
257   * @generator org.melati.poem.prepro.TableDef#generateTableBaseJava 
258   * @param troid a Table Row Object ID
259   * @return the <code>Persistent</code> identified   */
260   public Child getChildObject(int troid) {
261     return (Child)getObject(troid);
262   }
263 
264   protected JdbcPersistent _newPersistent() {
265     return new Child();
266   }
267   protected int defaultDisplayOrder() {
268     return 1;
269   }
270 }
271