Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [xpand] name of UMLPrimitiveType not generated (=null)
[xpand] name of UMLPrimitiveType not generated (=null) [message #558419] Sun, 12 September 2010 16:48 Go to next message
Christian Huelsmeier is currently offline Christian HuelsmeierFriend
Messages: 12
Registered: September 2010
Junior Member
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
Re: [xpand] name of UMLPrimitiveType not generated (=null) [message #558422 is a reply to message #558419] Sun, 12 September 2010 17:20 Go to previous message
Christian Huelsmeier is currently offline Christian HuelsmeierFriend
Messages: 12
Registered: September 2010
Junior Member
Ok. I figured it out myself.
This is the solution that works for me:

<?xml version="1.0"?>
<workflow>
	<property name="model" value="src/My.uml" />
	<property name="src-gen" value="src-gen" />

	<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true" />
	 
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="${model}" />
		<modelSlot value="model" />
	</component>
	 
	<component class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>


Christian
Previous Topic:Problem by cast from AnyTypeImpl to ModelImpl
Next Topic:Toolchain for source code generation from UML?
Goto Forum:
  


Current Time: Thu Apr 25 10:23:15 GMT 2024

Powered by FUDForum. Page generated in 0.03216 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top