New sample of GardenWorld MyValidator to work correctly with new events

This commit is contained in:
Carlos Ruiz 2007-02-27 05:46:34 +00:00
parent ada57fd26c
commit 501eca17d5
1 changed files with 19 additions and 12 deletions

View File

@ -57,9 +57,12 @@ public class MyValidator implements ModelValidator
log.info(client.toString()); log.info(client.toString());
// We want to be informed when C_Order is created/changed // We want to be informed when C_Order is created/changed
engine.addModelChange("C_Order", this); engine.addModelChange(MOrder.Table_Name, this);
// We want to validate Order before preparing // We want to validate Order before preparing
engine.addDocValidate("C_Order", this); engine.addDocValidate(MOrder.Table_Name, this);
engine.addDocValidate(MInOut.Table_Name, this);
engine.addDocValidate(MPayment.Table_Name, this);
engine.addDocValidate(MCash.Table_Name, this);
} // initialize } // initialize
/** /**
@ -92,20 +95,24 @@ public class MyValidator implements ModelValidator
*/ */
public String docValidate (PO po, int timing) public String docValidate (PO po, int timing)
{ {
log.info(po.get_TableName() + " Timing: "+timing);
// Ignore all after Complete events // Ignore all after Complete events
if (timing == TIMING_AFTER_COMPLETE) if (timing == TIMING_AFTER_COMPLETE)
return null; return null;
// TIMING_BEFORE_PREPARE
if (po.get_TableName().equals(MOrder.Table_Name)) if (timing == TIMING_BEFORE_PREPARE) {
{ if (po.get_TableName().equals(MOrder.Table_Name))
/** Order Discount Example * {
MOrder order = (MOrder)po; /** Order Discount Example *
String error = orderDiscount(order); MOrder order = (MOrder)po;
if (error != null) String error = orderDiscount(order);
return error; if (error != null)
/** Order Discount Example */ return error;
log.info(po.toString()); /** Order Discount Example */
log.info(po.toString());
}
} }
return null; return null;
} // docValidate } // docValidate