Class UserCollectionUtil

java.lang.Object
com.skava.util.UserCollectionUtil

public final class UserCollectionUtil extends Object
This utility class consists of validator methods for User collection resource.
Author:
Infosys Equinox
  • Method Details

    • isBusinessIdValid

      public static boolean isBusinessIdValid(Long businessId)
      This method is used to validate the businessId, returns TRUE if businessId is valid and FALSE if null or less than 1.
      Parameters:
      businessId - Indicates the business id of a collection which is used to validate the business id
      Returns:
      A boolean value. a collection identifier validation result.
    • isCollectionNameValid

      public static boolean isCollectionNameValid(String collectionName)
      This method is used to validate the collection name, returns TRUE collection name is valid and FALSE if null or empty.
      Parameters:
      collectionName - Indicates the collection name which is used to validate the collection name
      Returns:
      A boolean value
    • getCollectionStatus

      public static CollectionStatus getCollectionStatus(Collection request)
      This method is used to get the Collection status for a collection. If status of the given collection is null then ACTIVE status is returned.
      Parameters:
      request - Holds Collection which is used to get the collection status.
      Returns:
      The collection status
    • isValidCollectionId

      public static boolean isValidCollectionId(Long collectionId)
      This method is used to validate the collectionId, returns TRUE collection id is greater than 1 else FALSE.
      Parameters:
      collectionId - Indicates the collectionId which is used to validate the collection id.
      Returns:
      A boolean value. a collection identifier validation result.
    • validateCollection

      public static CollectionEntity validateCollection(UserCommonServices userCommonServices, Long collectionId, Long businessId, String locale)
      This method is used to retrieve the collection for the given collectionId and businessId. Throws validateException if the collection is not present.
      Parameters:
      userCommonServices - Holds UserCommonServices object which is used for validating requested collection id.
      collectionId - Indicates the collectionId which is used to validate the collection id.
      businessId - Indicates the business id of a collection which is used to validate the business id.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      The CollectionEntity object.
    • validateCollectionAndBusinessId

      public static void validateCollectionAndBusinessId(CollectionRepository collectionRepository, org.springframework.context.MessageSource messageSource, Long collectionId, Long businessId, String locale)
      This method is used to retrieve the collection for the given collectionId and businessId. Throws validateException if the collection is not present.
      Parameters:
      collectionRepository - Holds CollectionRepository object which is used to validate the collection and business Id
      messageSource - Holds MessageSource object which is which is used to get the response for validating the collection and business id.
      collectionId - Indicates the collectionId which is used to validate the collection id.
      businessId - Indicates the business id of a collection which is used to validate the business id
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
    • getUpdatedCollectionProperties

      public static Set<CollectionPropertyEntity> getUpdatedCollectionProperties(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, UserCommonServices userCommonServices, String locale)
      This method is used to retrieve the updated collection properties for the given collection.
      Parameters:
      collection - Holds CollectionEntity object which is used to get updated collection properties
      requestProperties - List of Holds CollectionProperty object which is used to get updated collection properties.
      attributes - List of Holds CollectionAttributeEntity object which is used to get updated collection properties.
      userCommonServices - Holds userCommonServices object which is used for validating requested collection id.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      The Set of CollectionAttributeEntity
    • isCollectionPropertyAndAttributeEquals

      public static boolean isCollectionPropertyAndAttributeEquals(CollectionAttributeEntity attribute, CollectionProperty property)
      This method is used to compare collection property and the attribute by name. Returns TRUE if attribute name and collection property is same else FALSE.
      Parameters:
      attribute - Holds CollectionAttributeEntity object which is used to validate the property.
      property - Holds CollectionProperty object which is used to validate the property name.
      Returns:
      The boolean value
    • isCollectionPropertyHaveValidValue

      public static boolean isCollectionPropertyHaveValidValue(CollectionProperty property)
      This method is used to validate the property value, returns TRUE if property and its value are not null else FALSE.
      Parameters:
      property - Holds CollectionProperty object which is used to validate the property name
      Returns:
      The boolean value
    • getPropertyValue

      public static String getPropertyValue(CollectionAttributeEntity attribute, CollectionProperty requestProperty)
      This method is used to get property value for the given attribute and collection property. It returns the attribute value if collection property value is null in the request, else return collection property value.
      Parameters:
      attribute - Holds CollectionAttributeEntity object which is used to get the collection property.
      requestProperty - Holds CollectionProperty object which is used to get the property name.
      Returns:
      The collection property value.
    • getCollectionProperties

      public static Set<CollectionPropertyEntity> getCollectionProperties(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, UserCommonServices userCommonServices, String locale, boolean isCreate)
      This method will compare collection attributes and collection properties from the request object and adds it to the CollectionPropertyEntity set. If property value is null then attribute default value will be considered else property value remains.
      Parameters:
      collection - Holds CollectionEntity object which is used to get collection property.
      requestProperties - Holds the List of CollectionProperty object which is used to get collection property.
      attributes - Holds the List of CollectionAttributeEntity object which is used to get collection property.
      userCommonServices - Holds MessageSource object which is used for validating requested collection id.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      Returns:
      The Set of CollectionPropertyEntity object.
    • isPossibleValuesAvailable

      public static boolean isPossibleValuesAvailable(CollectionAttributeType attributeType)
      This method is used to validate collection attribute type, returns TRUE if attribute type is either ENUM_MULTISELECT or ENUM else FALSE.
      Parameters:
      attributeType - a CollectionAttributeType object to check whether the possible value is present or not.
      Returns:
      A Boolean object.
    • getPossibleValues

      public static List<String> getPossibleValues(CollectionAttributeEntity attribute)
      This method is used to convert String to List using delimiter as comma.
      Parameters:
      attribute - a CollectionAttributeEntity object for getting the possible value.
      Returns:
      the List of String objects.