public class DictionaryValidationServiceImpl extends Object implements DictionaryValidationService
Modifier and Type | Field and Description |
---|---|
protected BusinessObjectService |
businessObjectService |
protected DataDictionaryService |
dataDictionaryService |
protected DocumentDictionaryService |
documentDictionaryService |
protected PersistenceService |
persistenceService |
protected PersistenceStructureService |
persistenceStructureService |
static String |
VALIDATE_METHOD
Constant defines a validation method for an attribute value.
|
Constructor and Description |
---|
DictionaryValidationServiceImpl() |
Modifier and Type | Method and Description |
---|---|
List<CollectionConstraintProcessor> |
getCollectionConstraintProcessors()
gets the list of
CollectionConstraintProcessor |
List<ConstraintProvider> |
getConstraintProviders()
gets the list of
ConstraintProvider s |
DataDictionaryService |
getDataDictionaryService()
gets the
DataDictionaryService |
DocumentDictionaryService |
getDocumentDictionaryService()
gets the locally saved instance of @{link DocumentDictionaryService}
|
List<ConstraintProcessor> |
getElementConstraintProcessors()
gets the list of element
ConstraintProcessor |
boolean |
isBusinessObjectValid(BusinessObject businessObject)
Encapsulates
{@link #validateBusinessObject(BusinessObject) and returns boolean so one doesn't need to
check the
ErrorMap.Validates the business object primitive attributes against the data dictionary. |
boolean |
isBusinessObjectValid(BusinessObject businessObject,
String prefix)
Encapsulates
{@link #validateBusinessObject(BusinessObject) and returns boolean so one doesn't need to
check the
ErrorMap.Validates the business object primitive attributes against the data dictionary. |
protected Set<BusinessObject> |
newIdentitySet()
creates a new IdentitySet.
|
protected void |
processCollectionConstraints(DictionaryValidationResult result,
Collection<?> collection,
Constrainable definition,
AttributeValueReader attributeValueReader,
boolean doOptionalProcessing,
String validationState,
StateMapping stateMapping)
process constraints for the provided collection using the collection constraint processors
|
protected void |
processElementConstraints(DictionaryValidationResult result,
Object value,
Constrainable definition,
AttributeValueReader attributeValueReader,
boolean doOptionalProcessing,
String validationState,
StateMapping stateMapping)
process constraints for the provided value using the element constraint processors
|
void |
setBusinessObjectService(BusinessObjectService businessObjectService)
Sets the
BusinessObjectService attribute value |
void |
setCollectionConstraintProcessors(List<CollectionConstraintProcessor> collectionConstraintProcessors)
sets the list of
CollectionConstraintProcessor |
void |
setConstraintProviders(List<ConstraintProvider> constraintProviders)
sets a list of
ConstraintProvider |
void |
setDataDictionaryService(DataDictionaryService dataDictionaryService)
sets the
DataDictionaryService |
void |
setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService)
sets the
DocumentDictionaryService |
void |
setElementConstraintProcessors(List<ConstraintProcessor> elementConstraintProcessors)
sets the list of
ConstraintProcessor |
void |
setPersistenceService(PersistenceService persistenceService)
Sets the
PersistenceService attribute value |
void |
setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
sets the @{PersistenceStructureService}
|
DictionaryValidationResult |
validate(AttributeValueReader valueReader,
boolean doOptionalProcessing,
String validationState,
StateMapping stateMapping)
Validates using the defined AttributeValueReader (which allows access the object being validated) against
the validationState and stateMapping (if specified).
|
DictionaryValidationResult |
validate(Object object)
Validates an object using its class name as the entry name to look up its metadata in the dictionary.
|
DictionaryValidationResult |
validate(Object object,
String entryName,
DataDictionaryEntry entry,
boolean doOptionalProcessing)
Same as {@link DictionaryValidationService#validate(Object, String, String, boolean) except that it provides an
explicit
data dictionary
entry to use for the purpose of validation.
|
DictionaryValidationResult |
validate(Object object,
String entryName,
String attributeName,
boolean doOptionalProcessing)
Validate an object with the passed in dictionary entryName and the specific attribute to be evaluated
|
DictionaryValidationResult |
validateAgainstNextState(Object object)
Validates the object agains the next state (or current state if there is no next state).
|
DictionaryValidationResult |
validateAgainstState(Object object,
String validationState)
Validates the object against the state specified.
|
protected void |
validateAttribute(DictionaryValidationResult result,
AttributeValueReader attributeValueReader,
boolean checkIfRequired,
String validationState,
StateMapping stateMapping)
validates an attribute
|
protected void |
validateAttribute(DictionaryValidationResult result,
Constrainable definition,
AttributeValueReader attributeValueReader,
boolean checkIfRequired,
String validationState,
StateMapping stateMapping)
Validates the attribute specified by definition
|
void |
validateBusinessObject(BusinessObject businessObject)
Validates the business object primitive attributes against the data dictionary.
|
void |
validateBusinessObject(BusinessObject businessObject,
boolean validateRequired)
Validates the business object primitive attributes against the data dictionary.
|
protected void |
validateBusinessObjectsFromDescriptors(Object object,
PropertyDescriptor[] propertyDescriptors,
int depth)
iterates through the property descriptors looking for business objects or lists of business objects.
|
void |
validateBusinessObjectsRecursively(BusinessObject businessObject,
int depth) |
boolean |
validateDefaultExistenceChecks(BusinessObject bo)
This method does an existence check against all references of a BusinessObject as defined in the
MaintenanceDocument.xml file
for that business object.
|
boolean |
validateDefaultExistenceChecksForNewCollectionItem(BusinessObject bo,
BusinessObject newCollectionItem,
String collectionName)
Does an existence check against all references configured as a default existence check in the maintenance
document data dictionary file for the given business object
Appropriate errors will also be placed in the GlobalVariables.ErrorMap.
|
boolean |
validateDefaultExistenceChecksForNewCollectionItem(TransactionalDocument document,
BusinessObject newCollectionItem,
String collectionName)
This method does an existence check against all references of a transactionalDocument
Appropriate errors will also be placed in the GlobalVariables.ErrorMap.
|
boolean |
validateDefaultExistenceChecksForTransDoc(TransactionalDocument document)
This method does an existence check against all references of a transactionalDocument
Appropriate errors will also be placed in the GlobalVariables.ErrorMap.
|
void |
validateDocument(Document document)
Validates the contents of a document (i.e.
|
void |
validateDocumentAndUpdatableReferencesRecursively(Document document,
int maxDepth,
boolean validateRequired)
Validates the contents of a document and recursively validates any of its updatable references
|
void |
validateDocumentAndUpdatableReferencesRecursively(Document document,
int maxDepth,
boolean validateRequired,
boolean chompLastLetterSFromCollectionName)
Validates the contents of a document and recursively validates any of its updatable references
|
void |
validateDocumentAttribute(Document document,
String attributeName,
String errorPrefix)
Validates the specified attribute of the given document against the data dictionary.
|
protected void |
validateObject(DictionaryValidationResult result,
AttributeValueReader attributeValueReader,
boolean doOptionalProcessing,
boolean processAttributes,
String validationState,
StateMapping stateMapping)
validates an object and its attributes recursively
|
void |
validatePrimitiveFromDescriptor(String entryName,
Object object,
PropertyDescriptor propertyDescriptor,
String errorPrefix,
boolean validateRequired)
Deprecated.
since 1.1
|
boolean |
validateReferenceExists(BusinessObject bo,
ReferenceDefinition reference)
This method examines the populated BusinessObject bo instance passed in for a member named by the referenceName.
|
boolean |
validateReferenceExists(BusinessObject bo,
String referenceName)
This method examines the populated BusinessObject bo instance passed in for a member named by the referenceName.
|
boolean |
validateReferenceExistsAndIsActive(BusinessObject bo,
ReferenceDefinition reference)
validateReferenceExistsAndIsActive intelligently tests the designated reference on the bo for both existence and
active status, where
appropriate
|
boolean |
validateReferenceExistsAndIsActive(BusinessObject bo,
String referenceName,
String attributeToHighlightOnFail,
String displayFieldName)
This method intelligently tests the designated reference on the bo for both existence and active status, where
appropriate.
|
boolean |
validateReferenceIsActive(BusinessObject bo,
ReferenceDefinition reference)
This method retrieves the reference from the DB, and then tests whether the object is active.
|
boolean |
validateReferenceIsActive(BusinessObject bo,
String referenceName)
This method retrieves the reference from the DB, and then tests whether the object is active.
|
protected void |
validateUpdatabableReferencesRecursively(BusinessObject businessObject,
int maxDepth,
boolean validateRequired,
boolean chompLastLetterSFromCollectionName,
Set<BusinessObject> processedBOs) |
public static final String VALIDATE_METHOD
Value is "validate"
protected DataDictionaryService dataDictionaryService
protected BusinessObjectService businessObjectService
protected PersistenceService persistenceService
protected DocumentDictionaryService documentDictionaryService
protected PersistenceStructureService persistenceStructureService
public DictionaryValidationServiceImpl()
protected final Set<BusinessObject> newIdentitySet()
public DictionaryValidationResult validate(Object object)
DictionaryValidationService
validate
in interface DictionaryValidationService
object
- - an object to validateDictionaryValidationService.validate(java.lang.Object)
public DictionaryValidationResult validate(Object object, String entryName, String attributeName, boolean doOptionalProcessing)
DictionaryValidationService
validate
in interface DictionaryValidationService
object
- - an object to validateentryName
- - the dictionary entry name to look up the metadata associated with this objectattributeName
- - the name of the attribute (field) on the object that should be validateddoOptionalProcessing
- true if the validation should do optional validation (e.g. to check if empty values
are required or not), false otherwiseDictionaryValidationService.validate(java.lang.Object, java.lang.String,
java.lang.String, boolean)
public DictionaryValidationResult validateAgainstNextState(Object object)
DictionaryValidationService
When no stateMapping exists on the DataDictionaryEntry that applies for this object, validation is considered stateless and all constraints are processed regardless of their states attribute.
validateAgainstNextState
in interface DictionaryValidationService
DictionaryValidationService.validateAgainstNextState(Object)
public DictionaryValidationResult validateAgainstState(Object object, String validationState)
DictionaryValidationService
Important note: Alternatively the state can be changed on the object itself and another validation method can be used instead of this one (in practice, you'd revert the state on the object if validation returns errors).
validateAgainstState
in interface DictionaryValidationService
DictionaryValidationService.validateAgainstState(Object, String)
public DictionaryValidationResult validate(Object object, String entryName, DataDictionaryEntry entry, boolean doOptionalProcessing)
DictionaryValidationService
validate
in interface DictionaryValidationService
object
- - an object to validateentryName
- - the dictionary entry name to use in association with error look upsentry
- - the dictionary entry to use for validationdoOptionalProcessing
- true if the validation should do optional validation (e.g. to check if empty values
are required or not), false otherwiseDictionaryValidationService.validate(Object, String, DataDictionaryEntry, boolean)
public void validateDocument(Document document)
DictionaryValidationService
validateDocument
in interface DictionaryValidationService
document
- - document to validateDictionaryValidationService.validateDocument(org.kuali.rice.krad.document.Document)
public void validateDocumentAttribute(Document document, String attributeName, String errorPrefix)
DictionaryValidationService
public void validateDocumentAndUpdatableReferencesRecursively(Document document, int maxDepth, boolean validateRequired)
DictionaryValidationService
validateDocumentAndUpdatableReferencesRecursively
in interface DictionaryValidationService
document
- the documentmaxDepth
- the maximum numbers of levels to recursevalidateRequired
- whether to validate whether a field is required and is currently blankDictionaryValidationService.validateDocumentAndUpdatableReferencesRecursively(org.kuali.rice.krad.document.Document,
int, boolean)
public void validateDocumentAndUpdatableReferencesRecursively(Document document, int maxDepth, boolean validateRequired, boolean chompLastLetterSFromCollectionName)
DictionaryValidationService
validateDocumentAndUpdatableReferencesRecursively
in interface DictionaryValidationService
document
- the documentmaxDepth
- the maximum numbers of levels to recursevalidateRequired
- whether to validate whether a field is required and is currently blankchompLastLetterSFromCollectionName
- if true, the error path for any collections encountered will have the
last "s" removed from the collection name if it ends
with the letter "s". If false, this method acts like DictionaryValidationService.validateDocumentAndUpdatableReferencesRecursively(Document,
int, boolean)
DictionaryValidationService.validateDocumentAndUpdatableReferencesRecursively(org.kuali.rice.krad.document.Document,
int, boolean, boolean)
protected void validateUpdatabableReferencesRecursively(BusinessObject businessObject, int maxDepth, boolean validateRequired, boolean chompLastLetterSFromCollectionName, Set<BusinessObject> processedBOs)
public boolean isBusinessObjectValid(BusinessObject businessObject)
DictionaryValidationService
{@link #validateBusinessObject(BusinessObject) and returns boolean so one doesn't need to
check the
ErrorMap.Validates the business object primitive attributes against the data dictionary. Adds errors to the map
as they are
encountered.
Makes no error path adjustments
isBusinessObjectValid
in interface DictionaryValidationService
businessObject
- - business object to validateDictionaryValidationService.isBusinessObjectValid(org.kuali.rice.krad.bo.BusinessObject)
public boolean isBusinessObjectValid(BusinessObject businessObject, String prefix)
DictionaryValidationService
{@link #validateBusinessObject(BusinessObject) and returns boolean so one doesn't need to
check the
ErrorMap.Validates the business object primitive attributes against the data dictionary. Adds errors to the map
as they are
encountered.
Makes no error path adjustments
isBusinessObjectValid
in interface DictionaryValidationService
businessObject
- - business object to validateprefix
- - error prefixDictionaryValidationService.isBusinessObjectValid(org.kuali.rice.krad.bo.BusinessObject,
String)
public void validateBusinessObjectsRecursively(BusinessObject businessObject, int depth)
businessObject
- - business object to validatepublic void validateBusinessObject(BusinessObject businessObject)
DictionaryValidationService
validateBusinessObject
in interface DictionaryValidationService
businessObject
- - business object to validateDictionaryValidationService.validateBusinessObject(org.kuali.rice.krad.bo.BusinessObject)
public void validateBusinessObject(BusinessObject businessObject, boolean validateRequired)
DictionaryValidationService
validateBusinessObject
in interface DictionaryValidationService
businessObject
- - business object to validatevalidateRequired
- - whether to execute required field checksDictionaryValidationService.validateBusinessObject(org.kuali.rice.krad.bo.BusinessObject,
boolean)
protected void validateBusinessObjectsFromDescriptors(Object object, PropertyDescriptor[] propertyDescriptors, int depth)
object
- propertyDescriptors
- @Deprecated public void validatePrimitiveFromDescriptor(String entryName, Object object, PropertyDescriptor propertyDescriptor, String errorPrefix, boolean validateRequired)
validatePrimitiveFromDescriptor
in interface DictionaryValidationService
entryName
- object
- propertyDescriptor
- errorPrefix
- public boolean validateReferenceExists(BusinessObject bo, ReferenceDefinition reference)
DictionaryValidationService
validateReferenceExists
in interface DictionaryValidationService
bo
- - The bo whose reference is being tested.reference
- - The ReferenceDefinition to be existence tested.DictionaryValidationService.validateReferenceExists(org.kuali.rice.krad.bo.BusinessObject,
org.kuali.rice.krad.datadictionary.ReferenceDefinition)
public boolean validateReferenceExists(BusinessObject bo, String referenceName)
DictionaryValidationService
validateReferenceExists
in interface DictionaryValidationService
bo
- - The bo whose reference is being tested.referenceName
- - The name of the member to be existence tested.DictionaryValidationService.validateReferenceExists(org.kuali.rice.krad.bo.BusinessObject,
java.lang.String)
public boolean validateReferenceIsActive(BusinessObject bo, ReferenceDefinition reference)
DictionaryValidationService
public boolean validateReferenceIsActive(BusinessObject bo, String referenceName)
DictionaryValidationService
validateReferenceIsActive
in interface DictionaryValidationService
DictionaryValidationService.validateReferenceIsActive(org.kuali.rice.krad.bo.BusinessObject,
String)
public boolean validateReferenceExistsAndIsActive(BusinessObject bo, ReferenceDefinition reference)
DictionaryValidationService
It will not test anything if the foreign-key fields for the given reference aren't filled out with values, and it will not test active status if the reference doesn't exist.
Further, it will only test active status where the correct flag is set.
On failures of either sort, it will put the relevant errors into the GlobalVariables errorMap, and return a false. If there are no failures, or nothing can be tested because the foreign-key fields arent fully filled out, it will return true and add no errors.
This method assumes that you already have the errorPath set exactly as desired, and adds new errors to the errorMap with no prefix, other than what has already been pushed onto the errorMap.
validateReferenceExistsAndIsActive
in interface DictionaryValidationService
bo
- - the BusinessObject instance to be tested.reference
- - the ReferenceDefinition to control the nature of the testing.DictionaryValidationService.validateReferenceExistsAndIsActive(org.kuali.rice.krad.bo.BusinessObject,
org.kuali.rice.krad.datadictionary.ReferenceDefinition)
public boolean validateReferenceExistsAndIsActive(BusinessObject bo, String referenceName, String attributeToHighlightOnFail, String displayFieldName)
DictionaryValidationService
validateReferenceExistsAndIsActive
in interface DictionaryValidationService
bo
- - the BusinessObject instance to be tested.referenceName
- - the member name on the bo to be tested for existence and active-stateattributeToHighlightOnFail
- - the fieldName to highlight with the error message on a failuredisplayFieldName
- - the human-readable display name of the failed field, to go in the error messageDictionaryValidationService.validateReferenceExistsAndIsActive(org.kuali.rice.krad.bo.BusinessObject,
String, String, String)
public boolean validateDefaultExistenceChecks(BusinessObject bo)
DictionaryValidationService
validateDefaultExistenceChecks
in interface DictionaryValidationService
bo
- - BusinessObject instance that should be testedDictionaryValidationService.validateDefaultExistenceChecks(org.kuali.rice.krad.bo.BusinessObject)
public boolean validateDefaultExistenceChecksForNewCollectionItem(BusinessObject bo, BusinessObject newCollectionItem, String collectionName)
DictionaryValidationService
validateDefaultExistenceChecksForNewCollectionItem
in interface DictionaryValidationService
bo
- parent business object instance to retrieve default checks fornewCollectionItem
- new collection line to validatecollectionName
- name of the collection in the parentDictionaryValidationService.validateDefaultExistenceChecksForNewCollectionItem(org.kuali.rice.krad.bo.BusinessObject,
org.kuali.rice.krad.bo.BusinessObject, java.lang.String)
public boolean validateDefaultExistenceChecksForTransDoc(TransactionalDocument document)
DictionaryValidationService
validateDefaultExistenceChecksForTransDoc
in interface DictionaryValidationService
document
- document instance that should be testedDictionaryValidationService.validateDefaultExistenceChecksForTransDoc(org.kuali.rice.krad.document.TransactionalDocument)
public boolean validateDefaultExistenceChecksForNewCollectionItem(TransactionalDocument document, BusinessObject newCollectionItem, String collectionName)
DictionaryValidationService
validateDefaultExistenceChecksForNewCollectionItem
in interface DictionaryValidationService
document
- document instance that should be testednewCollectionItem
- that should be testedcollectionName
- that should be testedDictionaryValidationService.validateDefaultExistenceChecksForNewCollectionItem(org.kuali.rice.krad.document.TransactionalDocument,
org.kuali.rice.krad.bo.BusinessObject, String)
public DictionaryValidationResult validate(AttributeValueReader valueReader, boolean doOptionalProcessing, String validationState, StateMapping stateMapping)
If state information is null, validates the constraints as stateless (ie all constraints apply regardless of their states attribute).
validate
in interface DictionaryValidationService
valueReader
- - an object to validatedoOptionalProcessing
- true if the validation should do optional validation (e.g. to check if empty values
are required or not), false otherwisevalidationState
- stateMapping
- protected void processElementConstraints(DictionaryValidationResult result, Object value, Constrainable definition, AttributeValueReader attributeValueReader, boolean doOptionalProcessing, String validationState, StateMapping stateMapping)
result
- - used to store the validation resultsvalue
- - the object on which constraints are to be processed - the value of a complex attributedefinition
- - a Data Dictionary definition e.g. ComplexAttributeDefinition
attributeValueReader
- - a class that encapsulate access to both dictionary metadata and object field
valuesdoOptionalProcessing
- - true if the validation should do optional validation, false otherwiseprotected void processCollectionConstraints(DictionaryValidationResult result, Collection<?> collection, Constrainable definition, AttributeValueReader attributeValueReader, boolean doOptionalProcessing, String validationState, StateMapping stateMapping)
result
- - used to store the validation resultscollection
- - the object on which constraints are to be processed - a collectiondefinition
- - a Data Dictionary definition e.g. CollectionDefinition
attributeValueReader
- - a class that encapsulate access to both dictionary metadata and object field
valuesdoOptionalProcessing
- - true if the validation should do optional validation, false otherwiseprotected void validateAttribute(DictionaryValidationResult result, AttributeValueReader attributeValueReader, boolean checkIfRequired, String validationState, StateMapping stateMapping) throws AttributeValidationException
result
- - used to store the validation resultsattributeValueReader
- - a class that encapsulate access to both dictionary metadata and object field
valuescheckIfRequired
- - check if empty values are required or notAttributeValidationException
protected void validateAttribute(DictionaryValidationResult result, Constrainable definition, AttributeValueReader attributeValueReader, boolean checkIfRequired, String validationState, StateMapping stateMapping) throws AttributeValidationException
definition
- - the constrainable attribute definition of a specific attribute nameAttributeValidationException
for the other parameters
protected void validateObject(DictionaryValidationResult result, AttributeValueReader attributeValueReader, boolean doOptionalProcessing, boolean processAttributes, String validationState, StateMapping stateMapping) throws AttributeValidationException
result
- - used to store the validation resultsattributeValueReader
- - a class that encapsulate access to both dictionary metadata and object field
valuesdoOptionalProcessing
- - true if the validation should do optional validation, false otherwiseprocessAttributes
- - if true process all attribute definitions, skip if falseAttributeValidationException
public DataDictionaryService getDataDictionaryService()
DataDictionaryService
public void setDataDictionaryService(DataDictionaryService dataDictionaryService)
DataDictionaryService
dataDictionaryService
- The dataDictionaryService to setpublic void setBusinessObjectService(BusinessObjectService businessObjectService)
BusinessObjectService
attribute valuebusinessObjectService
- - the businessObjectService to setpublic void setPersistenceService(PersistenceService persistenceService)
PersistenceService
attribute valuepersistenceService
- The persistenceService to setpublic void setPersistenceStructureService(PersistenceStructureService persistenceStructureService)
persistenceStructureService
- - the PersistenceStructureService
to setpublic List<CollectionConstraintProcessor> getCollectionConstraintProcessors()
CollectionConstraintProcessor
Collection constraint processors are classes that determine if a feature of a collection of objects satisfies some constraint
public void setCollectionConstraintProcessors(List<CollectionConstraintProcessor> collectionConstraintProcessors)
CollectionConstraintProcessor
collectionConstraintProcessors
- the collectionConstraintProcessors to setpublic List<ConstraintProvider> getConstraintProviders()
ConstraintProvider
s
Constraint providers are classes that map specific constraint types to a constraint resolver, which takes a constrainable definition
public void setConstraintProviders(List<ConstraintProvider> constraintProviders)
ConstraintProvider
constraintProviders
- the constraintProviders to setpublic List<ConstraintProcessor> getElementConstraintProcessors()
ConstraintProcessor
Element constraint processors are classes that determine if a passed value is valid for a specific constraint at the individual object or object attribute level
public void setElementConstraintProcessors(List<ConstraintProcessor> elementConstraintProcessors)
ConstraintProcessor
elementConstraintProcessors
- the elementConstraintProcessors to setpublic DocumentDictionaryService getDocumentDictionaryService()
If the instance in this class has not be set, retrieve it using
KRADServiceLocatorWeb.getDocumentDictionaryService()
and save locally
DocumentDictionaryService
public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService)
DocumentDictionaryService
documentDictionaryService
- - the DocumentDictionaryService
to setCopyright © 2005-2015 The Kuali Foundation. All Rights Reserved.