Package com.skava.helper
Class CollectionUtil
java.lang.Object
com.skava.helper.CollectionUtil
The utility class CollectionUtil consists of helper and validator methods for collection entity.
- Author:
- Infosys Equinox
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.data.domain.Sort
buildSort - to build the sort parameter.static void
checkCollectionNameExists
(CollectionRepository collectionRepository, CollectionEntity collection, org.springframework.context.MessageSource messageSource, String locale) static Set<CollectionPropertyEntity>
getCollectionProperties
(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, CommonServices commonServices, String locale) Used to get collection properties.static CollectionStatus
getCollectionStatus
(Collection request) validateCollectionStatusgetPossibleValues
(CollectionAttributeEntity attribute) static String
getPropertyValue
(CollectionAttributeEntity attribute, CollectionProperty requestProperty) Getting property valuestatic Set<CollectionPropertyEntity>
getUpdatedCollectionProperties
(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, org.springframework.context.MessageSource messageSource, String locale) Getting updated collection propertiesstatic boolean
isBusinessIdValid
(Long businessId) isValidBusinessIdstatic boolean
isCollectionNameValid
(String collectionName) isCollectionNameValid - Used to check if the collection name is valid.static boolean
isCollectionPropertyAndAttributeEquals
(CollectionAttributeEntity attribute, CollectionProperty property) Validating collection property and attributesstatic boolean
Validating property valuestatic boolean
isPossibleValuesAvailable
(CollectionAttributeType attributeType) isPossibleValuesAvailablestatic boolean
isValidCollection
(CommonServices commonServices, Long collectionId) Validating collection idstatic boolean
isValidCollectionId
(Long collectionId) This method is used to validate the collection identifier.static String
sanitizeInput
(String input) static CollectionEntity
validateCollectionAndBusinessId
(CollectionRepository collectionRepository, org.springframework.context.MessageSource messageSource, Long collectionId, Long businessId, String locale) Validating collection and business id
-
Method Details
-
isBusinessIdValid
isValidBusinessId
This method is used to validate the collection identifier.- 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
isCollectionNameValid - Used to check if the collection name is valid.- Parameters:
collectionName
- Indicates the collection name which is to be validated.- Returns:
- a boolean value - true/false
-
getCollectionStatus
validateCollectionStatus
- Parameters:
request
- Instance ofCollection
which is used to get the collection status.- Returns:
- collection status
-
isValidCollectionId
This method is used to validate the collection identifier.- Parameters:
collectionId
- Indicates the collectionId which will be validated.- Returns:
- a boolean value - true/false ie., if the collectionId is valid or not.
-
isValidCollection
Validating collection id- Parameters:
commonServices
- Instance ofCommonServices
which is used to get the collection property.collectionId
- Indicates the collectionId which is used to validate the collection id.- Returns:
- Boolean value if valid collection true else false
-
validateCollectionAndBusinessId
public static CollectionEntity validateCollectionAndBusinessId(CollectionRepository collectionRepository, org.springframework.context.MessageSource messageSource, Long collectionId, Long businessId, String locale) Validating collection and business id- Parameters:
collectionRepository
- Instance ofCollectionRepository
which is used to validate the collection and business IdmessageSource
- Instance ofMessageSource
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.- Returns:
- Instance of
CollectionEntity
object
-
getUpdatedCollectionProperties
public static Set<CollectionPropertyEntity> getUpdatedCollectionProperties(CollectionEntity collection, List<CollectionProperty> requestProperties, List<CollectionAttributeEntity> attributes, org.springframework.context.MessageSource messageSource, String locale) Getting updated collection properties- Parameters:
collection
- Instance ofCollectionEntity
which is used to get updated collection propertiesrequestProperties
- List of Instance ofCollectionProperty
object which is used to get updated collection properties.attributes
- List of Instance ofCollectionAttributeEntity
object which is used to get updated collection properties.messageSource
- HoldsMessageSource
which is used for response message and codes.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- Set of Instance of
CollectionAttributeEntity
-
isCollectionPropertyAndAttributeEquals
public static boolean isCollectionPropertyAndAttributeEquals(CollectionAttributeEntity attribute, CollectionProperty property) Validating collection property and attributes- Parameters:
attribute
- Instance ofCollectionAttributeEntity
object which is used to validate the property.property
- Instance ofCollectionProperty
which is used to validate the property name- Returns:
- the boolean value
-
isCollectionPropertyHaveValidValue
Validating property value- Parameters:
property
- Instance ofCollectionProperty
which is used to validate the property name- Returns:
- the boolean value
-
getPropertyValue
public static String getPropertyValue(CollectionAttributeEntity attribute, CollectionProperty requestProperty) Getting property value- Parameters:
attribute
- Instance ofCollectionAttributeEntity
object which is used to get the collection propertyrequestProperty
- Instance ofCollectionProperty
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, CommonServices commonServices, String locale) Used to get collection properties.- Parameters:
collection
- Instance ofCollectionEntity
which is used to get collection property.requestProperties
- List of Instance ofCollectionProperty
which is used to get collection property.attributes
- List of Instance ofCollectionAttributeEntity
object which is used to get collection property.commonServices
- Instance ofCommonServices
which is used tp get the collection property.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.- Returns:
- Set of Instance of
CollectionPropertyEntity
-
isPossibleValuesAvailable
isPossibleValuesAvailable- Parameters:
attributeType
- aCollectionAttributeType
object.- Returns:
- a
Boolean
object.
-
getPossibleValues
- Parameters:
attribute
- aCollectionAttributeEntity
object.- Returns:
- a
List
ofString
objects.
-
buildSort
buildSort - to build the sort parameter.- Parameters:
sortStr
- the sort string to build the sort object.- Returns:
- the
Sort
object.
-
checkCollectionNameExists
public static void checkCollectionNameExists(CollectionRepository collectionRepository, CollectionEntity collection, org.springframework.context.MessageSource messageSource, String locale) -
sanitizeInput
- Parameters:
input
-- Returns:
-