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   
6   import org.melati.example.odmg.Child;
7   import org.melati.example.odmg.OdmgDatabaseTables;
8   import org.melati.example.odmg.OdmgTable;
9   import org.melati.example.odmg.Parent;
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.Field;
15  import org.melati.poem.JdbcPersistent;
16  import org.melati.poem.Persistent;
17  import org.melati.poem.PoemException;
18  import org.melati.poem.ReferencePoemType;
19  import org.melati.poem.StringPoemType;
20  import org.melati.poem.TroidPoemType;
21  import org.melati.poem.ValidationPoemException;
22  
23  
24  /**
25   * Melati POEM generated base class for <code>Table</code> <code>Child</code>.
26   *
27   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
28   */
29  
30  public class ChildTableBase<T extends Child> extends OdmgTable<T> {
31  
32    private Column<Integer> col_id = null;
33    private Column<String> col_name = null;
34    private Column<Integer> col_parent = null;
35  
36   /**
37    * Constructor. 
38    * 
39    * See 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    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
57    * @return the database tables
58    */
59    public OdmgDatabaseTables getOdmgDatabaseTables() {
60      return (OdmgDatabaseTables)getDatabase();
61    }
62  
63  
64   /**
65    * Initialise this table by defining its columns.
66    *
67    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
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 int defaultDisplayOrder() {
98              return 0;
99            }
100 
101           public Object getRaw_unsafe(Persistent g)
102               throws AccessPoemException {
103             return ((Child)g).getId_unsafe();
104           }
105 
106           public void setRaw_unsafe(Persistent g, Object raw)
107               throws AccessPoemException {
108             ((Child)g).setId_unsafe((Integer)raw);
109           }
110 
111           public Object getRaw(Persistent g)
112               throws AccessPoemException {
113             return ((Child)g).getId();
114           }
115 
116           public void setRaw(Persistent g, Object raw)
117               throws AccessPoemException {
118             ((Child)g).setId((Integer)raw);
119           }
120         });
121 
122     defineColumn(col_name =
123         new Column<String>(this, "name",
124                    new StringPoemType(false, 60),
125                    DefinitionSource.dsd) { 
126           public Object getCooked(Persistent g)
127               throws AccessPoemException, PoemException {
128             return ((Child)g).getName();
129           }
130 
131           public void setCooked(Persistent g, Object cooked)
132               throws AccessPoemException, ValidationPoemException {
133             ((Child)g).setName((String)cooked);
134           }
135 
136           public Field<String> asField(Persistent g) {
137             return ((Child)g).getNameField();
138           }
139 
140           public int defaultDisplayOrder() {
141             return 1;
142           }
143 
144           public Object getRaw_unsafe(Persistent g)
145               throws AccessPoemException {
146             return ((Child)g).getName_unsafe();
147           }
148 
149           public void setRaw_unsafe(Persistent g, Object raw)
150               throws AccessPoemException {
151             ((Child)g).setName_unsafe((String)raw);
152           }
153 
154           public Object getRaw(Persistent g)
155               throws AccessPoemException {
156             return ((Child)g).getName();
157           }
158 
159           public void setRaw(Persistent g, Object raw)
160               throws AccessPoemException {
161             ((Child)g).setName((String)raw);
162           }
163         });
164 
165     defineColumn(col_parent =
166         new Column<Integer>(this, "parent",
167                    new ReferencePoemType(getOdmgDatabaseTables().
168                                              getParentTable(), false),
169                    DefinitionSource.dsd) { 
170           public Object getCooked(Persistent g)
171               throws AccessPoemException, PoemException {
172             return ((Child)g).getParent();
173           }
174 
175           public void setCooked(Persistent g, Object cooked)
176               throws AccessPoemException, ValidationPoemException {
177             ((Child)g).setParent((Parent)cooked);
178           }
179 
180           public Field<Integer> asField(Persistent g) {
181             return ((Child)g).getParentField();
182           }
183 
184           public int defaultDisplayOrder() {
185             return 2;
186           }
187 
188           public Object getRaw_unsafe(Persistent g)
189               throws AccessPoemException {
190             return ((Child)g).getParent_unsafe();
191           }
192 
193           public void setRaw_unsafe(Persistent g, Object raw)
194               throws AccessPoemException {
195             ((Child)g).setParent_unsafe((Integer)raw);
196           }
197 
198           public Object getRaw(Persistent g)
199               throws AccessPoemException {
200             return ((Child)g).getParentTroid();
201           }
202 
203           public void setRaw(Persistent g, Object raw)
204               throws AccessPoemException {
205             ((Child)g).setParentTroid((Integer)raw);
206           }
207         });
208   }
209 
210 
211  /**
212   * Retrieves the <code>Id</code> <code>Column</code> for this 
213   * <code>Child</code> <code>Table</code>.
214   * 
215   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
216   * @return the id <code>Column</code>
217   */
218   public final Column<Integer> getIdColumn() {
219     return col_id;
220   }
221 
222 
223  /**
224   * Retrieves the <code>Name</code> <code>Column</code> for this 
225   * <code>Child</code> <code>Table</code>.
226   * 
227   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
228   * @return the name <code>Column</code>
229   */
230   public final Column<String> getNameColumn() {
231     return col_name;
232   }
233 
234 
235  /**
236   * Retrieves the <code>Parent</code> <code>Column</code> for this 
237   * <code>Child</code> <code>Table</code>.
238   * 
239   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
240   * @return the parent <code>Column</code>
241   */
242   public final Column<Integer> getParentColumn() {
243     return col_parent;
244   }
245 
246 
247  /**
248   * Retrieve the <code>Child</code> as a <code>Child</code>.
249   *
250   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
251   * @param troid a Table Row Object ID
252   * @return the <code>Persistent</code> identified by the <code>troid</code>
253   */
254   public Child getChildObject(Integer troid) {
255     return (Child)getObject(troid);
256   }
257 
258 
259  /**
260   * Retrieve the <code>Child</code> 
261   * as a <code>Child</code>.
262   *
263   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
264   * @param troid a Table Row Object ID
265   * @return the <code>Persistent</code> identified   */
266   public Child getChildObject(int troid) {
267     return (Child)getObject(troid);
268   }
269 
270   protected JdbcPersistent _newPersistent() {
271     return new Child();
272   }
273   public int defaultDisplayOrder() {
274     return 1;
275   }
276 }
277