Class MdClassUtil


  • public class MdClassUtil
    extends Object
    Utilities for working with MdClass model.
    • Field Detail

      • GET_NAME

        public static final com.google.common.base.Function<MdObject,​String> GET_NAME
    • Method Detail

      • getConfiguration

        public static Configuration getConfiguration​(org.eclipse.emf.ecore.EObject eObject)
        Returns the configuration object for the given object, loaded in the same resource set as the given object. Returns null if the configuration object cannot be resolved for the given object.
        Parameters:
        eObject - not null, must be contained by a resource in a resource set
        Returns:
        the configuration object for the given object, loaded in the same resource set as the given object; null if the configuration object cannot be resolved for the given object
      • getConfigurationFeature

        public static org.eclipse.emf.ecore.EStructuralFeature getConfigurationFeature​(MdObject mdObject)
        Gets configuration feature by md-object.
        Parameters:
        mdObject - thr md-object
        Returns:
        the structural feature
      • getDefaultForm

        public static BasicForm getDefaultForm​(MdObject object,
                                               String defaultFormType)
        Searches for default form in Md object If such type of form is not presented in current object, assertion error will be thrown
        Parameters:
        object - - Md object where to search
        defaultFormType - - name of the feature, containing default form
        Returns:
        default form if found, or null otherwise
        Throws:
        AssertionError - - if passed defaultFormType is not presented in current Md object
      • getFeatureByCode

        public static org.eclipse.emf.ecore.EStructuralFeature getFeatureByCode​(org.eclipse.emf.ecore.EClass eClass,
                                                                                String code)
        Returns the feature of the child MdClass for the given code, or null.
        Parameters:
        code - of the child MdClass (not null)
        Returns:
        structural feature of the child MdClass for the given code, or null if the feature cannot be resolved
      • getForms

        public static List<BasicForm> getForms​(MdObject owner)
        Searches for forms, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic forms, if they were found in owner, never null
      • getCommands

        public static List<BasicCommand> getCommands​(MdObject owner)
        Searches for commands, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic commands, if they were found in owner, never null
      • getTemplates

        public static List<BasicTemplate> getTemplates​(MdObject owner)
        Searches for templates, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic templates, if they were found in owner, never null
      • getAttributes

        public static Optional<List<BasicFeature>> getAttributes​(MdObject owner)
        Searches for attributes, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic features, if they were found in owner, never null
      • getTabularSections

        public static Optional<List<BasicTabularSection>> getTabularSections​(MdObject owner)
        Searches for tabular section, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic tabular sections, if they were found in owner, never null
      • getResources

        public static Optional<List<Resource>> getResources​(MdObject owner)
        Searches for resources, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of resources, if they were found in owner, never null
      • getDimensions

        public static Optional<List<Dimension>> getDimensions​(MdObject owner)
        Searches for dimension, that are contained in owner object
        Parameters:
        owner - metadata object where to search. Cannot be null
        Returns:
        a list of basic features, if they were found in owner, never null
      • getMdClassCode

        public static String getMdClassCode​(org.eclipse.emf.ecore.EModelElement feature)
        Returns the code of the child MdClass for the given feature, or null if the code cannot be resolved. The code should be specified in the MdClass annotation on the feature.
        Parameters:
        feature - a structural feature (not null)
        Returns:
        the code of the child MdClass for the given feature, or null if the code cannot be resolved
      • getMdClassCodeRu

        public static String getMdClassCodeRu​(org.eclipse.emf.ecore.EModelElement feature)
        Returns the code_ru of the child MdClass for the given feature, or null if the code cannot be resolved. The code should be specified in the MdClass annotation on the feature.
        Parameters:
        feature - a structural feature (not null)
        Returns:
        the code_ru of the child MdClass for the given feature, or null if the code cannot be resolved
      • findFormByName

        public static BasicForm findFormByName​(MdObject object,
                                               String formName)
        Searches for forms (by name) in md object
        Parameters:
        object - - an object where to search
        formName - - name of the form to search
        findDefault - - if true, method will return default form.
        Returns:
        Form md object, or null if form not found
      • findCommandByName

        public static BasicCommand findCommandByName​(MdObject object,
                                                     String commandName)
        Searches for command (by name) in md object
        Parameters:
        object - - an object where to search
        commandName - - name of the command to search
        Returns:
        Form md object, or null if form not found
      • findTemplateByName

        public static BasicTemplate findTemplateByName​(MdObject object,
                                                       String templateName)
        Searches for templates (by name) in md object
        Parameters:
        object - - an object where to search
        templateName - - name of the template to search
        Returns:
        Template md object, or null if template not found
      • isMdClass

        public static boolean isMdClass​(org.eclipse.emf.ecore.EModelElement element)
        Returns whether the given element is annotated as MdClass.
        Parameters:
        element - a model element (not null)
        Returns:
        true if the given element has MdClass annotation; otherwise false
      • isCommonAttributeTarget

        public static boolean isCommonAttributeTarget​(org.eclipse.emf.ecore.EClass eClass)
        Returns whether objects of the given EClass are potential targets for common attribute application.
        Parameters:
        eClass -
        Returns:
        true if objects of the given EClass are potential targets for common attribute application; false otherwise
      • getCompatibilityMode

        public static CompatibilityMode getCompatibilityMode​(int major,
                                                             int minor,
                                                             int micro)
        Convert version numerical components to configuration CompatibilityMode enum
        Parameters:
        major - Major component of the version identifier, not negative.
        minor - Minor component of the version identifier, not negative.
        micro - Micro component of the version identifier, not negative.
        Returns:
        the compatibility mode for given version or null
      • getRealTypeDescription

        public static TypeDescription getRealTypeDescription​(TypeDescription typeDescription)
        Returns a real type description in case of a defined type. Otherwise, returns it as is.
        Parameters:
        typeDescription - the type description, cannot be null
        Returns:
        real type description, cannot be null
      • getProducedTypes

        public static MdTypes getProducedTypes​(MdObject mdObject)
        Produced types of specified MdObject
        Parameters:
        mdObject - the source object to gets produced types, cannot be null
        Returns:
        the instance of MdTypes as produced types for given MdObject, or null if specified object has no produced types.
      • getPluralFormOfModelObjectName

        public static String getPluralFormOfModelObjectName​(String modelObjectName)
        Returns the plural form of the given model object name.
        Parameters:
        modelObjectName - the singular form of the model object name, cannot be null
        Returns:
        the plural form, never null
      • isMobileApplicationUsePurposes

        public static boolean isMobileApplicationUsePurposes​(Collection<ApplicationUsePurpose> usePurposes)
        The specified collection of ApplicationUsePurpose-s is only for mobile applications
        Parameters:
        usePurposes - the collection of ApplicationUsePurpose elements for check, cannot be null
        Returns:
        true if given collection is only for mobile applications, false in otherwise