Class CodeEngineeringManager


  • @OpenApiAll
    public class CodeEngineeringManager
    extends java.lang.Object
    Dedicated to perform Code Engineering reverse/generate task using MagicDraw OpenApi. It has static methods to create, remove, set some reverse settings for given code engineering set.
    • Constructor Detail

      • CodeEngineeringManager

        public CodeEngineeringManager()
    • Method Detail

      • createCodeEngineeringSet

        public static CodeEngineeringSet createCodeEngineeringSet​(@Nonnull
                                                                  java.lang.String language,
                                                                  @CheckForNull
                                                                  java.lang.String dialect,
                                                                  @Nonnull
                                                                  java.lang.String name,
                                                                  @Nonnull
                                                                  Project project,
                                                                  @CheckForNull
                                                                  Package workingPackage,
                                                                  @CheckForNull
                                                                  java.lang.String workingDirectory)
                                                           throws java.lang.IllegalStateException
        Given a language + dialect, name and working package of Code Engineering Set and project where to add this CES, creates new Code Engineering Set instance.
        Parameters:
        language - Language of Code Engineering Set. Use CodeEngineeringConstants to get List of languages.
        dialect - Dialect of language, this is dedicated for C++ or DDL CES. If language has no dialect, use null.
        name - Name of Code Engineering Set.
        project - project where to add new code engineering set.
        workingPackage - Working package code engineering set.
        workingDirectory - Directory of working files. This is path where files are located fore reverse, or where new files will be generated.
        Returns:
        created Code Engineering Set instance.
        Throws:
        java.lang.IllegalStateException - if given language is not supported.
      • removeCodeEngineeringSet

        public static void removeCodeEngineeringSet​(@Nonnull
                                                    CodeEngineeringSet codeEngineeringSet)
                                             throws java.lang.IllegalStateException
        Given a codeEngineeringSet, removes it with all inner elements.
        Parameters:
        codeEngineeringSet - set to be removed.
        Throws:
        java.lang.IllegalStateException - if code engineering set language is not supported.
      • getAllCodeEngineeringSets

        public static java.util.List<CodeEngineeringSet> getAllCodeEngineeringSets​(@Nonnull
                                                                                   Project project)
        Given a project, returns list of all available code engineering sets.
        Parameters:
        project - project of code engineering sets.
        Returns:
        List of available code engineering sets.
      • getCodeEngineeringSet

        public static CodeEngineeringSet getCodeEngineeringSet​(@Nonnull
                                                               Project project,
                                                               @Nonnull
                                                               java.lang.String language,
                                                               @CheckForNull
                                                               java.lang.String dialect,
                                                               @Nonnull
                                                               java.lang.String name)
                                                        throws java.lang.IllegalStateException
        Returns Code engineering set from given project, which matches language, dialect and name.
        Parameters:
        project - MD project, where code engineering set should be.
        language - Language of code engineering set. Use CodeEngineeringConstants.Languages to get constants.
        dialect - dialect of language. Dedicated for C++ or DDL. Use CodeEngineeringConstants.Dialects to get constants.
        name - name of code engineering set.
        Returns:
        code engineering set or null.
        Throws:
        java.lang.IllegalStateException - if given language is not supported.
      • setReverseAnalysisOption

        public static void setReverseAnalysisOption​(@Nonnull
                                                    Project project,
                                                    boolean createClassifiersDependencies,
                                                    boolean createPackageDependencies)
        Sets reverse engineering analysis options. Applies to all code engineering sets for given project.
        Parameters:
        project - MagicDraw project, where to apply this option.
        createClassifiersDependencies - True to create classifiers dependencies.
        createPackageDependencies - True to create package dependencies.
      • setClassFieldCreationType

        @Deprecated
        public static void setClassFieldCreationType​(@Nonnull
                                                     Project project,
                                                     @Nonnull
                                                     java.lang.String language,
                                                     boolean asAttribute)
                                              throws java.lang.IllegalStateException
        Given a project and language of Code engineering set and, sets the default Class field creation as attribute if asAttribute field is true, and association if false.
        Parameters:
        project - MagicDraw project.
        language - Code Engineering set language.
        asAttribute - true, if creation type is Attribute, false if creation type is association.
        Throws:
        java.lang.IllegalStateException - if given language is not supported.
      • setClassFieldCreationType

        public static void setClassFieldCreationType​(@Nonnull
                                                     Project project,
                                                     @Nonnull
                                                     java.lang.String language,
                                                     com.nomagic.magicdraw.ce.core.rt.options.AttributeCreationType type)
                                              throws java.lang.IllegalStateException
        Given a project and language of Code engineering set and, sets the default Class field creation type.
        Parameters:
        project - project.
        language - Code Engineering set language.
        type - class field creation type.
        Throws:
        java.lang.IllegalStateException - if given language is not supported.
      • setResolveCollectionGenerics

        public static void setResolveCollectionGenerics​(Project project,
                                                        boolean resolve)
        Reverse engineering option, to enable resolve collection generic. Applies for all project's code engineering sets.
        Parameters:
        project - MD project.
        resolve - True, to resolve, false to not resolve.
      • setResetAlreadyCreatedFields

        public static void setResetAlreadyCreatedFields​(@Nonnull
                                                        Project project,
                                                        boolean reset)
        Reverse engineering option, to reset already created fields. Applies for all project's code engineering sets.
        Parameters:
        project - MD project.
        reset - true - reset, false - not reset.
      • setMergeModelAndCode

        public static void setMergeModelAndCode​(@Nonnull
                                                Project project,
                                                boolean mergeCode)
        Reverse engineering option, for merging new code with model. Applies for all project's code engineering sets.
        Parameters:
        project - MD project.
        mergeCode - True to merge, false for not (default).
      • reverse

        public static void reverse​(@Nonnull
                                   CodeEngineeringSet ces,
                                   boolean showOptionDialog)
                            throws java.lang.IllegalStateException
        Performs reverse engineering for given code engineering set.
        Parameters:
        ces - code engineering set, to be reversed.
        showOptionDialog - True to show code engineering option dialog, False for silent reverse.
        Throws:
        java.lang.IllegalStateException - if code engineering set language is not supported.
      • generate

        public static void generate​(@Nonnull
                                    CodeEngineeringSet ces)
                             throws java.lang.IllegalStateException
        Performs code engineering for given code engineering set.
        Parameters:
        ces - code engineering set to be generated.
        Throws:
        java.lang.IllegalStateException - if code engineering set language is not supported.