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 OrderItemPoCtl extends AbstractLifeCycleController
014: implements PersistentRule {
015:
016: public static final PersistentObject PERSISTENT = new OrderItemPO();
017:
018: protected RecordValidator recordInsertValidator = new RecordValidatorImpl(
019: PERSISTENT, true);
020:
021: public OrderItemPoCtl(String cacheName) {
022: super (cacheName);
023: }
024:
025: public OrderItemPoCtl(
026: com.completex.objective.components.ocache.OdalCache cache) {
027: super (cache);
028: }
029:
030: protected void initInsertValidator() {
031: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
032: initInsertValidatorOrderItemId();
033: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
034: initInsertValidatorOrderId();
035: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
036: initInsertValidatorProductId();
037: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
038: initInsertValidatorQuantity();
039: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
040: initInsertValidatorState();
041: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
042: initInsertValidatorLastUpdated();
043: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
044: initInsertValidatorCreationDate();
045: }
046:
047: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
048: protected void initInsertValidatorOrderItemId() {
049: //getRecordInsertValidator().addFieldValidator(OrderItemPO.ICOL_ORDER_ITEM_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
050: }
051:
052: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
053: protected void initInsertValidatorOrderId() {
054: getRecordInsertValidator()
055: .addFieldValidator(OrderItemPO.ICOL_ORDER_ID,
056: new RequiredFieldValidator());
057: //getRecordInsertValidator().addFieldValidator(OrderItemPO.ICOL_ORDER_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
058: }
059:
060: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
061: protected void initInsertValidatorProductId() {
062: //getRecordInsertValidator().addFieldValidator(OrderItemPO.ICOL_PRODUCT_ID, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
063: }
064:
065: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
066: protected void initInsertValidatorQuantity() {
067: //getRecordInsertValidator().addFieldValidator(OrderItemPO.ICOL_QUANTITY, new NumberSizeFieldValidator(new BigDecimal("-"), new BigDecimal("")));
068: }
069:
070: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
071: protected void initInsertValidatorState() {
072: getRecordInsertValidator().addFieldValidator(
073: OrderItemPO.ICOL_STATE, new RequiredFieldValidator());
074: getRecordInsertValidator().addFieldValidator(
075: OrderItemPO.ICOL_STATE,
076: new StringSizeFieldValidator(0, 40));
077: }
078:
079: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
080: protected void initInsertValidatorLastUpdated() {
081: }
082:
083: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
084: protected void initInsertValidatorCreationDate() {
085: }
086:
087: protected RecordValidator recordUpdateValidator = new RecordValidatorImpl(
088: PERSISTENT, true);
089:
090: protected void initUpdateValidator() {
091: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
092: initUpdateValidatorOrderItemId();
093: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
094: initUpdateValidatorOrderId();
095: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
096: initUpdateValidatorProductId();
097: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
098: initUpdateValidatorQuantity();
099: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
100: initUpdateValidatorState();
101: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
102: initUpdateValidatorLastUpdated();
103: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
104: initUpdateValidatorCreationDate();
105: }
106:
107: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
108: protected void initUpdateValidatorOrderItemId() {
109: }
110:
111: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
112: protected void initUpdateValidatorOrderId() {
113: getRecordUpdateValidator().addFieldValidator(
114: OrderItemPO.ICOL_ORDER_ID, new NotNullFieldValidator());
115: }
116:
117: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
118: protected void initUpdateValidatorProductId() {
119: }
120:
121: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
122: protected void initUpdateValidatorQuantity() {
123: }
124:
125: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
126: protected void initUpdateValidatorState() {
127: getRecordUpdateValidator().addFieldValidator(
128: OrderItemPO.ICOL_STATE, new NotNullFieldValidator());
129: }
130:
131: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
132: protected void initUpdateValidatorLastUpdated() {
133: }
134:
135: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
136: protected void initUpdateValidatorCreationDate() {
137: }
138:
139: protected RecordConvertor recordConvertor = new RecordConvertorImpl(
140: PERSISTENT);
141:
142: protected void initConvertor() {
143: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
144: initConvertorOrderItemId();
145: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
146: initConvertorOrderId();
147: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
148: initConvertorProductId();
149: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
150: initConvertorQuantity();
151: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
152: initConvertorState();
153: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
154: initConvertorLastUpdated();
155: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
156: initConvertorCreationDate();
157: }
158:
159: /* COLUMN NAME: ORDER_ITEM_ID ; ALIAS NAME: ORDER_ITEM_ID */
160: protected void initConvertorOrderItemId() {
161: }
162:
163: /* COLUMN NAME: ORDER_ID ; ALIAS NAME: ORDER_ID */
164: protected void initConvertorOrderId() {
165: }
166:
167: /* COLUMN NAME: PRODUCT_ID ; ALIAS NAME: PRODUCT_ID */
168: protected void initConvertorProductId() {
169: }
170:
171: /* COLUMN NAME: QUANTITY ; ALIAS NAME: QUANTITY */
172: protected void initConvertorQuantity() {
173: }
174:
175: /* COLUMN NAME: STATE ; ALIAS NAME: STATE */
176: protected void initConvertorState() {
177: // getRecordConvertor().addFieldConvertor(OrderItemPO.ICOL_STATE, new TrimWhiteSpaceFieldConvertor());
178: // getRecordConvertor().addFieldConvertor(OrderItemPO.ICOL_STATE, new UpperCaseFieldConvertor());
179: }
180:
181: /* COLUMN NAME: LAST_UPDATED ; ALIAS NAME: LAST_UPDATED */
182: protected void initConvertorLastUpdated() {
183: }
184:
185: /* COLUMN NAME: CREATION_DATE ; ALIAS NAME: CREATION_DATE */
186: protected void initConvertorCreationDate() {
187: }
188:
189: public OrderItemPoCtl() {
190: init();
191: }
192:
193: public OrderItemPoCtl(Object[] parameters) {
194: super (parameters);
195: }
196:
197: protected void init() {
198: initInsertValidator();
199: initUpdateValidator();
200: initConvertor();
201: }
202:
203: public void beforeInsert(PersistentObject persistentObject) {
204: try {
205: executeInsertRule(persistentObject);
206: } catch (RuntimeRuleException e) {
207: throw e;
208: } catch (RuleException e) {
209: throw new RuntimeRuleException(e);
210: } catch (Exception e) {
211: throw new RuntimeRuleException(e.getMessage());
212: }
213: }
214:
215: public void executeInsertRule(PersistentObject persistentObject)
216: throws Exception {
217: executeConvertorRule(persistentObject);
218: executeInsertValidatorRule(persistentObject);
219: }
220:
221: public void beforeUpdate(PersistentObject persistentObject) {
222: try {
223: executeUpdateRule(persistentObject);
224: } catch (RuntimeRuleException e) {
225: throw e;
226: } catch (RuleException e) {
227: throw new RuntimeRuleException(e);
228: } catch (Exception e) {
229: throw new RuntimeRuleException(e.getMessage());
230: }
231: }
232:
233: public void executeUpdateRule(PersistentObject persistentObject)
234: throws Exception {
235: executeConvertorRule(persistentObject);
236: executeUpdateValidatorRule(persistentObject);
237: }
238:
239: protected void executeConvertorRule(
240: PersistentObject persistentObject) throws Exception {
241: getRecordConvertor().executeRule(persistentObject);
242: }
243:
244: protected void executeInsertValidatorRule(
245: PersistentObject persistentObject) throws Exception {
246: getRecordInsertValidator().executeRule(persistentObject);
247: }
248:
249: protected void executeUpdateValidatorRule(
250: PersistentObject persistentObject) throws Exception {
251: getRecordUpdateValidator().executeRule(persistentObject);
252: }
253:
254: public FieldValidator getFieldValidator() {
255: return recordInsertValidator;
256: }
257:
258: public FieldConvertor getFieldConvertor() {
259: return recordConvertor;
260: }
261:
262: public PersistentObject getPersistentObject() {
263: return PERSISTENT;
264: }
265:
266: protected RecordValidator getRecordInsertValidator() {
267: return recordInsertValidator;
268: }
269:
270: protected RecordValidator getRecordUpdateValidator() {
271: return recordUpdateValidator;
272: }
273:
274: protected RecordConvertor getRecordConvertor() {
275: return recordConvertor;
276: }
277:
278: public Object clone() throws CloneNotSupportedException {
279: OrderItemPoCtl ctl = (OrderItemPoCtl) super .clone();
280: ctl.recordConvertor = (RecordConvertor) getRecordConvertor()
281: .clone();
282: ctl.recordInsertValidator = (RecordValidator) getRecordInsertValidator()
283: .clone();
284: ctl.recordUpdateValidator = (RecordValidator) getRecordUpdateValidator()
285: .clone();
286: return ctl;
287: }
288: }
|