01: package simpleorm.simplewebapp.eg.dbute;
02:
03: import simpleorm.core.*;
04: import simpleorm.simplewebapp.core.WValidationException;
05: import simpleorm.simplewebapp.dbute.WRecordInstance;
06:
07: /** This test class defines the User table */
08: public class WUser extends WRecordInstance {
09:
10: public static final SRecordMeta meta = new SRecordMeta(WUser.class,
11: "RSA_USER");
12: // ie. SRecord objects describe SRecordInstances
13:
14: public static final SFieldInteger USER_ID = new SFieldInteger(meta,
15: "userId", SCon.SFD_PRIMARY_KEY, SCon.SGENERATED_KEY
16: .pvalue(new SGeneratorSelectMax(meta)));
17:
18: public static final SFieldString NAME = new SFieldString(meta,
19: "name", 40, SCon.SFD_DESCRIPTIVE, SCon.SFD_MANDATORY);
20:
21: public static final SFieldString ROLE = new SFieldString(meta,
22: "role", 20, SCon.SFD_MANDATORY);
23:
24: public static final SFieldString LOCATION = new SFieldString(meta,
25: "location", 20, SCon.SFD_MANDATORY);
26:
27: static {
28: setOptions(LOCATION, "Here", "There", "Somewhere", "Nowhere");
29: }
30:
31: public static final SFieldString PHONE = new SFieldString(meta,
32: "phone", 20);
33:
34: public static final SFieldBooleanCharYN HAPPY = new SFieldBooleanCharYN(
35: meta, "happy");
36:
37: public static final SFieldString CREDIT_CARD = new SFieldString(
38: meta, "CREDIT_CARD", 20);
39:
40: public static final SFieldString SOCIAL_SECURITY_NR = new SFieldString(
41: meta, "SOCIAL_SECURITY", 12);
42:
43: public static final SFieldString MOTHER_MAIDEN = new SFieldString(
44: meta, "motherMaiden", 20);
45:
46: public @Override
47: SRecordMeta getMeta() {
48: return meta;
49: };
50:
51: /** This will be performed whenever the field is updated, and the message
52: * will be passed all the way through to the user interface.
53: */
54: public @Override
55: void validateField(SFieldMeta field, Object newValue) {
56: if (field == NAME && newValue != null) {
57: if (((String) newValue).length() < 5)
58: throw new WValidationException("User.Name5Chars", null)
59: .setParameter(newValue + "");
60: }
61: }
62:
63: }
|