Class MerchandiseUtil

java.lang.Object
com.skava.merchandise.util.MerchandiseUtil

public final class MerchandiseUtil extends Object
This Class is used to write common methods which are used by more than one classes in merchandise service.
Author:
Infosys Equinox
  • Field Details

  • Method Details

    • isValidPageAndSize

      public static boolean isValidPageAndSize(int page, int size)
      This method is used to validate the page and size used in find all calls for API's.
      Parameters:
      page - It holds the value of the page to be validated.
      size - It holds the value of the size to be validated.
      Returns:
      boolean It represents the validation results. true - valid, false - not valid.
    • isValidIdentifier

      public static boolean isValidIdentifier(String identifier)
      This method is used to ensure whether the given Identifier is in alpha numeric format.
      Parameters:
      identifier - It is the identifier to be checked.
      Returns:
      boolean It represents the validation results. true - valid , false - not valid.
    • validateCollectionId

      public static void validateCollectionId(long collectionId)
      This method is used to validates the collection Id and throws ValidateException exception, if it is not valid.
      Parameters:
      collectionId - It contains identifier of a collection to be validated.
    • validateBusinessId

      public static void validateBusinessId(long businessId)
      This method is used to validates the business Id and throws ValidateException exception, if it is not valid.
      Parameters:
      businessId - It contains identifier of a business to be validated.
    • validateLocale

      public static void validateLocale(String locale)
      This method is used to validates the locale and throws ValidateException exception, if it is not valid.
      Parameters:
      locale - It contains locale to be validated.
    • validatePropertiesMaxArraySize

      public static void validatePropertiesMaxArraySize(List<CategoryProperty> categoryProperties)
      *This method is used to validate the maximum size of properties It will throw ValidateException if the maximum size is reached
      Parameters:
      categoryProperties - It contains the list of properties to be validated.
    • validatePropertiesMaxSize

      public static void validatePropertiesMaxSize(List<CategoryPropertyRequest> properties)
      *This method is used to validate the maximum size of properties It will throw ValidateException if the maximum size is reached
      Parameters:
      properties - It contains the list of properties to be validated.
    • propertyValidate

      public static void propertyValidate(String name, String value)
      This method validates whether the properties name contains the valid value.
      Parameters:
      name - It holds the value of name which is used to validate the value.
      value - It holds the value to be validated.
    • ignoreInvalidWidgetProperties

      public static void ignoreInvalidWidgetProperties(CreativeRequest creative)
      This method is used to Ignore the widget properties which contains empty name or value.
      Parameters:
      creative - It holds the creative which contains the properties with/without empty values to be Filtered.
    • ignoreEmptyTags

      public static void ignoreEmptyTags(CreativeRequest creative)
      This method is used to Ignore the tags which are invalid(empty/contains empty space).
      Parameters:
      creative - It holds the creative which contains the tags with/without empty values to be Filtered.
    • getFieldsNameFromClass

      public static List<String> getFieldsNameFromClass(Class<?> compositeIdClass)
      This method is used to get fields name from class.
      Parameters:
      compositeIdClass - compositeIdClass
      Returns:
      List<String>
    • getCurrentMileStone

      public static Milestone getCurrentMileStone(Milestone[] milestoneArr)
      This method is used to get current milestone in a array of milestones by comparing its start time, end time, priority and updated time.
      Parameters:
      milestoneArr - It contains array of milestone to get current milestone.
      Returns:
      Milestone
    • validateProperty

      public static void validateProperty(String name, Map<String,CategoryProperty> propertyMap)
      This method will validate the property whether it's exists in DB. If not it will throw CategoryPropertyNotFoundException exception
      Parameters:
      name - It holds the property name.
      propertyMap - It holds map of string and CategoryProperty.
    • setCategoryPropertyName

      public static void setCategoryPropertyName(CategoryProperty property, CategoryAttribute attributeObj, String defaultLocale)
      This method set Category property name from attribute entity
      Parameters:
      property - Instance of CategoryProperty.
      attributeObj - Optional of CategoryAttribute.
      defaultLocale - collection default locale
    • updateProductsAndAttributes

      public static boolean updateProductsAndAttributes(Milestone existingMilestoneEntity, Milestone entityToBeUpdated)
      This function is used to update products and attributes.
      Parameters:
      existingMilestoneEntity - Milestone entity fromDB.
      entityToBeUpdated - Milestone entity from input.
      Returns:
      It returns the boolean value
    • validateProductsUxdataAndRulesAgainstPageType

      public static void validateProductsUxdataAndRulesAgainstPageType(Milestone existingMilestoneEntity, PageType pageType)
      To validate the products,rules and search keyword fields against the category pageType.
      Parameters:
      existingMilestoneEntity - to get values to validate.
      pageType - pageType to validate milestone fields.
    • getLocalDateTimeFromEpoc

      public static LocalDateTime getLocalDateTimeFromEpoc(long previewTime)