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.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.StringPoemType;
18  import org.melati.poem.TroidPoemType;
19  import org.melati.poem.ValidationPoemException;
20  
21  
22  /**
23   * Melati POEM generated base class for <code>Table</code> <code>Parent</code>.
24   *
25   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
26   */
27  
28  public class ParentTableBase<T extends Parent> extends OdmgTable<T> {
29  
30    private Column<Integer> col_id = null;
31    private Column<String> col_name = null;
32  
33   /**
34    * Constructor. 
35    * 
36    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
37    * @param database          the POEM database we are using
38    * @param name              the name of this <code>Table</code>
39    * @param definitionSource  which definition is being used
40    * @throws PoemException    if anything goes wrong
41    */
42  
43    public ParentTableBase(
44        Database database, String name,
45        DefinitionSource definitionSource) throws PoemException {
46      super(database, name, definitionSource);
47    }
48  
49  
50   /**
51    * Get the database tables.
52    *
53    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
54    * @return the database tables
55    */
56    public OdmgDatabaseTables getOdmgDatabaseTables() {
57      return (OdmgDatabaseTables)getDatabase();
58    }
59  
60  
61   /**
62    * Initialise this table by defining its columns.
63    *
64    * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
65    */
66    public void init() throws PoemException {
67      super.init();
68      defineColumn(col_id =
69          new Column<Integer>(this, "id",
70                     new TroidPoemType(),
71                     DefinitionSource.dsd) { 
72            public Object getCooked(Persistent g)
73                throws AccessPoemException, PoemException {
74              return ((Parent)g).getId();
75            }
76  
77            public void setCooked(Persistent g, Object cooked)
78                throws AccessPoemException, ValidationPoemException {
79              ((Parent)g).setId((Integer)cooked);
80            }
81  
82            public Field<Integer> asField(Persistent g) {
83              return ((Parent)g).getIdField();
84            }
85  
86            public boolean defaultUserEditable() {
87              return false;
88            }
89  
90            public boolean defaultUserCreateable() {
91              return false;
92            }
93  
94            public int defaultDisplayOrder() {
95              return 0;
96            }
97  
98            public Object getRaw_unsafe(Persistent g)
99                throws AccessPoemException {
100             return ((Parent)g).getId_unsafe();
101           }
102 
103           public void setRaw_unsafe(Persistent g, Object raw)
104               throws AccessPoemException {
105             ((Parent)g).setId_unsafe((Integer)raw);
106           }
107 
108           public Object getRaw(Persistent g)
109               throws AccessPoemException {
110             return ((Parent)g).getId();
111           }
112 
113           public void setRaw(Persistent g, Object raw)
114               throws AccessPoemException {
115             ((Parent)g).setId((Integer)raw);
116           }
117         });
118 
119     defineColumn(col_name =
120         new Column<String>(this, "name",
121                    new StringPoemType(false, 60),
122                    DefinitionSource.dsd) { 
123           public Object getCooked(Persistent g)
124               throws AccessPoemException, PoemException {
125             return ((Parent)g).getName();
126           }
127 
128           public void setCooked(Persistent g, Object cooked)
129               throws AccessPoemException, ValidationPoemException {
130             ((Parent)g).setName((String)cooked);
131           }
132 
133           public Field<String> asField(Persistent g) {
134             return ((Parent)g).getNameField();
135           }
136 
137           public int defaultDisplayOrder() {
138             return 1;
139           }
140 
141           public Object getRaw_unsafe(Persistent g)
142               throws AccessPoemException {
143             return ((Parent)g).getName_unsafe();
144           }
145 
146           public void setRaw_unsafe(Persistent g, Object raw)
147               throws AccessPoemException {
148             ((Parent)g).setName_unsafe((String)raw);
149           }
150 
151           public Object getRaw(Persistent g)
152               throws AccessPoemException {
153             return ((Parent)g).getName();
154           }
155 
156           public void setRaw(Persistent g, Object raw)
157               throws AccessPoemException {
158             ((Parent)g).setName((String)raw);
159           }
160         });
161   }
162 
163 
164  /**
165   * Retrieves the <code>Id</code> <code>Column</code> for this 
166   * <code>Parent</code> <code>Table</code>.
167   * 
168   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
169   * @return the id <code>Column</code>
170   */
171   public final Column<Integer> getIdColumn() {
172     return col_id;
173   }
174 
175 
176  /**
177   * Retrieves the <code>Name</code> <code>Column</code> for this 
178   * <code>Parent</code> <code>Table</code>.
179   * 
180   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
181   * @return the name <code>Column</code>
182   */
183   public final Column<String> getNameColumn() {
184     return col_name;
185   }
186 
187 
188  /**
189   * Retrieve the <code>Parent</code> as a <code>Parent</code>.
190   *
191   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
192   * @param troid a Table Row Object ID
193   * @return the <code>Persistent</code> identified by the <code>troid</code>
194   */
195   public Parent getParentObject(Integer troid) {
196     return (Parent)getObject(troid);
197   }
198 
199 
200  /**
201   * Retrieve the <code>Parent</code> 
202   * as a <code>Parent</code>.
203   *
204   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
205   * @param troid a Table Row Object ID
206   * @return the <code>Persistent</code> identified   */
207   public Parent getParentObject(int troid) {
208     return (Parent)getObject(troid);
209   }
210 
211   protected JdbcPersistent _newPersistent() {
212     return new Parent();
213   }
214   public int defaultDisplayOrder() {
215     return 0;
216   }
217 }
218