Table of Contents
Enterprise Architect Notes
Help / Resources
- The official EA forum
- http://www.eausergroup.org/
- EA Resources
- Online User Guide
Model Transformations
To transform the Platform Independent Model (PIM) into a Java UML model EA MDA transformation is used.
Problems
When modifying the Platform Independent Model (PIM) be aware that not every modification will be transmitted by the present templates to the Java UML model:
- Constraints on classes or attributes will not be transmitted -> document constraints as notes! see BestPractices#Documentation1
- Deleting classes or connectors does not work
- Multiplicity changes for classes and for attributes might not be trasmitted
- Persistence changes of classes might not be transmitted.
Proven to work
- Renaming classes, attributes, operations or connectors is no problem
- Deleting attributes or operations is no problem
- Modification of connectors (including multiplicity) is no problem
Java Model
The following modified EA transformation templates have been used for the CommonDataModel
Class
%if elemType != "Class" and elemType != "Interface"%
%endTemplate%
%elemType%
{
%TRANSFORM_REFERENCE("Class")%
%TRANSFORM_CURRENT("language")%
language="Java"
%list="ClassBase" @separator="\n" @indent=" "%
%list="ClassInterface" @separator="\n" @indent=" "%
%list="InnerClass" @separator="\n" @indent=" "%
%if elemType=="Class"%
%list="Attribute" @separator="\n" @indent=" "%
%endIf%
%list="Attribute__AsProperties" @separator="\n" @indent=" " attScope=="Public"%
%list="Operation" @separator="\n" @indent=" "%
}
%list="Connector" @separator="\n"%
Properties
$attName=$parameter1
$type=$parameter2
$propertyName=$attName
$first2 = %LEFT($attName,2)%
Operation
{
%TRANSFORM_REFERENCE()%
%if $type=="Boolean" and $first2 == "is" %
name=%qt%$attName%qt%
%else%
$propertyName=%CONVERT_NAME($propertyName, "camel case", "pascal case")%
name=%qt%%genOptJavaGetPrefix%$propertyName%qt%
%endIf%
stereotype="property get"
scope="Public"
type=%qt%$type%qt%
code=%qt%return $attName;%qt%
Tag{name="attribute_name" value=%qt%$attName%qt%}
}
Operation
{
%TRANSFORM_REFERENCE()%
%if $type=="Boolean"%
$propertyName=%REMOVE_PREFIX($propertyName,"is")%
%endIf%
$propertyName=%CONVERT_NAME($propertyName, "camel case", "pascal case")%
name=%qt%%genOptJavaSetPrefix%$propertyName%qt%
stereotype="property set"
scope="Public"
type="void"
Parameter
{
name="newVal"
type=%qt%$type%qt%
}
code=%qt%$attName = newVal;%qt%
Tag{name="attribute_name" value=%qt%$attName%qt%}
}
JUnit Model
Class
%if elemType!="Class" or classLanguage!="Java"%
%endTemplate%
Class
{
%TRANSFORM_REFERENCE("TestClass")%
name=%qt%%className%Test%qt%
language="Java"
stereotype="junit4Test"
Operation
{
name="setUpClass"
stereotype="Test"
static="true"
scope="public"
type="void"
Tag
{
name="throws"
value="Exception"
}
}
Operation
{
name="setUp"
stereotype="Test"
scope="public"
type="void"
Tag
{
name="throws"
value="Exception"
}
}
Operation
{
name="tearDownClass"
stereotype="Test"
static="true"
scope="public"
type="void"
Tag
{
name="throws"
value="Exception"
}
}
Operation
{
name="tearDown"
stereotype = "Test"
scope="public"
type="void"
Tag
{
name="throws"
value="Exception"
}
}
\n
%list="Operation" @separator="\n" @indent=" " opScope=="Public"%
}
Dependency
{
%TRANSFORM_REFERENCE("SourceDependency")%
Source
{
%TRANSFORM_REFERENCE("TestClass")%
}
Target
{
guid=%qt%%classGUID%%qt%
}
}
Operation
$name=%opName%
$exists=%list="Operation__Exists" @separator="" opScope=="Public" and $name==opName%
%if $exists!="T"%
$name+=%list="Parameter" @separator=""%
%endIf%
Operation
{
name=%qt%$name%qt%
stereotype="Test"
scope="public"
constant="true"
type="void"
}
Code Generation Templates
Also see Macro documentation
Documentation
- Structured documentation will not be generated. Only notes fields end up in the final annotations, no matter if xml schema, java code or sql. See forum discussion at http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=suggestions;action=display;num=1186742348;start=0#0
Java
File
$COMMENT="WARNING: DO NOT MODIFY THIS TEMPLATE BELOW THIS POINT" /** * Copyright (C) 2007 EDIT * European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu * * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */\n %ImportSection%\n %list="Class" @separator="\n\n"%
Class
%ClassNotes% %if classStereotype=="superclass"% @MappedSuperclass %elseIf classPersistence=="Persistent"% @Entity %endIf% %PI=" "% %ClassDeclaration% %ClassBody%
Class Body
%if elemType == "Interface"%
%PI="\n\n"%
{
%list="InnerClass" @separator="\n\n" @indent="\t"%
%list="Attribute" @separator="\n" @indent="\t"%
%list="Operation" @separator="\n\n" @indent="\t"%
}
%endTemplate%
{
\tstatic Logger logger = Logger.getLogger(%className%.class);\n
%PI="\n\n"%
%list="InnerClass" @separator="\n\n" @indent="\t"%
%list="Attribute" @separator="\n" @indent="\t"%
$ops=""
%if genOptGenConstructor == "T" and classHasConstructor != "T"%
$ops+="\tpublic "+%className%+"(){\n\n\t}"
%endIf%
%if genOptGenDestructor == "T" and classHasDestructor != "T"%
$ops+="\n\n\tpublic void finalize() throws Throwable {\n"
$ops+=%classHasParent=="T" ? "\t\tsuper.finalize();" : ""% + "\n\t}"
%endIf%
%list="Operation" @separator="\n\n" @indent="\t"%
}
Import Section
%if packagePath != "" and packagePath != "." and packagePath != ".\\"% package %packagePath%; \n %endIf% $imports = %fileImports% + "\n" $imports += %fileHeaders% + "\n" $imports += "import org.apache.log4j.Logger;\n" %if classStereotype == "junit4Test"% $imports += "import org.junit.*;\n" $imports += "import static org.junit.Assert.*;\n" %endIf% %if classPersistence == "Persistent"% $imports += "import java.util.*;\n" $imports += "import javax.persistence.*;\n" %endIf% $imports += %list="Import" @separator="\n" importFromAggregation=="T" or importFromAssociation=="T" or importFromAtt=="T" or importFromDependency=="T" or importFromGeneralization=="T" or importFromMeth=="T" or importFromParam=="T" or importFromRealization=="T"% %REMOVE_DUPLICATES($imports, "\n")%
Attribute Note
$notes=%attNotes% %WRAP_COMMENT($notes, "120", "", "//")%
Operation
%OperationNotes% $prefix3=%LEFT(opName,3)% %if opStereotype!="property get" and $prefix3 == "get" and opStereotype != "Test"% @Transient %elseIf opStereotype == "Test"% %if opName == "setUpClass"% @BeforeClass %elseIf opName == "tearDownClass"% @AfterClass %elseIf opName == "setUp"% @Before %elseIf opName == "tearDown"% @After %else% @Test %endIf%%endIf% %PI=""% %OperationDeclaration% %if elemType == "Interface"% ; %else% %OperationBody% %endIf%
