LCO Validator

From ADempiere ERP Wiki

Jump to: navigation, search

Contents

Background

(This is an exposition of a pretty good ModelValidator which originates from Jorg Janke's Compiere but much attended to by our community experts.)

Call Hierarchy

  • Firstly we look at the java class calling hierarchy that leads to such a Validator.
  • In Eclipse when we do that for one of its methods we get:

Image:ModelValidatorHierarchy.gif

  • Note at the bottom which is truncated, it is actually a long list of Model activity.
  • Such as Document Actions (M<Document>) which are closeIt(), completeIt(), prepareIt(), reverseCorrectIt(), voidIt(), reActivateIt().
  • And in Persistence Object (PO) activity which are save(), saveFinish(boolean,boolean) and delete().
  • It is also called during Accounts Posting as in org.compiere.acct.Doc.post(boolean,boolean).
  • And in a few other distinctive places:
    • org.compiere.apps.Dialog.createSupportEmail(,,),
    • org.compiere.util.Login.loadPreferences(,,,),
    • org.compiere.util.Login.validateLogin(KeyNamePair),
    • org.compiere.util.Ini.saveProperties(),

Allowing the Interception

  • So you can see that the LCO_Validator class is called in an AOP (Aspect Oriented Programming) manner where its methods can intercept during any of the above Model or PO or callings.
  • A code example that calls from a Model class is:

Image:ModelCallValidator.gif

Intercepting Methods

  • Now the registered (see ModelValidator) methods will come into play and the event stated will be activated in the LCO_Validator.
  • They are ModelChange(PO, type) and DocValidate(PO, type).
  • For example:

Image:ModelChange.gif

See Also

Personal tools