Advanced use

Here’re some advanced uses with Astah API.

XML Input/Output

XML Input/Output is supported only in Astah Professional.
Use ProjectAccessor to input/output XML Input/Output from the API. But first you need to register the project in ProjectAccessor (Reference: Accessing the project).

Function Method
Output exportXMI(String fileName)
Input importXMI(String projectName)
importXMI(String projectName, boolean isIgnoreModelVersion)

Reference Model Management

Reference Model Management is supported only in Astah Professional.
To set or update referenced projects with API, call ProjectAccessor’s method.

Function Method
Add addReferenceProject(String path)
Update updateReferenceProject(String path)
Get Status getReferenceProjectStatus(String path)
Get Path getReferenceProjectPaths()
Change Path changeReferenceProject(String fromPath, String toPath)
Clear clearReferenceProject(String path)
Remove removeReferenceProject(String path)

Easy Merge

Easy Merge is supported only in Astah Professional.
To run Easy Merge from API, call ProjectAccessor#easyMerge(String path, boolean isKeepBase) method.

Programming Language

You can set programming languages for each project in Astah. (See how)

Get language information

Language information is stored as a TaggedValue in eachProject model (IModel) if any is specified.
So you can get the language information by TaggedValues.

Language Item Tagged Value
Java Java Project [Key] jude.profile.java
[Value] true/false
C# C# Project [Key] jude.profile.c_sharp
[Value] true/false
C++ C++ Project [Key] jude.profile.c_plus
[Value] true/false

Set language

You can set language information with BasicModelEditor.

Language Method
Java setLanguageJava(IModel project, boolean doApply)
C# setLanguageCSharp(IModel project, boolean doApply)
C++ setLanguageCPlus(IModel project, boolean doApply)


public void setLanguageCSharp(BasicModelEditor modelEditor, IModel project, boolean doApply)
        throws InvalidEditingException {
    modelEditor.setLanguageCSharp(project, doApply);
}

Find out language info1

In Astah, you can check Java, C++ or C# for each Class, Attribute and Operation.

language_tab

When any language is checked, it is added to the model as a stereotype internally. So by getting the stereotype, you can see which language property is set to each Class, Attribute and Operation.

Java

Model Stereotype
Class (IClass) Java Class
Attribute (IAttribute) Java Attribute
Operation (IOperation) Java Method

C

Model Stereotype
Class (IClass) C# Class
Attribute (IAttribute) C# Attribute
Operation (IOperation) C# Method

C++

Model Stereotype
Class (IClass) C++ Class
Attribute (IAttribute) C++ Attribute
Operation (IOperation) C++ Method

Find out language info2

When you add any language-related properties in [Language] tab to Classes, Attributes and Operations, the information will be added to these models as TaggedValue, Stereotype or attributes.

Target : Class (IClass), Attribute (IAttribute), Operation (IOperation)

Java

Item Stereotype Model
<<enum>> <<enum>> Class (IClass)
<<enum constant>> <<enum constant>> Attribute (IAttribute)
Item Tagged Value Model
annotations [Key] jude.java.annotations
[Value] Optional
Class (IClass)
Attribute (IAttribute)
Operation (IOperation)
@interface [Key] jude.java.atmark_interface
[Value] true/false
Class (IClass)
strictfp [Key] jude.java.strictfp
[Value] true/false
Class (IClass)
Operation (IOperation)
transient [Key] jude.java.transient
[Value] true/false
Attribute (IAttribute)
volatile [Key] jude.java.volatile
[Value] true/false
Attribute (IAttribute)
synchronized [Key] jude.java.synchronized
[Value] true/false
Operation (IOperation)
native [Key] jude.java.native
[Value] true/false
Operation (IOperation)
Item Model Attribute Model
[Class] final IClass.isLeaf() Class (IClass)
[Attribute] final IAttribute.isChangeable() Attribute (IAttribute)
[Operation] final IClass.isLeaf() Operation (IOperation)

C

Item Stereotype Tagged Value Model
<<delegate>> <<delegate>> - Class (IClass)
<<struct>> <<struct>> - Class (IClass)
<<enum>> <<enum>> - Class (IClass)
attributes - [Key] jude.c_sharp.attributes
[Value] Optional
Class (IClass)
Attribute (IAttribute)
Operation (IOperation)
sealed - [Key] jude.c_sharp.sealed
[Value] true/false
Class (IClass)
static - [Key] jude.c_sharp.static
[Value] true/false
Class (IClass)
internal - [Key] jude.c_sharp.internal
[Value] true/false
Class (IClass)
Attribute (IAttribute)
Operation (IOperation)
<<property>> <<property>> - Attribute (IAttribute)
<<property>> get - [Key] jude.c_sharp.property_get
[Value] true/false
Attribute (IAttribute)
<<property>> set - [Key] jude.c_sharp.property_set
[Value] true/false
Attribute (IAttribute)
<<enum constant>> <<enum constant>> - Attribute (IAttribute)
const - [Key] jude.c_sharp.const
[Value] true/false
Attribute (IAttribute)
volatile - [Key] jude.c_sharp.volatile
[Value] true/false
Attribute (IAttribute)
<<event>> <<event>> - Operation (IOperation)
<<event>> add - [Key] jude.c_sharp.event_add
[Value] true/false
Operation (IOperation)
<<event>> remove - [Key] jude.c_sharp.event_remove
[Value] true/false
Operation (IOperation)
<<indexer>> <<indexer>> - Operation (IOperation)
<<indexer>> get - [Key] jude.c_sharp.indexer_get
[Value] true/false
Operation (IOperation)
<<indexer>> set - [Key] jude.c_sharp.indexer_set
[Value] true/false
Operation (IOperation)
extern - [Key] jude.c_sharp.extern
[Value] true/false
Operation (IOperation)
override - [Key] jude.c_sharp.override
[Value] true/false
Operation (IOperation)
sealed - [Key] jude.c_sharp.sealed
[Value] true/false
Operation (IOperation)
unsafe - [Key] jude.c_sharp.unsafe
[Value] true/false
Operation (IOperation)
virtual - [Key] jude.c_sharp.virtual
[Value] true/false
Operation (IOperation)
extension method - [Key] jude.c_sharp.extension_method
[Value] true/false
Operation (IOperation)
Item Model Attribute Model
readonly IAttribute#isChangeable() Attribute (IAttribute)

C++

Item Tagged Value Model Attribute
Type Modifier [Key] type_modifier
[Value] Type Modifie String
ITemplateBinding#getActualParameterTypeModifier() IElement#getTypeModifier()
Item Stereotype Model
<<enum>> <<enum>> Class (IClass)
<<struct>> <<struct>> Class (IClass)
<<union>> <<union>> Class (IClass)
<<enum constant>> <<enum constant>> Attribute (IAttribute)
Item Tagged Value Model
const [Key] jude.c_plus.const
[Value] true/false
Attribute (IAttribute), Operation (IOperation)
mutable [Key] jude.c_plus.mutable
[Value] true/false
Attribute (IAttribute)
volatile [Key] jude.c_plus.volatile
[Value] true/false
Attribute (IAttribute)
friend [Key] jude.c_plus.friend
[Value] true/false
Operation (IOperation)
explicit [Key] jude.c_plus.explicit
[Value] true/false
Operation (IOperation)
inline [Key] jude.c_plus.inline
[Value] true/false
Operation (IOperation)
virtual [Key] jude.c_plus.virtual
[Value] true/false
Operation (IOperation)