001: /**
002: * GENERATED CODE: DO NOT MODIFY IT UNDER ANY CIRCUMSTANCES!!!
003: */package com.completex.objective.persistency.examples.ex005.pos;
004:
005: import com.completex.objective.components.persistency.core.impl.AbstractLifeCycleController;
006: import com.completex.objective.components.persistency.LifeCycleController;
007: import com.completex.objective.components.persistency.Record;
008: import com.completex.objective.components.persistency.rule.*;
009: import com.completex.objective.components.persistency.rule.impl.*;
010: import java.math.BigDecimal;
011: import com.completex.objective.components.persistency.PersistentObject;
012:
013: public class CustomerOrderPoCtl extends AbstractLifeCycleController
014: implements PersistentRule {
015:
016: public static final PersistentObject PERSISTENT = new CustomerOrderPO();
017:
018: protected RecordValidator recordInsertValidator = new RecordValidatorImpl(
019: PERSISTENT, true);
020:
021: public CustomerOrderPoCtl(String cacheName) {
022: super (cacheName);
023: }
024:
025: public CustomerOrderPoCtl(
026: com.completex.objective.components.ocache.OdalCache cache) {
027: super (cache);
028: }
029:
030: protected void initInsertValidator() {
031: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
032: initInsertValidatorOrderId();
033: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
034: initInsertValidatorParentOrderId();
035: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
036: initInsertValidatorCustomerId();
037: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
038: initInsertValidatorLastUpdated();
039: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
040: initInsertValidatorCreationDate();
041: }
042:
043: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
044: protected void initInsertValidatorOrderId() {
045: //getRecordInsertValidator().addFieldValidator(CustomerOrderPO.ICOL_ORDER_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
046: }
047:
048: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
049: protected void initInsertValidatorParentOrderId() {
050: //getRecordInsertValidator().addFieldValidator(CustomerOrderPO.ICOL_PARENT_ORDER_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
051: }
052:
053: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
054: protected void initInsertValidatorCustomerId() {
055: getRecordInsertValidator().addFieldValidator(
056: CustomerOrderPO.ICOL_CUSTOMER_ID,
057: new RequiredFieldValidator());
058: //getRecordInsertValidator().addFieldValidator(CustomerOrderPO.ICOL_CUSTOMER_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
059: }
060:
061: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
062: protected void initInsertValidatorLastUpdated() {
063: }
064:
065: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
066: protected void initInsertValidatorCreationDate() {
067: }
068:
069: protected RecordValidator recordUpdateValidator = new RecordValidatorImpl(
070: PERSISTENT, true);
071:
072: protected void initUpdateValidator() {
073: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
074: initUpdateValidatorOrderId();
075: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
076: initUpdateValidatorParentOrderId();
077: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
078: initUpdateValidatorCustomerId();
079: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
080: initUpdateValidatorLastUpdated();
081: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
082: initUpdateValidatorCreationDate();
083: }
084:
085: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
086: protected void initUpdateValidatorOrderId() {
087: }
088:
089: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
090: protected void initUpdateValidatorParentOrderId() {
091: }
092:
093: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
094: protected void initUpdateValidatorCustomerId() {
095: getRecordUpdateValidator().addFieldValidator(
096: CustomerOrderPO.ICOL_CUSTOMER_ID,
097: new NotNullFieldValidator());
098: }
099:
100: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
101: protected void initUpdateValidatorLastUpdated() {
102: }
103:
104: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
105: protected void initUpdateValidatorCreationDate() {
106: }
107:
108: protected RecordConvertor recordConvertor = new RecordConvertorImpl(
109: PERSISTENT);
110:
111: protected void initConvertor() {
112: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
113: initConvertorOrderId();
114: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
115: initConvertorParentOrderId();
116: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
117: initConvertorCustomerId();
118: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
119: initConvertorLastUpdated();
120: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
121: initConvertorCreationDate();
122: }
123:
124: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
125: protected void initConvertorOrderId() {
126: }
127:
128: /* COLUMN NAME: PARENT_ORDER_ID ; ALIAS NAME: PARENT_ORDER_ID */
129: protected void initConvertorParentOrderId() {
130: }
131:
132: /* COLUMN NAME: CUSTOMER_ID ; ALIAS NAME: CUSTOMER_ID */
133: protected void initConvertorCustomerId() {
134: }
135:
136: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
137: protected void initConvertorLastUpdated() {
138: }
139:
140: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
141: protected void initConvertorCreationDate() {
142: }
143:
144: public CustomerOrderPoCtl() {
145: init();
146: }
147:
148: public CustomerOrderPoCtl(Object[] parameters) {
149: super (parameters);
150: }
151:
152: protected void init() {
153: initInsertValidator();
154: initUpdateValidator();
155: initConvertor();
156: }
157:
158: public void beforeInsert(PersistentObject persistentObject) {
159: try {
160: executeInsertRule(persistentObject);
161: } catch (RuntimeRuleException e) {
162: throw e;
163: } catch (RuleException e) {
164: throw new RuntimeRuleException(e);
165: } catch (Exception e) {
166: throw new RuntimeRuleException(e.getMessage());
167: }
168: }
169:
170: public void executeInsertRule(PersistentObject persistentObject)
171: throws Exception {
172: executeConvertorRule(persistentObject);
173: executeInsertValidatorRule(persistentObject);
174: }
175:
176: public void beforeUpdate(PersistentObject persistentObject) {
177: try {
178: executeUpdateRule(persistentObject);
179: } catch (RuntimeRuleException e) {
180: throw e;
181: } catch (RuleException e) {
182: throw new RuntimeRuleException(e);
183: } catch (Exception e) {
184: throw new RuntimeRuleException(e.getMessage());
185: }
186: }
187:
188: public void executeUpdateRule(PersistentObject persistentObject)
189: throws Exception {
190: executeConvertorRule(persistentObject);
191: executeUpdateValidatorRule(persistentObject);
192: }
193:
194: protected void executeConvertorRule(
195: PersistentObject persistentObject) throws Exception {
196: getRecordConvertor().executeRule(persistentObject);
197: }
198:
199: protected void executeInsertValidatorRule(
200: PersistentObject persistentObject) throws Exception {
201: getRecordInsertValidator().executeRule(persistentObject);
202: }
203:
204: protected void executeUpdateValidatorRule(
205: PersistentObject persistentObject) throws Exception {
206: getRecordUpdateValidator().executeRule(persistentObject);
207: }
208:
209: public FieldValidator getFieldValidator() {
210: return recordInsertValidator;
211: }
212:
213: public FieldConvertor getFieldConvertor() {
214: return recordConvertor;
215: }
216:
217: public PersistentObject getPersistentObject() {
218: return PERSISTENT;
219: }
220:
221: protected RecordValidator getRecordInsertValidator() {
222: return recordInsertValidator;
223: }
224:
225: protected RecordValidator getRecordUpdateValidator() {
226: return recordUpdateValidator;
227: }
228:
229: protected RecordConvertor getRecordConvertor() {
230: return recordConvertor;
231: }
232:
233: public Object clone() throws CloneNotSupportedException {
234: CustomerOrderPoCtl ctl = (CustomerOrderPoCtl) super .clone();
235: ctl.recordConvertor = (RecordConvertor) getRecordConvertor()
236: .clone();
237: ctl.recordInsertValidator = (RecordValidator) getRecordInsertValidator()
238: .clone();
239: ctl.recordUpdateValidator = (RecordValidator) getRecordUpdateValidator()
240: .clone();
241: return ctl;
242: }
243: }
|