Hi,
I'm trying to generate some come code from an UML model and modeled a simple class with a property of type "String" (UMLPrimitiveType#String).
The result of the generator is quite good except of the fact that the attributes' type is not generated. I found out that the "name" attribute of the PrimitiveTypeImpl instance is null.
Can anyone tell me what to do to get the correct value ("String") rendered into my java file.
My Xpand project is based on the sample project and modified for use of uml profiles.
This is my model (My.uml):
<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_2esIoL5-Ed-d4M2Dk0udMA" name="hello">
<packagedElement xmi:type="uml:Class" xmi:id="_5Q6YoL5-Ed-d4M2Dk0udMA" name="HelloWorld">
<ownedAttribute xmi:id="__iMwgL5-Ed-d4M2Dk0udMA" name="who" visibility="private">
<type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
</ownedAttribute>
</packagedElement>
</uml:Model>
This is my template:
«IMPORT uml»
«DEFINE main FOR Model»
«EXPAND javaClass FOREACH ownedElement.typeSelect(Class)»
«ENDDEFINE»
«DEFINE javaClass FOR Class»
«FILE name+".java"»
«visibility» class «name» {
«FOREACH ownedAttribute AS p»
«p.visibility» «p.type.name» «p.name»;
public void set«p.name.toFirstUpper()»(«p.type.name» «p.name») {
this.«p.name» = «p.name»;
}
public «p.type.name» get«p.name.toFirstUpper()»() {
return «p.name»;
}
«ENDFOREACH»
}
«ENDFILE»
«ENDDEFINE»
This is my workflow:
<?xml version="1.0"?>
<workflow>
<property name="model" value="hello.uml/src/My.uml" />
<property name="src-gen" value="src-gen" />
<!-- set up EMF for standalone execution -->
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
<platformUri value=".."/>
<registerGeneratedEPackage value="org.eclipse.uml2.uml.UMLPackage"/>
</bean>
<!-- instantiate metamodel -->
<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
<!-- load model and store it in slot 'model' -->
<component class="org.eclipse.emf.mwe.utils.Reader">
<uri value="platform:/resource/${model}" />
<modelSlot value="model" />
</component>
<!-- check model -->
<component class="org.eclipse.xtend.check.CheckComponent">
<metaModel idRef="mm_emf"/>
<checkFile value="metamodel::Checks" />
<emfAllChildrenSlot value="model" />
</component>
<!-- generate code -->
<component class="org.eclipse.xpand2.Generator">
<metaModel idRef="mm_emf"/>
<expand
value="template::Template::main FOR model" />
<outlet path="${src-gen}" >
<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
</outlet>
</component>
</workflow>
Greets and thanx
Christian