Package com.skava.util
Class UserCollectionUtil
java.lang.Object
com.skava.util.UserCollectionUtil
This utility class consists of validator methods for User collection resource.
- Author:
- Infosys Equinox
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static CollectionStatus
getCollectionStatus
(Collection request) This method is used to get the Collection status for a collection.getPossibleValues
(CollectionAttributeEntity attribute) This method is used to convert String to List using delimiter as comma.static String
getPropertyValue
(CollectionAttributeEntity attribute, CollectionProperty requestProperty) This method is used to get property value for the given attribute and collection property.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.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.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.static boolean
isCollectionPropertyAndAttributeEquals
(CollectionAttributeEntity attribute, CollectionProperty property) This method is used to compare collection property and the attribute by name.static boolean
This method is used to validate the property value, returns TRUE if property and its value are not null else FALSE.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.static boolean
isValidCollectionId
(Long collectionId) This method is used to validate the collectionId, returns TRUE collection id is greater than 1 else FALSE.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.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.
-
Method Details
-
isBusinessIdValid
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
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
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
- HoldsCollection
which is used to get the collection status.- Returns:
- The collection status
-
isValidCollectionId
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
- HoldsUserCommonServices
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
- HoldsCollectionRepository
object which is used to validate the collection and business IdmessageSource
- HoldsMessageSource
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 idlocale
- 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
- HoldsCollectionEntity
object which is used to get updated collection propertiesrequestProperties
- List of HoldsCollectionProperty
object which is used to get updated collection properties.attributes
- List of HoldsCollectionAttributeEntity
object which is used to get updated collection properties.userCommonServices
- HoldsuserCommonServices
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
- HoldsCollectionAttributeEntity
object which is used to validate the property.property
- HoldsCollectionProperty
object which is used to validate the property name.- Returns:
- The boolean value
-
isCollectionPropertyHaveValidValue
This method is used to validate the property value, returns TRUE if property and its value are not null else FALSE.- Parameters:
property
- HoldsCollectionProperty
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
- HoldsCollectionAttributeEntity
object which is used to get the collection property.requestProperty
- HoldsCollectionProperty
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
- HoldsCollectionEntity
object which is used to get collection property.requestProperties
- Holds the List ofCollectionProperty
object which is used to get collection property.attributes
- Holds the List ofCollectionAttributeEntity
object which is used to get collection property.userCommonServices
- HoldsMessageSource
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
This method is used to validate collection attribute type, returns TRUE if attribute type is either ENUM_MULTISELECT or ENUM else FALSE.- Parameters:
attributeType
- aCollectionAttributeType
object to check whether the possible value is present or not.- Returns:
- A
Boolean
object.
-
getPossibleValues
This method is used to convert String to List using delimiter as comma.- Parameters:
attribute
- aCollectionAttributeEntity
object for getting the possible value.- Returns:
- the
List
ofString
objects.
-