org.kuali.kfs.sys.document.validation
Class BranchingValidation

java.lang.Object
  extended by org.kuali.kfs.sys.document.validation.ParameterizedValidation
      extended by org.kuali.kfs.sys.document.validation.BranchingValidation
All Implemented Interfaces:
Validation
Direct Known Subclasses:
AccountingLineBranchingValidation, CustomerInvoiceDiscountRelatedBranchingValidation, CustomerInvoiceReceivableBranchingValidation, CustomerInvoiceWriteoffGLPEGenerationBranchingValidation, PaymentRequestAccountingLineAccessibleBranchingValidation, PaymentRequestCalculationBranchingValidation, PurchaseOrderAmendmentProcessAccountValidation, PurchaseOrderRequiresAccountValidationBranchingValidation, PurchasingAccountsPayableExtendedPriceNonZeroBranchingValidation, PurchasingAccountsPayableFullDocumentEntryCompletedBranchingValidation, PurchasingAccountsPayableItemConsideredEnteredBranchingValidation, PurchasingAccountsPayableLineItemIndicatorBranchingValidation, PurchasingAccountsPayableObjectCodeOverrideBranchingValidation, PurchasingAccountsPayableRequiresAccountValidationBranchingValidation, RequisitionCommodityCodeBranchingValidation, RequisitionRequiresAccountValidationBranchingValidation

public abstract class BranchingValidation
extends ParameterizedValidation
implements Validation

An abstract class that creates an easy way to branch between validations. Basically, extenders set a branch map - a map where the key is the name of the branch and the value is the validation to perform to check on that branch. Extenders also implement the determineBranch method, which returns the name of the branch to validate against; if null is returned, then no validation will occur.


Field Summary
protected  Map<String,Validation> branchMap
           
protected  List<ValidationFieldConvertible> parameterProperties
           
protected  boolean shouldQuitOnFail
           
 
Constructor Summary
BranchingValidation()
           
 
Method Summary
protected abstract  String determineBranch(AttributedDocumentEvent event)
          Determines which branch, if any, within the branchMap should be used as the validation to take.
 Map<String,Validation> getBranchMap()
          Gets the branchMap attribute.
 List<ValidationFieldConvertible> getParameterProperties()
          Note: these parameter properties only help determine what branching should take place; these properties will not affect in anyway the branch children
 void setBranchMap(Map<String,Validation> branchMap)
          Sets the branchMap attribute value.
 void setParameterProperties(List<ValidationFieldConvertible> parameterProperties)
          Sets the parameterProperties attribute value.
 void setShouldQuitOnFail(boolean shouldQuitOnFail)
          Sets the shouldQuitOnFail attribute value.
 boolean shouldQuitOnFail()
          Returns whether the validation process should quit on the failure of this validation
 boolean stageValidation(AttributedDocumentEvent event)
          Stages the execution of a Validation
 boolean validate(AttributedDocumentEvent event)
          Using the branch name returned by determineBranch(), validates the event against the corresponding branch in the branch map.
 
Methods inherited from class org.kuali.kfs.sys.document.validation.ParameterizedValidation
populateParameterFromEvent, populateParametersFromEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

branchMap

protected Map<String,Validation> branchMap

parameterProperties

protected List<ValidationFieldConvertible> parameterProperties

shouldQuitOnFail

protected boolean shouldQuitOnFail
Constructor Detail

BranchingValidation

public BranchingValidation()
Method Detail

determineBranch

protected abstract String determineBranch(AttributedDocumentEvent event)
Determines which branch, if any, within the branchMap should be used as the validation to take.

Parameters:
event - the event which triggered this validation
Returns:
the name of the branch to take, or a null or empty string to not take any branch and simply pass validation as true

getParameterProperties

public List<ValidationFieldConvertible> getParameterProperties()
Note: these parameter properties only help determine what branching should take place; these properties will not affect in anyway the branch children

Overrides:
getParameterProperties in class ParameterizedValidation
Returns:
Returns the parameterProperties.
See Also:
org.kuali.kfs.sys.document.validation.Validation#getParameterProperties()

setParameterProperties

public void setParameterProperties(List<ValidationFieldConvertible> parameterProperties)
Sets the parameterProperties attribute value.

Overrides:
setParameterProperties in class ParameterizedValidation
Parameters:
parameterProperties - The parameterProperties to set.

shouldQuitOnFail

public boolean shouldQuitOnFail()
Description copied from interface: Validation
Returns whether the validation process should quit on the failure of this validation

Specified by:
shouldQuitOnFail in interface Validation
Returns:
true if the validation process should quit, false otherwise
See Also:
Validation.shouldQuitOnFail()

setShouldQuitOnFail

public void setShouldQuitOnFail(boolean shouldQuitOnFail)
Sets the shouldQuitOnFail attribute value.

Parameters:
shouldQuitOnFail - The shouldQuitOnFail to set.

stageValidation

public boolean stageValidation(AttributedDocumentEvent event)
Description copied from interface: Validation
Stages the execution of a Validation

Specified by:
stageValidation in interface Validation
Parameters:
event - the event the validate
Returns:
the boolean result of the staged Validation
See Also:
Validation.stageValidation(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)

validate

public boolean validate(AttributedDocumentEvent event)
Using the branch name returned by determineBranch(), validates the event against the corresponding branch in the branch map. If a null or empty string is returned from determineBrach(), this method simply returns true; if there is no validation in the branchMap for the given name, an IllegalStateException is thrown.

Specified by:
validate in interface Validation
Returns:
true if validation should continue, false otherwise
See Also:
Validation.validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)

getBranchMap

public Map<String,Validation> getBranchMap()
Gets the branchMap attribute.

Returns:
Returns the branchMap.

setBranchMap

public void setBranchMap(Map<String,Validation> branchMap)
Sets the branchMap attribute value.

Parameters:
branchMap - The branchMap to set.


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.