001: package simpleorm.examples;
002:
003: import simpleorm.core.*;
004: import simpleorm.properties.*;
005:
006: /** This test class defines the Payroll tables as static inner tables
007: which demonstrate identifying foreign keys. */
008: public class Payroll {
009:
010: static public class Period extends SRecordInstance {
011:
012: public static final SRecordMeta meta = new SRecordMeta(
013: Period.class, "XX_PAY_PERIOD");
014:
015: public static final SFieldInteger YEAR = new SFieldInteger(
016: meta, "YEAR", SCon.SFD_PRIMARY_KEY);
017:
018: public static final SFieldInteger PERIOD = new SFieldInteger(
019: meta, "PERIOD", SCon.SFD_PRIMARY_KEY);
020:
021: public static final SFieldDouble TOTAL_PAYROLL = new SFieldDouble(
022: meta, "TOTAL_PAYROLL");
023:
024: public SRecordMeta getMeta() {
025: return meta;
026: };
027: }
028:
029: static public class PaySlip extends SRecordInstance {
030:
031: public static final SRecordMeta meta = new SRecordMeta(
032: PaySlip.class, "XX_PAY_SLIP");
033:
034: static final SFieldString INCONSISTENT_EMP_NR = // not recommended
035: new SFieldString(meta, "INCONSIST_EMP_NR", 20,
036: SCon.SFD_PRIMARY_KEY);
037:
038: static final SFieldReference EMPLOYEE = new SFieldReference(
039: meta, Employee.meta,
040: new SFieldMeta[] { INCONSISTENT_EMP_NR },
041: new SPropertyValue[] { SCon.SFD_PRIMARY_KEY,
042: SCon.SFIELD_NAME.pvalue("INCONS") }); // Name for Foreign Key Constraint etc.
043:
044: static final SFieldReference PERIOD = new SFieldReference(meta,
045: Period.meta, (String) null, SCon.SFD_PRIMARY_KEY);
046:
047: //static final SFieldReference PAYSLIP =
048: // new SFieldReference(meta, PaySlip.meta,
049: // (String)null, SFD_PRIMARY_KEY);
050:
051: public static final SFieldString COMMENTS = new SFieldString(
052: meta, "COMMENTS", 200);
053:
054: public SRecordMeta getMeta() {
055: return meta;
056: };
057: }
058:
059: static public class PaySlipDetail extends SRecordInstance {
060:
061: public static final SRecordMeta meta = new SRecordMeta(
062: PaySlipDetail.class, "XX_PSLIP_DTL");
063:
064: static final SFieldReference PAY_SLIP = new SFieldReference(
065: meta, PaySlip.meta, (String) null,
066: SCon.SFD_PRIMARY_KEY, SCon.SFD_INNER_FOREIGN_KEY);
067:
068: public static final SFieldInteger DETAIL_TYPE = // Should be Enum
069: new SFieldInteger(meta, "DETAIL_TYPE", SCon.SFD_PRIMARY_KEY);
070:
071: public static final SFieldDouble VALUE = new SFieldDouble(meta,
072: "VALUE");
073:
074: public SRecordMeta getMeta() {
075: return meta;
076: };
077: }
078:
079: static public class UglyPaySlipDetail extends SRecordInstance {
080:
081: public static final SRecordMeta meta = new SRecordMeta(
082: UglyPaySlipDetail.class, "XX_UGLY_PAY_DTL");
083:
084: static final SFieldString UGLY_EMP_NR = new SFieldString(meta,
085: "UGLY_EMP_NR", 20, SCon.SFD_PRIMARY_KEY);
086:
087: static final SFieldReference EMPLOYEE = new SFieldReference(
088: meta, PaySlip.EMPLOYEE,
089: new SFieldMeta[] { UGLY_EMP_NR }, new SPropertyValue[] {
090: SCon.SFD_PRIMARY_KEY,
091: SCon.SFIELD_NAME.pvalue("UGLYEMP") });
092:
093: static final SFieldReference PERIOD = new SFieldReference(meta,
094: PaySlip.PERIOD, (String) null,
095: new SPropertyValue[] { SCon.SFD_PRIMARY_KEY });
096:
097: static final SFieldReference PAY_SLIP = new SFieldReference(
098: meta, PaySlip.meta,
099: new SFieldMeta[] { EMPLOYEE, PERIOD },
100: new SPropertyValue[] { SCon.SFD_PRIMARY_KEY,
101: SCon.SFD_INNER_FOREIGN_KEY,
102: SCon.SFIELD_NAME.pvalue("UGLY_PAYSLIP") });
103:
104: public static final SFieldInteger DETAIL_TYPE = // Should be Enum
105: new SFieldInteger(meta, "DETAIL_TYPE", SCon.SFD_PRIMARY_KEY);
106:
107: public static final SFieldDouble VALUE = new SFieldDouble(meta,
108: "VALUE");
109:
110: public SRecordMeta getMeta() {
111: return meta;
112: };
113: }
114: }
|