Class MdTypeUtil


  • public class MdTypeUtil
    extends Object
    Type utilities.
    • Constructor Detail

      • MdTypeUtil

        public MdTypeUtil()
    • Method Detail

      • createArbitrartyType

        public static TypeItem createArbitrartyType​(Version version)
        Creates a new Arbitrary type for the given 1C:Enterprise runtime version.
        Parameters:
        version - the version of 1C:Enterprise runtime version, cannot be null
        Returns:
        a new arbitrary type for the given 1C:Enterprise runtime version, never null
      • createAnyRefType

        public static TypeItem createAnyRefType​(Version version)
        Creates a new AnyRef type for the given 1C:Enterprise runtime version.
        Parameters:
        version - the version of 1C:Enterprise runtime version, cannot be null
        Returns:
        a new any reference type for the given 1C:Enterprise runtime version, never null
      • createReferenceTypeProxy

        public static TypeItem createReferenceTypeProxy​(org.eclipse.core.resources.IProject project,
                                                        String fqn,
                                                        org.eclipse.emf.ecore.EReference producedTypeReference,
                                                        org.eclipse.emf.ecore.EReference typeReference)
        Creates a new proxy type that will refers to some metadata object. This may be usefull to crate a type with reference to some object, that is not yet exist in the provided project.

        Example of usage:

         // create a proxy to some unknown catalog; when it will be created, this proxy may be resolved
         TypeItem typeProxy = MdTypeUtil.createReferenceTypeProxy(project, "Catalog.UnknownCatalog",
             MdTypePackage.Literals.BASIC_DB_OBJECT_TYPES__REF_TYPE, MdTypePackage.Literals.MD_TYPE__TYPE);
        
         // set this proxy as type to other catalog attribute
         catalogAttribute.setType(MdTypeUtil.newTypeDescription(typeProxy));
         
        Parameters:
        project - the project that will contain referenced metadata object, cannot be null
        fqn - the FQN of the referenced metatada object, cannot be null
        producedTypeReference - the referenced object produced type reference, cannot be null
        typeReference - the produced type to Type reference, cannot be null
        Returns:
        a new proxy type that will refers to the metadata object with the provided parameters, never null
      • createDynamicTypeRegisterRecordsCollection

        public static Type createDynamicTypeRegisterRecordsCollection​(Document document,
                                                                      IEObjectProvider typeProvider)
        Creates dynamic type for property "RegisterRecords" for document context def
        Parameters:
        document - actual Document, can't be null
        typeProvider - special IEObjectProvider for TypeItem, can't be null
        Returns:
        created dynamic type, can't be null
      • getRecordSetTypeFromBasicRegister

        public static Type getRecordSetTypeFromBasicRegister​(BasicRegister register)
        Gets RecordSetType from BasicRegister
        Parameters:
        register - actual BasicRegister, can be null
        Returns:
        found type or null if register hasn't got RecordSetType or if register == null
      • getRefType

        public static Type getRefType​(BasicDbObject object)
        Returns Type representing reference to the data object.
        Parameters:
        object - BasicDbObject metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(Catalog object)
        Returns Type representing reference to the data object.
        Parameters:
        object - Catalog metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(ChartOfAccounts object)
        Returns Type representing reference to the data object.
        Parameters:
        object - ChartOfAccounts metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(Task object)
        Returns Type representing reference to the Task member.
        Parameters:
        object - Task metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the Task member. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(Document object)
        Returns Type representing reference to the data object.
        Parameters:
        object - Document metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(ChartOfCalculationTypes object)
        Returns Type representing reference to the data object.
        Parameters:
        object - ChartOfCalculationTypes metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(ChartOfCharacteristicTypes object)
        Returns Type representing reference to the data object.
        Parameters:
        object - ChartOfCharacteristicTypes metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(ExchangePlan object)
        Returns Type representing reference to the data object.
        Parameters:
        object - ExchangePlan metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getRefType

        public static Type getRefType​(Table object)
        Returns Type representing reference to the data object.
        Parameters:
        object - Table metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the data object. May be null if metadata object is not completely initialized.
      • getTypeProducer

        public static MdObject getTypeProducer​(TypeItem typeItem)
        Return MdObject that produced given type item.
        Parameters:
        typeItem - the type object, cannot by null
        Returns:
        MdObject that produced given type item, or null if given type is not produced by any mdObject
      • newTypeDescription

        public static TypeDescription newTypeDescription​(TypeItem type)
        Returns a new type description containing the given type.
        Parameters:
        type - type to be added to the type decription. May be null. In that case empty type description is cerated.
        Returns:
        a new type description containing the given type
      • newRefTypeDescription

        public static TypeDescription newRefTypeDescription​(Enum object)
        Returns a new type description for the ref field of the Enum.
        Parameters:
        object - Enum metadata object. May not be null.
        Returns:
        newly created type description.
      • newTypeDescription

        public static TypeDescription newTypeDescription()
        Returns a new type description which is initially empty.
        Returns:
        a new, empty type description
      • getRefType

        public static Type getRefType​(Enum object)
        Returns Type representing reference to the Enum member.
        Parameters:
        object - Enum metadata object. May not be null or proxy.
        Returns:
        Type representing reference to the Enum member. May be null if metadata object is not completely initialized.
      • isMetadataObjectType

        public static boolean isMetadataObjectType​(TypeItem item)
        Returns true if the given TypeItem is the metadata object type.
        Parameters:
        item - the TypeItem
        Returns:
        true if the given item is the metadata object type
      • isArbitraryType

        public static boolean isArbitraryType​(TypeDescription typeDescription)
        Returns true if the given TypeDescription is arbitrary type.
        Parameters:
        typeDescription - the TypeDescription object, can be null
        Returns:
        true if given TypeDescription have single arbitrary type, or empty type list, or equals null, false in otherwise
      • getSingleType

        public static TypeItem getSingleType​(TypeDescription typeDescription)
        Returns type item if given type description has single type.
        Parameters:
        typeDescription - the TypeDescription object, can be null
        Returns:
        the TypeItem if given TypeDescription have only one single not arbitrary type, or null in otherwise
        See Also:
        TypeDescriptionUtils#isArbitraryType(TypeDescription)
      • isSingleTypeWithName

        public static boolean isSingleTypeWithName​(TypeDescription typeDescription,
                                                   String typeName)
        Returns type item if given type description has single type with given name.
        Parameters:
        typeDescription - the TypeDescription object, can be null
        typeName - the name of expected type in given type description, cannot be null
        Returns:
        true if given TypeDescription have single type with given type name, false in otherwise
      • containsTypeWithName

        public static boolean containsTypeWithName​(TypeDescription typeDescription,
                                                   String typeName)
        Returns true if given type description contains type with given name.
        Parameters:
        typeDescription - the TypeDescription object, can be null
        typeName - the name of expected type in given type description, cannot be null
        Returns:
        true if given TypeDescription contains type with given type name, false in otherwise
      • isAttachedToBusinessProcess

        public static boolean isAttachedToBusinessProcess​(Task task)
        Returns true if given task is attached to any business process
        Parameters:
        task - a Task metadata object (not null)
        Returns:
        true if given task is attached to any business process or false otherwise
      • getBpNamesWithTask

        public static Collection<String> getBpNamesWithTask​(Task task)
        Returns list of business process names which referenced to given task.
        Parameters:
        task - the task (not null)
        Returns:
        list of business process names which referenced to given task (never null)
      • getRefTypeNames

        public static Collection<String> getRefTypeNames()
        Returns a collection of reference type english names such as AnyRef, BusinessProcessRef, etc.
        Returns:
        a collection of reference type names, never null
      • flatTypesAndMergeQualifiers

        public static TypeDescription flatTypesAndMergeQualifiers​(TypeDescription type,
                                                                  org.eclipse.emf.ecore.EObject context)
        Flats types and merges qualifiers, contained in source TypeDescription:
        • Single types will be copied as is from source to destination TypeDescription.
        • Type sets will be flatten to types and merges with existing types and then be copied to destination TypeDescription. If type set is DefinedType or characteristic then source and type set qualifiers will be merged.
        Parameters:
        type - the type, cannot be null.
        context - the context object, cannot be null.
        Returns:
        the flatten type, cannot be null
      • createPropertyFilterForCube

        public Property createPropertyFilterForCube​(Cube cube,
                                                    IEObjectProvider typeProvider)
        Creates dynamic property "Filter" for Cube context def.
        Parameters:
        register - actual Cube, can be null
        typeProvider - special IEObjectProvider for TypeItem, can't be null
        Returns:
        created property, can't be null
      • createPropertyFilterForTable

        public Property createPropertyFilterForTable​(Table table,
                                                     IEObjectProvider typeProvider)
        Creates dynamic property "Filter" for Table context def.
        Parameters:
        register - actual Table, can be null
        typeProvider - special IEObjectProvider for TypeItem, can't be null
        Returns:
        created property, can't be null
      • createPropertyFilterForSequence

        public Property createPropertyFilterForSequence​(Sequence sequence,
                                                        IEObjectProvider typeProvider)
        Creates dynamic property "Filter" for Sequence context def.
        Parameters:
        sequence - actual Sequence, can be null
        typeProvider - special IEObjectProvider for TypeItem, can't be null
        Returns:
        created property, cannot be null
      • newStringQualifiers

        public StringQualifiers newStringQualifiers​(int length,
                                                    boolean fixed)
        Returns a new string qualifiers.
        Parameters:
        length - a non-negative integer
        fixed -
        Returns:
        a new string qualifiers
      • newNumberQualifiers

        public NumberQualifiers newNumberQualifiers​(int precision,
                                                    int scale,
                                                    boolean nonNegative)
        Returns a new number qualifiers.
        Parameters:
        precision - a non-negative integer
        scale - a non-negative integer, may not be greater than precision
        nonNegative -
        Returns:
        a new number qualifiers
      • newDateQualifiers

        public DateQualifiers newDateQualifiers​(DateFractions dateFractions)
        Returns a new date qualifiers.
        Parameters:
        dateFractions - a value from DateFractions
        Returns:
        a new date qualifiers
      • newTypeDescription

        public TypeDescription newTypeDescription​(String platformTypeName,
                                                  IEObjectProvider typeProvider)
        Returns a new type description containing the given platform type.
        Parameters:
        platformTypeName - platform type name to be added to the type decription.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        a new type description containing the given type or empty type description if there is no platform type with given name.
      • newDescriptionTypeDescription

        public TypeDescription newDescriptionTypeDescription​(ExchangePlan object,
                                                             IEObjectProvider typeProvider)
        Returns a new type description for the description field of the ExchangePlan.
        Parameters:
        object - ExchangePlan metadata object, cannot be null
        typeProvider - IEObjectProvider provider for type item, cannot be null.
        Returns:
        new type description for the description field, never null
      • newDescriptionTypeDescription

        public TypeDescription newDescriptionTypeDescription​(Task object,
                                                             IEObjectProvider typeProvider)
        Returns a new type description for the description field of the Task.
        Parameters:
        object - Task metadata object, cannot be null
        typeProvider - IEObjectProvider provider for type item, cannot be null.
        Returns:
        new type description for the description field, never null
      • newCodeTypeDescription

        public TypeDescription newCodeTypeDescription​(Catalog object,
                                                      IEObjectProvider typeProvider)
        Returns a new type description for the code field of the Catalog.
        Parameters:
        object - Catalog metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the code field.
      • newCodeTypeDescription

        public TypeDescription newCodeTypeDescription​(ExchangePlan object,
                                                      IEObjectProvider typeProvider)
        Returns a new type description for the code field of the ExchangePlan.
        Parameters:
        object - Catalog metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the code field.
      • newDescriptionTypeDescription

        public TypeDescription newDescriptionTypeDescription​(Catalog object,
                                                             IEObjectProvider typeProvider)
        Returns a new type description for the description field of the Catalog.
        Parameters:
        object - Catalog metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the description field.
      • newOwnerTypeDescription

        public TypeDescription newOwnerTypeDescription​(Catalog object)
        Returns a new type description for the owner field of the Catalog.
        Parameters:
        object - Catalog metadata object. May not be null.
        Returns:
        new type description for the owner field.
      • newCodeTypeDescription

        public TypeDescription newCodeTypeDescription​(ChartOfCalculationTypes object,
                                                      IEObjectProvider typeProvider)
        Returns a new type description for the code field of the ChartOfCharacteristicTypes.
        Parameters:
        object - ChartOfCalculationTypes metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the code field.
      • newCodeTypeDescription

        public TypeDescription newCodeTypeDescription​(ChartOfCharacteristicTypes object,
                                                      IEObjectProvider typeProvider)
        Returns a new type description for the code field of the ChartOfCharacteristicTypes.
        Parameters:
        object - ChartOfCharacteristicTypes metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the code field.
      • newDescriptionTypeDescription

        public TypeDescription newDescriptionTypeDescription​(ChartOfCalculationTypes object,
                                                             IEObjectProvider typeProvider)
        Returns a new type description for the description field of the ChartOfCalculationTypes.
        Parameters:
        object - ChartOfCalculationTypes metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the description field.
      • newDescriptionTypeDescription

        public TypeDescription newDescriptionTypeDescription​(ChartOfCharacteristicTypes object,
                                                             IEObjectProvider typeProvider)
        Returns a new type description for the description field of the ChartOfCharacteristicTypes.
        Parameters:
        object - ChartOfCharacteristicTypes metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the description field.
      • newNumberTypeDescription

        public TypeDescription newNumberTypeDescription​(Document object,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the number field of the Document.
        Parameters:
        object - Document metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the number field.
      • newNumberTypeDescription

        public TypeDescription newNumberTypeDescription​(Task object,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the number field of the Task.
        Parameters:
        object - Task metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the number field.
      • newNumberTypeDescription

        public TypeDescription newNumberTypeDescription​(BusinessProcess object,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the number field of the BusinessProcess.
        Parameters:
        object - BusinessProcess metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the number field.
      • newStringTypeDescription

        public TypeDescription newStringTypeDescription​(int length,
                                                        boolean fixed,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the String type with the given qualifiers.
        Parameters:
        length - a non-negative integer
        fixed -
        typeProvider - IEObjectProvider provider for type item
        Returns:
        a new type description for the String type
      • newNumberTypeDescription

        public TypeDescription newNumberTypeDescription​(int precision,
                                                        int scale,
                                                        boolean nonNegative,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the Number type with the given qualifiers.
        Parameters:
        precision - a non-negative integer
        scale - a non-negative integer, may not be greater than precision
        nonNegative -
        typeProvider - IEObjectProvider provider for type item
        Returns:
        a new type description for the Number type
      • newBooleanTypeDescription

        public TypeDescription newBooleanTypeDescription​(IEObjectProvider typeProvider)
        Returns a new type description for the Boolean type with the given qualifiers.
        Parameters:
        typeProvider - IEObjectProvider provider for type item
        Returns:
        a new type description for the Boolean type
      • newDateTypeDescription

        public TypeDescription newDateTypeDescription​(DateFractions dateFractions,
                                                      IEObjectProvider typeProvider)
        Returns a new type description for the Date type with the given fractions.
        Parameters:
        dateFractions - a value from DateFractions
        typeProvider - IEObjectProvider provider for type item
        Returns:
        a new type description for the Date type
      • newPeriodTypeDescription

        public TypeDescription newPeriodTypeDescription​(InformationRegister object,
                                                        IEObjectProvider typeProvider)
        Returns a new type description for the period field of the InformationRegister.
        Parameters:
        object - InformationRegister metadata object. May not be null.
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for the period field.
      • newHeadTaskTypeDescription

        public TypeDescription newHeadTaskTypeDescription​(BusinessProcess businessProcess,
                                                          IEObjectProvider typeProvider)
        Returns a new type description with all TaskRefs
        Parameters:
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description with with all TaskRef-s
      • newRecorderTypeDescription

        public TypeDescription newRecorderTypeDescription​(BasicRegister object)
        Returns a new type description for the recorder field of the BasicRegister.
        Parameters:
        object - BasicRegister metadata object. May not be null.
        Returns:
        new type description for the recorder field.
      • newRecorderTypeDescription

        public TypeDescription newRecorderTypeDescription​(Sequence object)
        Returns a new type description for the recorder field of the Sequence.
        Parameters:
        object - Sequence metadata object. May not be null.
        Returns:
        new type description for the sequence field.
      • newRefTypeDescription

        public TypeDescription newRefTypeDescription​(BasicDbObject object)
        Returns a new type description for the ref field of the BasicDbObject.
        Parameters:
        object - Enum metadata object. May not be null.
        Returns:
        newly created type description.
      • newRefTypeDescription

        public TypeDescription newRefTypeDescription​(Table object)
        Returns a new type description for the ref field of the Table.
        Parameters:
        object - metadata object. May not be null.
        Returns:
        newly created type description.
      • newBusinessProcessDescription

        public TypeDescription newBusinessProcessDescription​(Task task)
        Returns a new type description for the BusinessProcess field of the Task.
        Parameters:
        task - Task metadata object. May not be null.
        Returns:
        newly created type description.
      • newBusinessProcessRoutePointDescription

        public TypeDescription newBusinessProcessRoutePointDescription​(Task task)
        Returns a new type description for the RoutePoint field of the Task.
        Parameters:
        task - Task metadata object. May not be null.
        Returns:
        newly created type description.
      • newNodeTypeDescription

        public TypeDescription newNodeTypeDescription​(MdObject mdObject)
        Returns a new type description for the Node field of the Changes table of given md object.
        Parameters:
        mdObject - metadata object. May not be null.
        Returns:
        newly created type description.
      • newPerformerTypeDescription

        public TypeDescription newPerformerTypeDescription​(Task task)
        Returns a new type description for the Performer parameter of the Task.TaskByPerformer.
        Parameters:
        task - Task metadata object. May not be null.
        Returns:
        newly created type description.
      • newFilterCriterionTypeDescription

        public TypeDescription newFilterCriterionTypeDescription​(FilterCriterion filterCriterion)
        Returns a new type description for the value parameter of the FilterCriterion select view.
        Parameters:
        filterCriterion - FilterCriterion metadata object. May not be null.
        Returns:
        newly created type description.
      • newDocumentJournalNumberTypeDescription

        public TypeDescription newDocumentJournalNumberTypeDescription​(List<Document> documents,
                                                                       IEObjectProvider typeProvider)
        Returns a new type description for Number field of Document Journal
        Parameters:
        documents - the list of registered documents
        typeProvider - IEObjectProvider provider for type item
        Returns:
        new type description for Number field of Document Journal
      • newRefTypeDescription

        public TypeDescription newRefTypeDescription​(FilterCriterion filterCriterion)
        Returns a new type description for the ref field of the FilterCriterion select view.
        Parameters:
        filterCriterion - FilterCriterion metadata object. May not be null.
        Returns:
        newly created type description.
      • newMainAddressingAttributeTypeDescription

        public TypeDescription newMainAddressingAttributeTypeDescription​(AddressingAttribute mainAddressingAttribute)
        Returns a new type description for the main addressing attribute field of the Task.
        Parameters:
        mainAddressingAttribute - the main addressing attribute. May not be null.
        Returns:
        newly created type description.
      • getBpTypesByCategory

        public List<TypeItem> getBpTypesByCategory​(Task task,
                                                   String typeCategory)
        Returns list of typeCategory types to business processes which has link to given Task.

        This implementation uses scopes, that's why there would be no resolving

        Parameters:
        task - the task (not null)
        typeCategory - type category (not null). Type categories:
        • BusinessProcessRef
        • BusinessProcessObject
        • BusinessProcessRoutePointRef
        Returns:
        list of typeCategory types to business processes which has link to given task
        See Also:
        IEObjectTypeNames