Package com.nomagic.magicdraw.ce
Class CodeEngineeringManager
java.lang.Object
com.nomagic.magicdraw.ce.CodeEngineeringManager
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CodeEngineeringSet
createCodeEngineeringSet
(String language, String dialect, String name, Project project, Package workingPackage, String workingDirectory) 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.static void
Performs code engineering for given code engineering set.static List<CodeEngineeringSet>
getAllCodeEngineeringSets
(Project project) Given a project, returns list of all available code engineering sets.static CodeEngineeringSet
getCodeEngineeringSet
(Project project, String language, String dialect, String name) Returns Code engineering set from given project, which matches language, dialect and name.static void
removeCodeEngineeringSet
(CodeEngineeringSet codeEngineeringSet) Given a codeEngineeringSet, removes it with all inner elements.static void
reverse
(CodeEngineeringSet ces, boolean showOptionDialog) Performs reverse engineering for given code engineering set.static void
setClassFieldCreationType
(Project project, String language, boolean asAttribute) Deprecated.static void
setClassFieldCreationType
(Project project, String language, com.nomagic.magicdraw.ce.core.rt.options.AttributeCreationType type) Given a project and language of Code engineering set and, sets the default Class field creation type.static void
setMergeModelAndCode
(Project project, boolean mergeCode) Reverse engineering option, for merging new code with model.static void
setResetAlreadyCreatedFields
(Project project, boolean reset) Reverse engineering option, to reset already created fields.static void
setResolveCollectionGenerics
(Project project, boolean resolve) Reverse engineering option, to enable resolve collection generic.static void
setReverseAnalysisOption
(Project project, boolean createClassifiersDependencies, boolean createPackageDependencies) Sets reverse engineering analysis options.
-
Constructor Details
-
CodeEngineeringManager
public CodeEngineeringManager()
-
-
Method Details
-
createCodeEngineeringSet
public static CodeEngineeringSet createCodeEngineeringSet(@Nonnull String language, @CheckForNull String dialect, @Nonnull String name, @Nonnull Project project, @CheckForNull Package workingPackage, @CheckForNull String workingDirectory) throws 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. UseCodeEngineeringConstants
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:
IllegalStateException
- if given language is not supported.
-
removeCodeEngineeringSet
public static void removeCodeEngineeringSet(@Nonnull CodeEngineeringSet codeEngineeringSet) throws IllegalStateException Given a codeEngineeringSet, removes it with all inner elements.- Parameters:
codeEngineeringSet
- set to be removed.- Throws:
IllegalStateException
- if code engineering set language is not supported.
-
getAllCodeEngineeringSets
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 String language, @CheckForNull String dialect, @Nonnull String name) throws 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:
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 String language, boolean asAttribute) throws 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:
IllegalStateException
- if given language is not supported.
-
setClassFieldCreationType
public static void setClassFieldCreationType(@Nonnull Project project, @Nonnull String language, com.nomagic.magicdraw.ce.core.rt.options.AttributeCreationType type) throws 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:
IllegalStateException
- if given language is not supported.
-
setResolveCollectionGenerics
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
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
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 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:
IllegalStateException
- if code engineering set language is not supported.
-
generate
Performs code engineering for given code engineering set.- Parameters:
ces
- code engineering set to be generated.- Throws:
IllegalStateException
- if code engineering set language is not supported.
-
setClassFieldCreationType(Project, String, AttributeCreationType)