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());
// 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
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
/**
@ -92,10 +95,12 @@ public class MyValidator implements ModelValidator
*/
public String docValidate (PO po, int timing)
{
log.info(po.get_TableName() + " Timing: "+timing);
// Ignore all after Complete events
if (timing == TIMING_AFTER_COMPLETE)
return null;
// TIMING_BEFORE_PREPARE
if (timing == TIMING_BEFORE_PREPARE) {
if (po.get_TableName().equals(MOrder.Table_Name))
{
/** Order Discount Example *
@ -106,6 +111,8 @@ public class MyValidator implements ModelValidator
/** Order Discount Example */
log.info(po.toString());
}
}
return null;
} // docValidate