Package com.apgar.common.lib.utils
Class ValidationUtils
java.lang.Object
com.apgar.common.lib.utils.ValidationUtils
Utility class that offers methods for checking validation errors for records across various inputs, including tables, datasets, and
dataspaces.
- Author:
- APGAR Consulting
-
Method Summary
Modifier and TypeMethodDescriptionstatic Set<com.onwbp.adaptation.Adaptation>checkValidationError(com.onwbp.adaptation.Adaptation dataset) Evaluates the validation report of the specifieddatasetand returns the records that contain errors.static Set<com.onwbp.adaptation.Adaptation>checkValidationError(com.onwbp.adaptation.AdaptationHome dataspace, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Evaluates the validation report of the specifieddataspaceand returns the records with validation errors, excluding those with matching errors in the providedinitialErrorsMap.static Set<com.onwbp.adaptation.Adaptation>checkValidationError(com.onwbp.adaptation.Adaptation dataset, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Evaluates the validation report of the specifieddatasetand returns the records with validation errors, excluding those with matching errors in the providedinitialErrorsMap.static Set<com.onwbp.adaptation.Adaptation>checkValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTable) Evaluates the validation report of the tables belonging to theupdatedTablecollection and returns the records that contain errors.static Set<com.onwbp.adaptation.Adaptation>checkValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTableCollection, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Retrieves records with validation errors from the specified tables, excluding those with matching errors in the providedinitialErrorsMap.static <T> Predicate<T>distinctByKeys(Function<? super T, ?>... keyExtractors) Creates aPredicatethat filters elements based on distinct keys extracted using the provided key extractors.getValidationError(com.onwbp.adaptation.Adaptation dataset) Retrieves all records in error along with their validation errors from the inputdataset.getValidationError(com.onwbp.adaptation.AdaptationHome dataspace) Retrieves all records in error along with their validation errors from the inputdataspace.getValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTable) Retrieves all records in error, along with their validation errors, from the tables in theupdatedTablecollection.isValidAdaptations(com.onwbp.adaptation.Adaptation... records) Checks the validation report of the input record(s) and returns those in error, along with their validation errors.
-
Method Details
-
checkValidationError
public static Set<com.onwbp.adaptation.Adaptation> checkValidationError(com.onwbp.adaptation.AdaptationHome dataspace, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Evaluates the validation report of the specifieddataspaceand returns the records with validation errors, excluding those with matching errors in the providedinitialErrorsMap.- Parameters:
dataspace- the dataspace to be checked for validation errorsinitialErrorsMap- a map associating records (using their primary keys) with their corresponding validation items of error severitysession- the authenticated user session- Returns:
- a set of adaptations (records) with validation errors, filtered by
initialErrorsMap - See Also:
-
checkValidationError
public static Set<com.onwbp.adaptation.Adaptation> checkValidationError(com.onwbp.adaptation.Adaptation dataset) Evaluates the validation report of the specifieddatasetand returns the records that contain errors.- Parameters:
dataset- the dataset to be checked for validation errors- Returns:
- a set of adaptations (records) that are in error.
-
checkValidationError
public static Set<com.onwbp.adaptation.Adaptation> checkValidationError(com.onwbp.adaptation.Adaptation dataset, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Evaluates the validation report of the specifieddatasetand returns the records with validation errors, excluding those with matching errors in the providedinitialErrorsMap.- Parameters:
dataset- the dataset to be checked for validation errorsinitialErrorsMap- a map associating records (using their primary keys) with their corresponding validation items of error severitysession- the authenticated user session- Returns:
- a set of adaptations (records) with validation errors, filtered by
initialErrorsMap - See Also:
-
checkValidationError
public static Set<com.onwbp.adaptation.Adaptation> checkValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTable) Evaluates the validation report of the tables belonging to theupdatedTablecollection and returns the records that contain errors.- Parameters:
updatedTable- a collection of tables to be checked for validation errors- Returns:
- a set of adaptations (records) that are in error.
-
getValidationError
public static Map<com.onwbp.adaptation.PrimaryKey,Set<com.orchestranetworks.service.ValidationReportItem>> getValidationError(com.onwbp.adaptation.AdaptationHome dataspace) Retrieves all records in error along with their validation errors from the inputdataspace.- Parameters:
dataspace- the dataspace to be validated- Returns:
- a map of the records in error with their validation errors
-
getValidationError
public static Map<com.onwbp.adaptation.PrimaryKey,Set<com.orchestranetworks.service.ValidationReportItem>> getValidationError(com.onwbp.adaptation.Adaptation dataset) Retrieves all records in error along with their validation errors from the inputdataset.- Parameters:
dataset- the dataset to be validated- Returns:
- a map of the records in error with their validation errors
-
getValidationError
public static Map<com.onwbp.adaptation.PrimaryKey,Set<com.orchestranetworks.service.ValidationReportItem>> getValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTable) Retrieves all records in error, along with their validation errors, from the tables in theupdatedTablecollection.- Parameters:
updatedTable- a collection of tables to be validated- Returns:
- a map of the records in error with their validation errors
-
checkValidationError
public static Set<com.onwbp.adaptation.Adaptation> checkValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTableCollection, Map<com.onwbp.adaptation.PrimaryKey, Set<com.orchestranetworks.service.ValidationReportItem>> initialErrorsMap, com.orchestranetworks.service.Session session) Retrieves records with validation errors from the specified tables, excluding those with matching errors in the providedinitialErrorsMap.This method retrieves all records with validation errors from the tables in the specified
updatedTableCollection. The returned records are filtered based on the providedinitialErrorsMap. If the same record exists ininitialErrorsMapwith matching errors, it will not be returned.- Parameters:
updatedTableCollection- the collection of tables to be checked for validation errorsinitialErrorsMap- a map associating records (using their primary keys) with their corresponding validation items of error severitysession- the authenticated user session- Returns:
- a set of adaptations (records) with validation errors, filtered by
initialErrorsMap
-
distinctByKeys
Creates aPredicatethat filters elements based on distinct keys extracted using the provided key extractors. This allows for filtering out duplicates from a stream of elements by one or more attributes.This method can be used by JAVA stream to distinct entries by one or more fields
- Type Parameters:
T- the type of elements to be filtered- Parameters:
keyExtractors- one or more functions that extract keys from elements of typeT- Returns:
- a
Predicatethat evaluates totruefor distinct elements andfalsefor duplicates
-
isValidAdaptations
public static Map<com.onwbp.adaptation.PrimaryKey,Set<com.orchestranetworks.service.ValidationReportItem>> isValidAdaptations(com.onwbp.adaptation.Adaptation... records) Checks the validation report of the input record(s) and returns those in error, along with their validation errors.This method accepts a variable number of
Adaptationrecords that need to be validated. You can pass any number of records, including none.- Parameters:
records- theAdaptationrecords to be validated; can be zero or more- Returns:
- a map of the records in error with their validation errors
-