public class DictionaryValidationServiceImpl extends Object implements DictionaryValidationService
| Modifier and Type | Field and Description |
|---|---|
protected DataDictionaryService |
dataDictionaryService |
protected DocumentDictionaryService |
documentDictionaryService |
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
ConstraintProviders |
DataDictionaryService |
getDataDictionaryService()
gets the
DataDictionaryService |
DocumentDictionaryService |
getDocumentDictionaryService()
gets the locally saved instance of @{link DocumentDictionaryService}
|
List<ConstraintProcessor> |
getElementConstraintProcessors()
gets the list of element
ConstraintProcessor |
LegacyDataAdapter |
getLegacyDataAdapter()
Deprecated.
|
boolean |
isBusinessObjectValid(Object businessObject)
Encapsulates
#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(Object businessObject,
String prefix)
Encapsulates
#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<Object> |
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 |
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 |
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
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(Object businessObject)
Validates the business object primitive attributes against the data dictionary.
|
void |
validateBusinessObject(Object 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(Object businessObject,
int depth) |
boolean |
validateDefaultExistenceChecks(Object dataObject)
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(Object dataObject,
Object 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,
Object 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(Object dataObject,
ReferenceDefinition reference)
This method examines the populated BusinessObject bo instance passed in for a member named by the referenceName.
|
boolean |
validateReferenceExists(Object dataObject,
String referenceName)
This method examines the populated BusinessObject bo instance passed in for a member named by the referenceName.
|
boolean |
validateReferenceExistsAndIsActive(Object dataObject,
ReferenceDefinition reference)
validateReferenceExistsAndIsActive intelligently tests the designated reference on the data object for both existence and
active status, where
appropriate
|
boolean |
validateReferenceExistsAndIsActive(Object dataObject,
String referenceName,
String attributeToHighlightOnFail,
String displayFieldName)
This method intelligently tests the designated reference on the data object for both existence and active status, where
appropriate.
|
boolean |
validateReferenceIsActive(Object dataObject,
ReferenceDefinition reference)
This method retrieves the reference from the DB, and then tests whether the object is active.
|
boolean |
validateReferenceIsActive(Object dataObject,
String referenceName)
This method retrieves the reference from the DB, and then tests whether the object is active.
|
protected void |
validateUpdatabableReferencesRecursively(Object businessObject,
int maxDepth,
boolean validateRequired,
boolean chompLastLetterSFromCollectionName,
Set<Object> processedBOs) |
public static final String VALIDATE_METHOD
Value is "validate"
protected DataDictionaryService dataDictionaryService
protected DocumentDictionaryService documentDictionaryService
public DictionaryValidationServiceImpl()
protected final Set<Object> newIdentitySet()
public DictionaryValidationResult validate(Object object)
DictionaryValidationServicevalidate in interface DictionaryValidationServiceobject - - an object to validateDictionaryValidationService.validate(java.lang.Object)public DictionaryValidationResult validate(Object object, String entryName, String attributeName, boolean doOptionalProcessing)
DictionaryValidationServicevalidate in interface DictionaryValidationServiceobject - - 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)
DictionaryValidationServiceWhen 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 DictionaryValidationServiceDictionaryValidationService.validateAgainstNextState(Object)public DictionaryValidationResult validateAgainstState(Object object, String validationState)
DictionaryValidationServiceImportant 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 DictionaryValidationServiceDictionaryValidationService.validateAgainstState(Object, String)public DictionaryValidationResult validate(Object object, String entryName, DataDictionaryEntry entry, boolean doOptionalProcessing)
DictionaryValidationServiceDictionaryValidationService.validate(Object, String, String, boolean) except
that it provides an explicit data dictionary entry to use for the purpose of validation.validate in interface DictionaryValidationServiceobject - - 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)
DictionaryValidationServicevalidateDocument in interface DictionaryValidationServicedocument - - document to validateDictionaryValidationService.validateDocument(org.kuali.rice.krad.document.Document)public void validateDocumentAttribute(Document document, String attributeName, String errorPrefix)
DictionaryValidationServicepublic void validateDocumentAndUpdatableReferencesRecursively(Document document, int maxDepth, boolean validateRequired)
DictionaryValidationServicevalidateDocumentAndUpdatableReferencesRecursively in interface DictionaryValidationServicedocument - 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)
DictionaryValidationServicevalidateDocumentAndUpdatableReferencesRecursively in interface DictionaryValidationServicedocument - 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(Object businessObject, int maxDepth, boolean validateRequired, boolean chompLastLetterSFromCollectionName, Set<Object> processedBOs)
public boolean isBusinessObjectValid(Object businessObject)
DictionaryValidationService#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.isBusinessObjectValid in interface DictionaryValidationServicebusinessObject - - business object to validateorg.kuali.rice.krad.service.DictionaryValidationService#isBusinessObjectValid(org.kuali.rice.krad.bo.BusinessObject)public boolean isBusinessObjectValid(Object businessObject, String prefix)
DictionaryValidationService#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.isBusinessObjectValid in interface DictionaryValidationServicebusinessObject - - business object to validateprefix - - error prefixorg.kuali.rice.krad.service.DictionaryValidationService#isBusinessObjectValid(org.kuali.rice.krad.bo.BusinessObject,
String)public void validateBusinessObjectsRecursively(Object businessObject, int depth)
businessObject - - business object to validatepublic void validateBusinessObject(Object businessObject)
DictionaryValidationServicevalidateBusinessObject in interface DictionaryValidationServicebusinessObject - - business object to validateorg.kuali.rice.krad.service.DictionaryValidationService#validateBusinessObject(org.kuali.rice.krad.bo.BusinessObject)public void validateBusinessObject(Object businessObject, boolean validateRequired)
DictionaryValidationServicevalidateBusinessObject in interface DictionaryValidationServicebusinessObject - - business object to validatevalidateRequired - - whether to execute required field checksorg.kuali.rice.krad.service.DictionaryValidationService#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 DictionaryValidationServiceentryName - object - propertyDescriptor - errorPrefix - public boolean validateReferenceExists(Object dataObject, ReferenceDefinition reference)
DictionaryValidationServicevalidateReferenceExists in interface DictionaryValidationServicedataObject - - the data object whose reference is being tested.reference - - The ReferenceDefinition to be existence tested.DictionaryValidationService.validateReferenceExists(java.lang.Object dataObject,
org.kuali.rice.krad.datadictionary.ReferenceDefinition)public boolean validateReferenceExists(Object dataObject, String referenceName)
DictionaryValidationServicevalidateReferenceExists in interface DictionaryValidationServicedataObject - - the data object whose reference is being tested.referenceName - - The name of the member to be existence tested.DictionaryValidationService.validateReferenceExists(java.lang.Object dataObject,
java.lang.String)public boolean validateReferenceIsActive(Object dataObject, ReferenceDefinition reference)
DictionaryValidationServicevalidateReferenceIsActive in interface DictionaryValidationServiceDictionaryValidationService.validateReferenceIsActive(java.lang.Object
dataObject,
org.kuali.rice.krad.datadictionary.ReferenceDefinition)public boolean validateReferenceIsActive(Object dataObject, String referenceName)
DictionaryValidationServicevalidateReferenceIsActive in interface DictionaryValidationServiceDictionaryValidationService.validateReferenceIsActive(java.lang.Object
dataObject,
String)public boolean validateReferenceExistsAndIsActive(Object dataObject, ReferenceDefinition reference)
DictionaryValidationServiceIt 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 DictionaryValidationServicedataObject - - the data object instance to be tested.reference - - the ReferenceDefinition to control the nature of the testing.DictionaryValidationService.validateReferenceExistsAndIsActive(java.lang.Object
dataObject,
org.kuali.rice.krad.datadictionary.ReferenceDefinition)public boolean validateReferenceExistsAndIsActive(Object dataObject, String referenceName, String attributeToHighlightOnFail, String displayFieldName)
DictionaryValidationServicevalidateReferenceExistsAndIsActive in interface DictionaryValidationServicedataObject - - the BusinessObject instance to be tested.referenceName - - the member name on the data object 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(java.lang.Object
dataObject,
String, String, String)public boolean validateDefaultExistenceChecks(Object dataObject)
DictionaryValidationServicevalidateDefaultExistenceChecks in interface DictionaryValidationServicedataObject - - BusinessObject instance that should be testedDictionaryValidationService.validateDefaultExistenceChecks(java.lang.Object
dataObject)public boolean validateDefaultExistenceChecksForNewCollectionItem(Object dataObject, Object newCollectionItem, String collectionName)
DictionaryValidationServicevalidateDefaultExistenceChecksForNewCollectionItem in interface DictionaryValidationServicedataObject - parent business object instance to retrieve default checks fornewCollectionItem - new collection line to validatecollectionName - name of the collection in the parentDictionaryValidationService.validateDefaultExistenceChecksForNewCollectionItem(java.lang.Object
dataObject,
java.lang.Object newCollectionLine, java.lang.String collectionName)public boolean validateDefaultExistenceChecksForTransDoc(TransactionalDocument document)
DictionaryValidationServicevalidateDefaultExistenceChecksForTransDoc in interface DictionaryValidationServicedocument - document instance that should be testedDictionaryValidationService.validateDefaultExistenceChecksForTransDoc(org.kuali.rice.krad.document.TransactionalDocument)public boolean validateDefaultExistenceChecksForNewCollectionItem(TransactionalDocument document, Object newCollectionItem, String collectionName)
DictionaryValidationServicevalidateDefaultExistenceChecksForNewCollectionItem in interface DictionaryValidationServicedocument - document instance that should be testedcollectionName - that should be testedorg.kuali.rice.krad.service.DictionaryValidationService#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 DictionaryValidationServicevalueReader - - 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. ComplexAttributeDefinitionattributeValueReader - - 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. CollectionDefinitionattributeValueReader - - 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 notAttributeValidationExceptionprotected 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 nameAttributeValidationExceptionprotected 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 falseAttributeValidationExceptionpublic DataDictionaryService getDataDictionaryService()
DataDictionaryServicepublic void setDataDictionaryService(DataDictionaryService dataDictionaryService)
DataDictionaryServicedataDictionaryService - The dataDictionaryService 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)
CollectionConstraintProcessorcollectionConstraintProcessors - the collectionConstraintProcessors to setpublic List<ConstraintProvider> getConstraintProviders()
ConstraintProviders
Constraint providers are classes that map specific constraint types to a constraint resolver, which takes a constrainable definition
public void setConstraintProviders(List<ConstraintProvider> constraintProviders)
ConstraintProviderconstraintProviders - 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)
ConstraintProcessorelementConstraintProcessors - the elementConstraintProcessors to setpublic DocumentDictionaryService getDocumentDictionaryService()
If the instance in this class has not be set, retrieve it using
KRADServiceLocatorWeb.getDocumentDictionaryService() and save locally
DocumentDictionaryServicepublic void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService)
DocumentDictionaryServicedocumentDictionaryService - - the DocumentDictionaryService to set@Deprecated public LegacyDataAdapter getLegacyDataAdapter()
Copyright © 2005–2016 The Kuali Foundation. All rights reserved.