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