Class DefaultVariantsService

All Implemented Interfaces:
VariantsService, Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
DefaultBackofficeVariantsService

public class DefaultVariantsService extends AbstractBusinessService implements VariantsService
Default implementation of the VariantsService.
See Also:
  • Constructor Details

    • DefaultVariantsService

      public DefaultVariantsService()
  • Method Details

    • getVariantTypeForCode

      public VariantTypeModel getVariantTypeForCode(String code)
      Returns a VariantTypeModel instance for the given code.
      Specified by:
      getVariantTypeForCode in interface VariantsService
      Parameters:
      code - the variant type code. Must exists in the system and must be not null.
      Returns:
      a VariantTypeModel for the given code.
    • getVariantAttributes

      public Set<String> getVariantAttributes(String variantProductType)
      Returns a set of variant attribute qualifiers for the given variantProductType.
      Specified by:
      getVariantAttributes in interface VariantsService
      Parameters:
      variantProductType - the variant type code. Must exists in the system and must be a variant type.
      Returns:
      an empty set if for the given variantProductType no variant attributes were found.
    • getVariantAttributeValue

      public Object getVariantAttributeValue(VariantProductModel variant, String qualifier)
      Returns for the given VariantProductModel and given attribute qualifier the value of this attribute.

      TODO: to be changed, remove the jalo part. At this moment the jalo-way has to be used because there is no chance to read the attribute value in SL, because it's not a part of the model.

      Specified by:
      getVariantAttributeValue in interface VariantsService
      Parameters:
      variant - the variant product
      qualifier - the attribute qualifier
      Returns:
      what is stored in this attribute.
    • setVariantAttributeValue

      public void setVariantAttributeValue(VariantProductModel variant, String qualifier, Object value)
      Sets in the given VariantProductModel the given value to the given attribute qualifier.

      TODO: to be changed, remove the jalo part. At this moment the jalo-way has to be used because there is no chance to read the attribute value in SL, because it's not a part of the model.

      Specified by:
      setVariantAttributeValue in interface VariantsService
      Parameters:
      variant - the variant product
      qualifier - the attribute qualifier
      value - the value to be set
    • setTypeService

      public void setTypeService(TypeService typeService)
    • setVariantTypeDao

      public void setVariantTypeDao(VariantTypeDao variantTypeDao)
    • getAllVariantTypes

      public Collection<VariantTypeModel> getAllVariantTypes()
      Searches all existing variant types.
      Specified by:
      getAllVariantTypes in interface VariantsService
      Returns:
      the variant types.
    • getAssignedVariantAttributes

      public Map<String,Collection<Object>> getAssignedVariantAttributes(ProductModel baseProduct)
      Searches variant attributes with all assigned values for given base product.
      Specified by:
      getAssignedVariantAttributes in interface VariantsService
      Parameters:
      baseProduct - the base product for all variants
      Returns:
      map "name of attribute (qualifier) ->distinct values" over all variants
    • getVariantProductForAttributeValues

      public Collection<VariantProductModel> getVariantProductForAttributeValues(ProductModel baseProduct, Map<String,Object> filterValues)
      Filters a range of variants from a given base product according to the given variant attribute qualifier-value map. If not all available attributes are specified the method is likely to return more than one variant - if all attributes are specified there should be only one variant which matches them.
      Specified by:
      getVariantProductForAttributeValues in interface VariantsService
      Parameters:
      baseProduct - the base product to get variants for
      filterValues - the variant attribute values (attribute qualifier->value map) to match. if null or empty an empty List will be returned.
      Returns:
      collection of matching variants.
    • getVariantAttributesForVariantType

      public List<VariantAttributeDescriptorModel> getVariantAttributesForVariantType(VariantTypeModel variantType)
      Returns the attribute descriptors of the given VariantType.
      Specified by:
      getVariantAttributesForVariantType in interface VariantsService
      Parameters:
      variantType - the variant type
      Returns:
      an attributes collection
    • setVariantAttributesForVariantType

      public void setVariantAttributesForVariantType(VariantTypeModel variantType, List<VariantAttributeDescriptorModel> newAttributes)
      Tries to assign new variant attribute descriptors for the given variant type. Removes old attributes if necessary and checks if enclosing type is set correctly. This is achieved by internal save of the given variantType with new set of the VariantAttributeDescriptorModels.
      Specified by:
      setVariantAttributesForVariantType in interface VariantsService
      Parameters:
      variantType - the variant type
      newAttributes - the attributes which should be assigned