Class ValidationUtils

java.lang.Object
com.apgar.common.lib.utils.ValidationUtils

public class ValidationUtils extends Object
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 Type
    Method
    Description
    static Set<com.onwbp.adaptation.Adaptation>
    checkValidationError(com.onwbp.adaptation.Adaptation dataset)
    Evaluates the validation report of the specified dataset and 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 specified dataspace and returns the records with validation errors, excluding those with matching errors in the provided initialErrorsMap.
    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 specified dataset and returns the records with validation errors, excluding those with matching errors in the provided initialErrorsMap.
    static Set<com.onwbp.adaptation.Adaptation>
    checkValidationError(Collection<com.onwbp.adaptation.AdaptationTable> updatedTable)
    Evaluates the validation report of the tables belonging to the updatedTable collection 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 provided initialErrorsMap.
    static <T> Predicate<T>
    distinctByKeys(Function<? super T,?>... keyExtractors)
    Creates a Predicate that filters elements based on distinct keys extracted using the provided key extractors.
    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 input dataset.
    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 input dataspace.
    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 the updatedTable collection.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 specified dataspace and returns the records with validation errors, excluding those with matching errors in the provided initialErrorsMap.
      Parameters:
      dataspace - the dataspace to be checked for validation errors
      initialErrorsMap - a map associating records (using their primary keys) with their corresponding validation items of error severity
      session - 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 specified dataset and 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 specified dataset and returns the records with validation errors, excluding those with matching errors in the provided initialErrorsMap.
      Parameters:
      dataset - the dataset to be checked for validation errors
      initialErrorsMap - a map associating records (using their primary keys) with their corresponding validation items of error severity
      session - 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 the updatedTable collection 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 input dataspace.
      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 input dataset.
      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 the updatedTable collection.
      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 provided initialErrorsMap.

      This method retrieves all records with validation errors from the tables in the specified updatedTableCollection. The returned records are filtered based on the provided initialErrorsMap. If the same record exists in initialErrorsMap with matching errors, it will not be returned.

      Parameters:
      updatedTableCollection - the collection of tables to be checked for validation errors
      initialErrorsMap - a map associating records (using their primary keys) with their corresponding validation items of error severity
      session - the authenticated user session
      Returns:
      a set of adaptations (records) with validation errors, filtered by initialErrorsMap
    • distinctByKeys

      @SafeVarargs public static <T> Predicate<T> distinctByKeys(Function<? super T,?>... keyExtractors)
      Creates a Predicate that 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 type T
      Returns:
      a Predicate that evaluates to true for distinct elements and false for 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 Adaptation records that need to be validated. You can pass any number of records, including none.

      Parameters:
      records - the Adaptation records to be validated; can be zero or more
      Returns:
      a map of the records in error with their validation errors