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