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