| 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.DisplayLevel; |
| 11 | |
import org.melati.poem.Field; |
| 12 | |
import org.melati.poem.JdbcPersistent; |
| 13 | |
import org.melati.poem.PasswordPoemType; |
| 14 | |
import org.melati.poem.Persistent; |
| 15 | |
import org.melati.poem.PoemDatabaseTables; |
| 16 | |
import org.melati.poem.PoemException; |
| 17 | |
import org.melati.poem.PoemTable; |
| 18 | |
import org.melati.poem.Searchability; |
| 19 | |
import org.melati.poem.StringPoemType; |
| 20 | |
import org.melati.poem.TroidPoemType; |
| 21 | |
import org.melati.poem.User; |
| 22 | |
import org.melati.poem.ValidationPoemException; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public class UserTableBase<T extends User> extends PoemTable<T> { |
| 32 | |
|
| 33 | 64 | private Column<Integer> col_id = null; |
| 34 | 64 | private Column<String> col_name = null; |
| 35 | 64 | private Column<String> col_login = null; |
| 36 | 64 | private Column<String> col_password = null; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
public UserTableBase( |
| 49 | |
Database database, String name, |
| 50 | |
DefinitionSource definitionSource) throws PoemException { |
| 51 | 64 | super(database, name, definitionSource); |
| 52 | 64 | } |
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
public PoemDatabaseTables getPoemDatabaseTables() { |
| 62 | 0 | return (PoemDatabaseTables)getDatabase(); |
| 63 | |
} |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
public void init() throws PoemException { |
| 72 | 41 | super.init(); |
| 73 | 41 | defineColumn(col_id = |
| 74 | |
new Column<Integer>(this, "id", |
| 75 | |
new TroidPoemType(), |
| 76 | 41 | DefinitionSource.dsd) { |
| 77 | |
public Object getCooked(Persistent g) |
| 78 | |
throws AccessPoemException, PoemException { |
| 79 | 0 | return ((User)g).getId(); |
| 80 | |
} |
| 81 | |
|
| 82 | |
public void setCooked(Persistent g, Object cooked) |
| 83 | |
throws AccessPoemException, ValidationPoemException { |
| 84 | 0 | ((User)g).setId((Integer)cooked); |
| 85 | 0 | } |
| 86 | |
|
| 87 | |
public Field<Integer> asField(Persistent g) { |
| 88 | 0 | return ((User)g).getIdField(); |
| 89 | |
} |
| 90 | |
|
| 91 | |
public boolean defaultUserEditable() { |
| 92 | 40 | return false; |
| 93 | |
} |
| 94 | |
|
| 95 | |
public boolean defaultUserCreateable() { |
| 96 | 40 | return false; |
| 97 | |
} |
| 98 | |
|
| 99 | |
public DisplayLevel defaultDisplayLevel() { |
| 100 | 80 | return DisplayLevel.detail; |
| 101 | |
} |
| 102 | |
|
| 103 | |
public int defaultDisplayOrder() { |
| 104 | 40 | return 10; |
| 105 | |
} |
| 106 | |
|
| 107 | |
public String defaultDescription() { |
| 108 | 40 | return "The Table Row Object ID"; |
| 109 | |
} |
| 110 | |
|
| 111 | |
public Object getRaw_unsafe(Persistent g) |
| 112 | |
throws AccessPoemException { |
| 113 | 163 | return ((User)g).getId_unsafe(); |
| 114 | |
} |
| 115 | |
|
| 116 | |
public void setRaw_unsafe(Persistent g, Object raw) |
| 117 | |
throws AccessPoemException { |
| 118 | 257 | ((User)g).setId_unsafe((Integer)raw); |
| 119 | 257 | } |
| 120 | |
|
| 121 | |
public Object getRaw(Persistent g) |
| 122 | |
throws AccessPoemException { |
| 123 | 4 | return ((User)g).getId(); |
| 124 | |
} |
| 125 | |
|
| 126 | |
public void setRaw(Persistent g, Object raw) |
| 127 | |
throws AccessPoemException { |
| 128 | 0 | ((User)g).setId((Integer)raw); |
| 129 | 0 | } |
| 130 | |
}); |
| 131 | |
|
| 132 | 41 | defineColumn(col_name = |
| 133 | |
new Column<String>(this, "name", |
| 134 | |
new StringPoemType(false, 60), |
| 135 | 41 | DefinitionSource.dsd) { |
| 136 | |
public Object getCooked(Persistent g) |
| 137 | |
throws AccessPoemException, PoemException { |
| 138 | 19 | return ((User)g).getName(); |
| 139 | |
} |
| 140 | |
|
| 141 | |
public void setCooked(Persistent g, Object cooked) |
| 142 | |
throws AccessPoemException, ValidationPoemException { |
| 143 | 6 | ((User)g).setName((String)cooked); |
| 144 | 6 | } |
| 145 | |
|
| 146 | |
public Field<String> asField(Persistent g) { |
| 147 | 13 | return ((User)g).getNameField(); |
| 148 | |
} |
| 149 | |
|
| 150 | |
public DisplayLevel defaultDisplayLevel() { |
| 151 | 80 | return DisplayLevel.primary; |
| 152 | |
} |
| 153 | |
|
| 154 | |
public Searchability defaultSearchability() { |
| 155 | 80 | return Searchability.primary; |
| 156 | |
} |
| 157 | |
|
| 158 | |
public Integer defaultDisplayOrderPriority() { |
| 159 | 40 | return new Integer(0); |
| 160 | |
} |
| 161 | |
|
| 162 | |
public String defaultDisplayName() { |
| 163 | 40 | return "Full name"; |
| 164 | |
} |
| 165 | |
|
| 166 | |
public int defaultDisplayOrder() { |
| 167 | 40 | return 20; |
| 168 | |
} |
| 169 | |
|
| 170 | |
public String defaultDescription() { |
| 171 | 40 | return "The user's real name"; |
| 172 | |
} |
| 173 | |
|
| 174 | |
public boolean defaultIndexed() { |
| 175 | 40 | return true; |
| 176 | |
} |
| 177 | |
|
| 178 | |
public Object getRaw_unsafe(Persistent g) |
| 179 | |
throws AccessPoemException { |
| 180 | 164 | return ((User)g).getName_unsafe(); |
| 181 | |
} |
| 182 | |
|
| 183 | |
public void setRaw_unsafe(Persistent g, Object raw) |
| 184 | |
throws AccessPoemException { |
| 185 | 57 | ((User)g).setName_unsafe((String)raw); |
| 186 | 57 | } |
| 187 | |
|
| 188 | |
public Object getRaw(Persistent g) |
| 189 | |
throws AccessPoemException { |
| 190 | 31 | return ((User)g).getName(); |
| 191 | |
} |
| 192 | |
|
| 193 | |
public void setRaw(Persistent g, Object raw) |
| 194 | |
throws AccessPoemException { |
| 195 | 10 | ((User)g).setName((String)raw); |
| 196 | 10 | } |
| 197 | |
}); |
| 198 | |
|
| 199 | 41 | defineColumn(col_login = |
| 200 | |
new Column<String>(this, "login", |
| 201 | |
new StringPoemType(false, 255), |
| 202 | 41 | DefinitionSource.dsd) { |
| 203 | |
public Object getCooked(Persistent g) |
| 204 | |
throws AccessPoemException, PoemException { |
| 205 | 0 | return ((User)g).getLogin(); |
| 206 | |
} |
| 207 | |
|
| 208 | |
public void setCooked(Persistent g, Object cooked) |
| 209 | |
throws AccessPoemException, ValidationPoemException { |
| 210 | 2 | ((User)g).setLogin((String)cooked); |
| 211 | 2 | } |
| 212 | |
|
| 213 | |
public Field<String> asField(Persistent g) { |
| 214 | 8 | return ((User)g).getLoginField(); |
| 215 | |
} |
| 216 | |
|
| 217 | |
public int defaultDisplayOrder() { |
| 218 | 40 | return 30; |
| 219 | |
} |
| 220 | |
|
| 221 | |
public String defaultDescription() { |
| 222 | 40 | return "The user's login name"; |
| 223 | |
} |
| 224 | |
|
| 225 | |
public boolean defaultUnique() { |
| 226 | 40 | return true; |
| 227 | |
} |
| 228 | |
|
| 229 | |
public int defaultWidth() { |
| 230 | 40 | return 20; |
| 231 | |
} |
| 232 | |
|
| 233 | |
public Object getRaw_unsafe(Persistent g) |
| 234 | |
throws AccessPoemException { |
| 235 | 245 | return ((User)g).getLogin_unsafe(); |
| 236 | |
} |
| 237 | |
|
| 238 | |
public void setRaw_unsafe(Persistent g, Object raw) |
| 239 | |
throws AccessPoemException { |
| 240 | 57 | ((User)g).setLogin_unsafe((String)raw); |
| 241 | 57 | } |
| 242 | |
|
| 243 | |
public Object getRaw(Persistent g) |
| 244 | |
throws AccessPoemException { |
| 245 | 8 | return ((User)g).getLogin(); |
| 246 | |
} |
| 247 | |
|
| 248 | |
public void setRaw(Persistent g, Object raw) |
| 249 | |
throws AccessPoemException { |
| 250 | 0 | ((User)g).setLogin((String)raw); |
| 251 | 0 | } |
| 252 | |
}); |
| 253 | |
|
| 254 | 41 | defineColumn(col_password = |
| 255 | |
new Column<String>(this, "password", |
| 256 | |
new PasswordPoemType(false, 20), |
| 257 | 41 | DefinitionSource.dsd) { |
| 258 | |
public Object getCooked(Persistent g) |
| 259 | |
throws AccessPoemException, PoemException { |
| 260 | 0 | return ((User)g).getPassword(); |
| 261 | |
} |
| 262 | |
|
| 263 | |
public void setCooked(Persistent g, Object cooked) |
| 264 | |
throws AccessPoemException, ValidationPoemException { |
| 265 | 2 | ((User)g).setPassword((String)cooked); |
| 266 | 2 | } |
| 267 | |
|
| 268 | |
public Field<String> asField(Persistent g) { |
| 269 | 8 | return ((User)g).getPasswordField(); |
| 270 | |
} |
| 271 | |
|
| 272 | |
public DisplayLevel defaultDisplayLevel() { |
| 273 | 80 | return DisplayLevel.record; |
| 274 | |
} |
| 275 | |
|
| 276 | |
public Searchability defaultSearchability() { |
| 277 | 80 | return Searchability.no; |
| 278 | |
} |
| 279 | |
|
| 280 | |
public int defaultDisplayOrder() { |
| 281 | 40 | return 40; |
| 282 | |
} |
| 283 | |
|
| 284 | |
public String defaultDescription() { |
| 285 | 40 | return "The user's password"; |
| 286 | |
} |
| 287 | |
|
| 288 | |
public int defaultWidth() { |
| 289 | 40 | return 10; |
| 290 | |
} |
| 291 | |
|
| 292 | |
public Object getRaw_unsafe(Persistent g) |
| 293 | |
throws AccessPoemException { |
| 294 | 163 | return ((User)g).getPassword_unsafe(); |
| 295 | |
} |
| 296 | |
|
| 297 | |
public void setRaw_unsafe(Persistent g, Object raw) |
| 298 | |
throws AccessPoemException { |
| 299 | 57 | ((User)g).setPassword_unsafe((String)raw); |
| 300 | 57 | } |
| 301 | |
|
| 302 | |
public Object getRaw(Persistent g) |
| 303 | |
throws AccessPoemException { |
| 304 | 9 | return ((User)g).getPassword(); |
| 305 | |
} |
| 306 | |
|
| 307 | |
public void setRaw(Persistent g, Object raw) |
| 308 | |
throws AccessPoemException { |
| 309 | 0 | ((User)g).setPassword((String)raw); |
| 310 | 0 | } |
| 311 | |
}); |
| 312 | 41 | } |
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
|
| 322 | |
public final Column<Integer> getIdColumn() { |
| 323 | 1 | return col_id; |
| 324 | |
} |
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | |
public final Column<String> getNameColumn() { |
| 335 | 98 | return col_name; |
| 336 | |
} |
| 337 | |
|
| 338 | |
|
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
|
| 346 | |
public final Column<String> getLoginColumn() { |
| 347 | 289 | return col_login; |
| 348 | |
} |
| 349 | |
|
| 350 | |
|
| 351 | |
|
| 352 | |
|
| 353 | |
|
| 354 | |
|
| 355 | |
|
| 356 | |
|
| 357 | |
|
| 358 | |
public final Column<String> getPasswordColumn() { |
| 359 | 33 | return col_password; |
| 360 | |
} |
| 361 | |
|
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
|
| 370 | |
public User getUserObject(Integer troid) { |
| 371 | 0 | return (User)getObject(troid); |
| 372 | |
} |
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
|
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | |
public User getUserObject(int troid) { |
| 383 | 0 | return (User)getObject(troid); |
| 384 | |
} |
| 385 | |
|
| 386 | |
protected JdbcPersistent _newPersistent() { |
| 387 | 102 | return new User(); |
| 388 | |
} |
| 389 | |
public String defaultDescription() { |
| 390 | 19 | return "A registered User of the database"; |
| 391 | |
} |
| 392 | |
|
| 393 | |
public boolean defaultRememberAllTroids() { |
| 394 | 40 | return true; |
| 395 | |
} |
| 396 | |
|
| 397 | |
public String defaultCategory() { |
| 398 | 19 | return "User"; |
| 399 | |
} |
| 400 | |
|
| 401 | |
public int defaultDisplayOrder() { |
| 402 | 19 | return 2010; |
| 403 | |
} |
| 404 | |
|
| 405 | |
|
| 406 | |
|
| 407 | |
|
| 408 | |
public User ensure(String name, String login, String password) { |
| 409 | 0 | User p = (User)getLoginColumn().firstWhereEq(login); |
| 410 | 0 | if (p == null) { |
| 411 | 0 | p = (User)newPersistent(); |
| 412 | 0 | p.setName(name); |
| 413 | 0 | p.setLogin(login); |
| 414 | 0 | p.setPassword(password); |
| 415 | |
} |
| 416 | 0 | return (User)getLoginColumn().ensure(p); |
| 417 | |
} |
| 418 | |
} |
| 419 | |
|