Class DefaultTypeService

All Implemented Interfaces:
TypeService, Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean

public class DefaultTypeService extends AbstractBusinessService implements TypeService
Default implementation of the type service interface
Since:
4.0
See Also:
  • Constructor Details

    • DefaultTypeService

      public DefaultTypeService()
  • Method Details

    • getAtomicType

      @Deprecated(since="ages", forRemoval=true) public AtomicTypeModel getAtomicType(String typeCode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns a specific atomic type.
      Specified by:
      getAtomicType in interface TypeService
      Parameters:
      typeCode - the unique code of this type
    • getAtomicTypeForCode

      public AtomicTypeModel getAtomicTypeForCode(String code)
      Description copied from interface: TypeService
      Gets the atomic type for code.
      Specified by:
      getAtomicTypeForCode in interface TypeService
      Parameters:
      code - the code
      Returns:
      the atomic type for code
    • getAtomicTypeForJavaClass

      public AtomicTypeModel getAtomicTypeForJavaClass(Class javaClass)
      Description copied from interface: TypeService
      Returns the atomic type for java class.
      Specified by:
      getAtomicTypeForJavaClass in interface TypeService
      Parameters:
      javaClass - the java class that we are looking atomic type for
      Returns:
      the atomic type for java class
    • getComposedType

      @Deprecated(since="ages", forRemoval=true) public ComposedTypeModel getComposedType(String typeCode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns a specific composed type.
      Specified by:
      getComposedType in interface TypeService
      Parameters:
      typeCode - the unique code of this type
    • getComposedTypeForCode

      public ComposedTypeModel getComposedTypeForCode(String code)
      Description copied from interface: TypeService
      Returns the specific composed type for code.
      Specified by:
      getComposedTypeForCode in interface TypeService
      Parameters:
      code - the unique code of this type code
      Returns:
      the composed type for the specified code
    • getComposedType

      @Deprecated(since="ages", forRemoval=true) public ComposedTypeModel getComposedType(Class modelClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns the composed type for a specified model class.
      Specified by:
      getComposedType in interface TypeService
      Parameters:
      modelClass - the model class
    • getComposedTypeForClass

      public ComposedTypeModel getComposedTypeForClass(Class modelClass)
      Description copied from interface: TypeService
      Returns the specific composed type for the model class.
      Specified by:
      getComposedTypeForClass in interface TypeService
      Parameters:
      modelClass - the model class we are looking composed type for
      Returns:
      the composed type for class
    • getType

      @Deprecated(since="ages", forRemoval=true) public TypeModel getType(String typeCode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns a specific type. This includes composed, atomic, collection and map types.
      Specified by:
      getType in interface TypeService
      Parameters:
      typeCode - the unique code of this type
    • getTypeForCode

      public TypeModel getTypeForCode(String code)
      Description copied from interface: TypeService
      Returns a specific type. This includes composed, atomic, collection and map types.
      Specified by:
      getTypeForCode in interface TypeService
      Parameters:
      code - the code for the required type
      Returns:
      the type for code
    • getAttributeDescriptor

      public AttributeDescriptorModel getAttributeDescriptor(ComposedTypeModel composedType, String qualifier)
      Description copied from interface: TypeService
      Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
      Specified by:
      getAttributeDescriptor in interface TypeService
      Parameters:
      composedType - the composed type to get attribute descriptor for
      qualifier - the attribute qualifier
    • getAttributeDescriptor

      public AttributeDescriptorModel getAttributeDescriptor(String composedType, String qualifier)
      Description copied from interface: TypeService
      Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
      Specified by:
      getAttributeDescriptor in interface TypeService
      Parameters:
      composedType - the code of the composed type to get attribute descriptor for
      qualifier - the attribute qualifier
    • getAttributeDescriptors

      @Deprecated(since="ages", forRemoval=true) public Set<AttributeDescriptorModel> getAttributeDescriptors(ComposedTypeModel composedType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns all attribute descriptors of a single composed type. This includes declared and inherited ones.
      Specified by:
      getAttributeDescriptors in interface TypeService
      Parameters:
      composedType - the composed type to get attribute descriptors from
    • getAttributeDescriptorsForType

      public Set<AttributeDescriptorModel> getAttributeDescriptorsForType(ComposedTypeModel composedType)
      !!Note!! this service is not returning VariantAttributeDescriptors if there are any.
      Specified by:
      getAttributeDescriptorsForType in interface TypeService
      Parameters:
      composedType - the composed type
      Returns:
      the attribute descriptors for type
    • getRuntimeAttributeDescriptorsForType

      public Collection<AttributeDescriptorModel> getRuntimeAttributeDescriptorsForType(ComposedTypeModel composedTypeModel)
      Description copied from interface: TypeService
      Gets all runtime attributes for a type. A runtime attribute was created from a code and does not have a definition in the *item.xml.
      Specified by:
      getRuntimeAttributeDescriptorsForType in interface TypeService
      Parameters:
      composedTypeModel - the composed type model model
      Returns:
      runtime attributes
    • isRuntimeAttribute

      public Boolean isRuntimeAttribute(AttributeDescriptorModel attributeDescriptorModel)
      Description copied from interface: TypeService
      Checks if the attribute descriptor is a runtime one. A runtime attribute was created from a code and does not have a definition in the *item.xml. For attributes marked as dontoptimize it returns false.
      Specified by:
      isRuntimeAttribute in interface TypeService
      Parameters:
      attributeDescriptorModel - the attribute descriptor model
      Returns:
      true is the attribute is runtime
    • getAttributeDescriptors

      @Deprecated(since="ages", forRemoval=true) public Set<AttributeDescriptorModel> getAttributeDescriptors(String composedTypeCode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns all attribute descriptors (as AttributeDescriptorModel) of a single composed type. This includes declared and inherited ones. This also includes attributes which are not generated in the model layer.
      Specified by:
      getAttributeDescriptors in interface TypeService
      Parameters:
      composedTypeCode - the code of the composed type to get attribute descriptors from
    • getInitialAttributeDescriptorsForType

      public Set<AttributeDescriptorModel> getInitialAttributeDescriptorsForType(ComposedTypeModel composedTypeModel)
      Description copied from interface: TypeService
      Returns all attribute descriptors of this type which are marked as being initial.

      Initial attributes are normally non-writable attributes intended to be set during item creation only. Therefore having initial and writable attributed does not make much sense.

      Specified by:
      getInitialAttributeDescriptorsForType in interface TypeService
      Parameters:
      composedTypeModel - the composed type model we look initial attribute descriptors for
      Returns:
      the initial attribute descriptors for the given model
    • getEnumerationType

      @Deprecated(since="ages", forRemoval=true) public EnumerationMetaTypeModel getEnumerationType(String code)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
      Description copied from interface: TypeService
      Returns a specific enumeration type.
      Specified by:
      getEnumerationType in interface TypeService
      Parameters:
      code - the unique code of this type
    • getEnumerationTypeForCode

      public EnumerationMetaTypeModel getEnumerationTypeForCode(String code)
      Description copied from interface: TypeService
      Gets the enumeration type for code.
      Specified by:
      getEnumerationTypeForCode in interface TypeService
      Parameters:
      code - the code for the required type
      Returns:
      the enumeration type for code
    • getEnumerationValue

      public EnumerationValueModel getEnumerationValue(String type, String code)
      Description copied from interface: TypeService
      Returns a specific enumeration value.
      Specified by:
      getEnumerationValue in interface TypeService
      Parameters:
      type - the enumeration type code
      code - the value code
    • getEnumerationValue

      public EnumerationValueModel getEnumerationValue(HybrisEnumValue plainEnum)
      Description copied from interface: TypeService
      Converts a plain enum value into its underlying model.
      Specified by:
      getEnumerationValue in interface TypeService
      Parameters:
      plainEnum - the enum constant
    • getMandatoryAttributes

      public Set<String> getMandatoryAttributes(String type, boolean forCreation)
      Description copied from interface: TypeService
      Provides all mandatory attributes required to save models of the specified type. If the model is new (creation) this method will return initial attributes but omit attributes providing default values. Otherwise initial attributes are omitted but all other mandatory ones are returned no matter if they've got default values or not.
      Specified by:
      getMandatoryAttributes in interface TypeService
      Parameters:
      type - the type to get attributes for
      forCreation - creation or update
    • getUniqueAttributes

      public Set<String> getUniqueAttributes(String type)
      Description copied from interface: TypeService
      Provides all attributes marked as unique within the given type.
      Specified by:
      getUniqueAttributes in interface TypeService
      Parameters:
      type - the type to get unique attributes for
      Returns:
      an empty set if type has no unique attributes
    • getUniqueModelRootType

      public String getUniqueModelRootType(String composedTypeCode)
      Description copied from interface: TypeService
      This method finds for the given composedtypecode the root ComposedType which contains/declares the same unique attributes as the given ComposedType. This could be the same typecode or a typecode of any supertype of this ComposedType. The result is returned as typecode String.
      Specified by:
      getUniqueModelRootType in interface TypeService
      Parameters:
      composedTypeCode - any composed type code of the platform
      Returns:
      null if the given ComposedType contains no unique attributes.
    • getDefaultValues

      public Map<String,Object> getDefaultValues(String type)
      Description copied from interface: TypeService
      Fetches all configured default values for a specified type.
      Specified by:
      getDefaultValues in interface TypeService
      Parameters:
      type - the type to get default values for
      Returns:
      a map containing all attributes and their default values which have got a configured value
    • getDefaultValues

      public Map<String,Object> getDefaultValues(String type, Collection<String> attributes)
      Description copied from interface: TypeService
      Fetches a subset of all configured default values for a specified type.
      Specified by:
      getDefaultValues in interface TypeService
      Parameters:
      type - the type to get default values for
      attributes - the attributes to consider
      Returns:
      a map containing all attributes and their default values which have got a configured value
    • isAssignableFrom

      public boolean isAssignableFrom(TypeModel target, TypeModel source)
      Description copied from interface: TypeService
      Returns true if the TypeModel, given by the parameter superModelType, is a super type of the TypeModel OR the same type as the TypeModel, given by the parameter subModelTypeCode.
      Specified by:
      isAssignableFrom in interface TypeService
      Returns:
      true if source type can be assigned to target type
    • isInstance

      public boolean isInstance(TypeModel typemodel, Object obj)
      Description copied from interface: TypeService
      Tests if the given object is an item instance of Type type.
      Specified by:
      isInstance in interface TypeService
      Returns:
      true if given object is an item instance of Type type
    • isAssignableFrom

      public boolean isAssignableFrom(String superModelTypeCode, String subModelTypeCode)
      Description copied from interface: TypeService
      Returns true if the model type, given by the parameter superModelTypeCode, is a super type of the type of the model OR the same type as the type of the model, given by the parameter subModelTypeCode.
      Specified by:
      isAssignableFrom in interface TypeService
      Parameters:
      superModelTypeCode - - the type code (TypeModel) of the super type
      subModelTypeCode - - the type code (TypeModel) of the sub type
      Returns:
      false if the sub model type is not addignable from the super model type or if any parameter is null
    • getPartOfAttributes

      public Set<String> getPartOfAttributes(String composedTypeCode)
      Description copied from interface: TypeService
      Provides all attribute qualifiers marked as part-of within the given type.
      Specified by:
      getPartOfAttributes in interface TypeService
      Parameters:
      composedTypeCode - the composedType code to get part-of attributes for
      Returns:
      an empty set if type has no part-of attributes
    • setConverterRegistry

      public void setConverterRegistry(ConverterRegistry converterRegistry)
    • getTypeDao

      public TypeDao getTypeDao()
    • setTypeDao

      public void setTypeDao(TypeDao typeDao)
    • getEnumerationManager

      @Deprecated(since="ages", forRemoval=true) public EnumerationManager getEnumerationManager()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since ages
    • setEnumerationManager

      public void setEnumerationManager(EnumerationManager enumerationManager)
    • hasAttribute

      public boolean hasAttribute(ComposedTypeModel type, String qualifier)
      Description copied from interface: TypeService
      Checks if type has attribute.
      Specified by:
      hasAttribute in interface TypeService
      Parameters:
      type - type
      qualifier - qualifier to check
      Returns:
      true if type has attribute
    • getModelClass

      public <T extends ItemModel> Class<T> getModelClass(ComposedTypeModel type)
      Description copied from interface: TypeService
      Returns model class for a type.
      Specified by:
      getModelClass in interface TypeService
      Parameters:
      type - type
      Returns:
      model class for a given type
    • getModelClass

      public <T extends ItemModel> Class<T> getModelClass(String typeCode)
      Description copied from interface: TypeService
      Returns model class for a type code.
      Specified by:
      getModelClass in interface TypeService
      Parameters:
      typeCode - code of a type
      Returns:
      model class for a given type code
    • getAttributesForModifiers

      public Set<AttributeDescriptorModel> getAttributesForModifiers(String composedTypeCode, AttributeModifierCriteria criteria)
      Description copied from interface: TypeService
      Gets the attributes for modifiers for given composed type and criteria container. To add proper criterias to the argument use constants in the class AttributeModifiers.
      Specified by:
      getAttributesForModifiers in interface TypeService
      Parameters:
      composedTypeCode - the composed type code
      criteria - the criteria
      Returns:
      the attributes for modifiers