Interface TypeService

  • All Known Implementing Classes:
    DefaultTypeService

    public interface TypeService
    Service covering type system of the platform. Provides a methods to access TypeModel, DescriptorModel and related objects.
    Since:
    4.0
    Spring Bean ID:
    typeService
    • Method Detail

      • getComposedTypeForCode

        ComposedTypeModel getComposedTypeForCode​(java.lang.String code)
        Returns the specific composed type for code.
        Parameters:
        code - the unique code of this type code
        Returns:
        the composed type for the specified code
        Throws:
        java.lang.IllegalArgumentException - thrown when given code is null
        AmbiguousIdentifierException - the ambiguous identifier exception when more than one composed type for given code is found
        UnknownIdentifierException - the unknown identifier exception when no composed type for given code is found
      • getComposedType

        @Deprecated
        ComposedTypeModel getComposedType​(java.lang.Class modelClass)
        Deprecated.
        since ages - usegetComposedTypeForClass(Class) instead.
        Returns the composed type for a specified model class.
        Parameters:
        modelClass - the model class
        Throws:
        java.lang.IllegalArgumentException - if no type is mapped to this model
      • getComposedTypeForClass

        ComposedTypeModel getComposedTypeForClass​(java.lang.Class modelClass)
        Returns the specific composed type for the model class.
        Parameters:
        modelClass - the model class we are looking composed type for
        Returns:
        the composed type for class
        Throws:
        java.lang.IllegalArgumentException - thrown when given modelClass is null
        UnknownIdentifierException - the unknown identifier exception when no composed type for given modelClass is found
      • getAttributeDescriptor

        AttributeDescriptorModel getAttributeDescriptor​(ComposedTypeModel composedType,
                                                        java.lang.String qualifier)
        Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
        Parameters:
        composedType - the composed type to get attribute descriptor for
        qualifier - the attribute qualifier
        Throws:
        UnknownIdentifierException - if the composed type does not own a matching attribute
      • getAttributeDescriptor

        AttributeDescriptorModel getAttributeDescriptor​(java.lang.String composedTypeCode,
                                                        java.lang.String qualifier)
        Returns a specific attribute descriptor for a given composed type. This includes declared and inherited attributes.
        Parameters:
        composedTypeCode - the code of the composed type to get attribute descriptor for
        qualifier - the attribute qualifier
        Throws:
        UnknownIdentifierException - if the composed type does not own a matching attribute
      • getAttributeDescriptorsForType

        java.util.Set<AttributeDescriptorModel> getAttributeDescriptorsForType​(ComposedTypeModel composedType)
        Gets the attribute descriptors for type.
        Parameters:
        composedType - the composed type
        Returns:
        the attribute descriptors for type
        Throws:
        java.lang.IllegalArgumentException - thrown when given type is null
      • getInitialAttributeDescriptorsForType

        java.util.Set<AttributeDescriptorModel> getInitialAttributeDescriptorsForType​(ComposedTypeModel composedTypeModel)
        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.

        Parameters:
        composedTypeModel - the composed type model we look initial attribute descriptors for
        Returns:
        the initial attribute descriptors for the given model
      • getAtomicTypeForCode

        AtomicTypeModel getAtomicTypeForCode​(java.lang.String code)
        Gets the atomic type for code.
        Parameters:
        code - the code
        Returns:
        the atomic type for code
        Throws:
        java.lang.IllegalArgumentException - thrown when given code is null
        UnknownIdentifierException - if no type exist for this code
      • getAtomicTypeForJavaClass

        AtomicTypeModel getAtomicTypeForJavaClass​(java.lang.Class javaClass)
        Returns the atomic type for java class.
        Parameters:
        javaClass - the java class that we are looking atomic type for
        Returns:
        the atomic type for java class
        Throws:
        java.lang.IllegalArgumentException - thrown when given class is null
        UnknownIdentifierException - if no type exist for this class
      • getType

        @Deprecated
        TypeModel getType​(java.lang.String code)
        Deprecated.
        since ages - usegetTypeForCode(String) instead.
        Returns a specific type. This includes composed, atomic, collection and map types.
        Parameters:
        code - the unique code of this type
        Throws:
        UnknownIdentifierException - if no type exist for this code
      • getTypeForCode

        TypeModel getTypeForCode​(java.lang.String code)
        Returns a specific type. This includes composed, atomic, collection and map types.
        Parameters:
        code - the code for the required type
        Returns:
        the type for code
        Throws:
        UnknownIdentifierException - if no type exist for this code
        java.lang.IllegalArgumentException - thrown when given code is null
      • getEnumerationTypeForCode

        EnumerationMetaTypeModel getEnumerationTypeForCode​(java.lang.String code)
        Gets the enumeration type for code.
        Parameters:
        code - the code for the required type
        Returns:
        the enumeration type for code
        Throws:
        UnknownIdentifierException - if no type exist for this code
        java.lang.IllegalArgumentException - thrown when given code is null
      • getEnumerationValue

        EnumerationValueModel getEnumerationValue​(java.lang.String type,
                                                  java.lang.String code)
        Returns a specific enumeration value.
        Parameters:
        type - the enumeration type code
        code - the value code
        Throws:
        UnknownIdentifierException - if either no matching enumeration type exists or no value with matching code
        java.lang.IllegalArgumentException - thrown when given type or code is null
      • getEnumerationValue

        EnumerationValueModel getEnumerationValue​(HybrisEnumValue plainEnum)
        Converts a plain enum value into its underlying model.
        Parameters:
        plainEnum - the enum constant
        Throws:
        java.lang.IllegalArgumentException - thrown when given enum is null
      • getMandatoryAttributes

        java.util.Set<java.lang.String> getMandatoryAttributes​(java.lang.String type,
                                                               boolean forCreation)
        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.
        Parameters:
        type - the type to get attributes for
        forCreation - creation or update
      • getUniqueAttributes

        java.util.Set<java.lang.String> getUniqueAttributes​(java.lang.String type)
        Provides all attributes marked as unique within the given type.
        Parameters:
        type - the type to get unique attributes for
        Returns:
        an empty set if type has no unique attributes
      • getUniqueModelRootType

        java.lang.String getUniqueModelRootType​(java.lang.String composedtypecode)
        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.
        Parameters:
        composedtypecode - any composed type code of the platform
        Returns:
        null if the given ComposedType contains no unique attributes.
        Throws:
        java.lang.IllegalArgumentException - if no such ComposedType by the given typecode exists
      • getDefaultValues

        java.util.Map<java.lang.String,​java.lang.Object> getDefaultValues​(java.lang.String type)
        Fetches all configured default values for a specified type.
        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

        java.util.Map<java.lang.String,​java.lang.Object> getDefaultValues​(java.lang.String type,
                                                                                java.util.Collection<java.lang.String> attributes)
        Fetches a subset of all configured default values for a specified type.
        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

        boolean isAssignableFrom​(TypeModel superModelType,
                                 TypeModel subModelType)
        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.
        Parameters:
        superModelType -
        subModelType -
        Returns:
        true if source type can be assigned to target type
      • isAssignableFrom

        boolean isAssignableFrom​(java.lang.String superModelTypeCode,
                                 java.lang.String subModelTypeCode)
        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.
        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
      • isInstance

        boolean isInstance​(TypeModel type,
                           java.lang.Object obj)
        Tests if the given object is an item instance of Type type.
        Parameters:
        type -
        obj -
        Returns:
        true if given object is an item instance of Type type
      • getPartOfAttributes

        java.util.Set<java.lang.String> getPartOfAttributes​(java.lang.String composedTypeCode)
        Provides all attribute qualifiers marked as part-of within the given type.
        Parameters:
        composedTypeCode - the composedType code to get part-of attributes for
        Returns:
        an empty set if type has no part-of attributes
      • hasAttribute

        boolean hasAttribute​(ComposedTypeModel type,
                             java.lang.String qualifier)
        Checks if type has attribute.
        Parameters:
        type - type
        qualifier - qualifier to check
        Returns:
        true if type has attribute
      • getModelClass

        <T extends ItemModel> java.lang.Class<T> getModelClass​(ComposedTypeModel type)
        Returns model class for a type.
        Parameters:
        type - type
        Returns:
        model class for a given type
      • getModelClass

        <T extends ItemModel> java.lang.Class<T> getModelClass​(java.lang.String typeCode)
        Returns model class for a type code.
        Parameters:
        typeCode - code of a type
        Returns:
        model class for a given type code
      • getAttributesForModifiers

        java.util.Set<AttributeDescriptorModel> getAttributesForModifiers​(java.lang.String composedTypeCode,
                                                                          AttributeModifierCriteria criteria)
        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.
        Parameters:
        composedTypeCode - the composed type code
        criteria - the criteria
        Returns:
        the attributes for modifiers