Package de.hybris.platform.product.impl
Class DefaultVariantsService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.product.impl.DefaultVariantsService
-
- All Implemented Interfaces:
VariantsService
,java.io.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 theVariantsService
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultVariantsService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<VariantTypeModel>
getAllVariantTypes()
Searches all existing variant types.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.java.util.Set<java.lang.String>
getVariantAttributes(java.lang.String variantProductType)
Returns a set of variant attribute qualifiers for the givenvariantProductType
.java.util.List<VariantAttributeDescriptorModel>
getVariantAttributesForVariantType(VariantTypeModel variantType)
Returns the attribute descriptors of the givenVariantType
.java.lang.Object
getVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier)
Returns for the givenVariantProductModel
and given attributequalifier
the value of this attribute.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.VariantTypeModel
getVariantTypeForCode(java.lang.String code)
Returns aVariantTypeModel
instance for the givencode
.void
setTypeService(TypeService typeService)
void
setVariantAttributesForVariantType(VariantTypeModel variantType, java.util.List<VariantAttributeDescriptorModel> newAttributes)
Tries to assign new variant attribute descriptors for the given variant type.void
setVariantAttributeValue(VariantProductModel variant, java.lang.String qualifier, java.lang.Object value)
void
setVariantTypeDao(VariantTypeDao variantTypeDao)
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
getVariantTypeForCode
public VariantTypeModel getVariantTypeForCode(java.lang.String code)
Returns aVariantTypeModel
instance for the givencode
.- Specified by:
getVariantTypeForCode
in interfaceVariantsService
- 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 givenvariantProductType
.- Specified by:
getVariantAttributes
in interfaceVariantsService
- 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 givenVariantProductModel
and given attributequalifier
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 interfaceVariantsService
- Parameters:
variant
- the variant productqualifier
- 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 givenVariantProductModel
the givenvalue
to the given attributequalifier
.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 interfaceVariantsService
- Parameters:
variant
- the variant productqualifier
- the attribute qualifiervalue
- the value to be set
-
setTypeService
public void setTypeService(TypeService typeService)
-
setVariantTypeDao
public void setVariantTypeDao(VariantTypeDao variantTypeDao)
-
getAllVariantTypes
public java.util.Collection<VariantTypeModel> getAllVariantTypes()
Searches all existing variant types.- Specified by:
getAllVariantTypes
in interfaceVariantsService
- Returns:
- the variant types.
-
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 interfaceVariantsService
- 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 interfaceVariantsService
- Parameters:
baseProduct
- the base product to get variants forfilterValues
- the variant attribute values (attribute qualifier->value map) to match. ifnull or empty
an empty List will be returned.- Returns:
- collection of matching variants.
-
getVariantAttributesForVariantType
public java.util.List<VariantAttributeDescriptorModel> getVariantAttributesForVariantType(VariantTypeModel variantType)
Returns the attribute descriptors of the givenVariantType
.- Specified by:
getVariantAttributesForVariantType
in interfaceVariantsService
- Parameters:
variantType
- the variant type- Returns:
- an attributes collection
-
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 theVariantAttributeDescriptorModel
s.- Specified by:
setVariantAttributesForVariantType
in interfaceVariantsService
- Parameters:
variantType
- the variant typenewAttributes
- the attributes which should be assigned
-
-