1
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
25
26
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
37
38
39
40
41
42
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
54
55
56
57
58 public PoemDatabaseTables getPoemDatabaseTables() {
59 return (PoemDatabaseTables)getDatabase();
60 }
61
62
63
64
65
66
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
231
232
233
234
235
236 public final Column<Integer> getIdColumn() {
237 return col_id;
238 }
239
240
241
242
243
244
245
246
247
248 public final Column<String> getNameColumn() {
249 return col_name;
250 }
251
252
253
254
255
256
257
258
259
260 public final Column<String> getValueColumn() {
261 return col_value;
262 }
263
264
265
266
267
268
269
270
271
272 public Setting getSettingObject(Integer troid) {
273 return (Setting)getObject(troid);
274 }
275
276
277
278
279
280
281
282
283
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
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