Class DefaultVariantsService

    • Constructor Detail

      • DefaultVariantsService

        public DefaultVariantsService()
    • Method Detail

      • getVariantTypeForCode

        public VariantTypeModel getVariantTypeForCode​(java.lang.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 java.util.Set<java.lang.String> getVariantAttributes​(java.lang.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 java.lang.Object getVariantAttributeValue​(VariantProductModel variant,
                                                         java.lang.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,
                                             java.lang.String qualifier,
                                             java.lang.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)
      • getAssignedVariantAttributes

        public java.util.Map<java.lang.String,​java.util.Collection<java.lang.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 java.util.Collection<VariantProductModel> getVariantProductForAttributeValues​(ProductModel baseProduct,
                                                                                             java.util.Map<java.lang.String,​java.lang.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.
      • setVariantAttributesForVariantType

        public void setVariantAttributesForVariantType​(VariantTypeModel variantType,
                                                       java.util.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