allprog
allprog

Reputation: 16790

Type field of Property not filled in for UML PrimitiveType in Xpand

I have an XPT template that generates text from a UML model. This is the excerpt I use on the attributes of a class

«FOREACH attribute AS a»
    Id: «a.name»
    Type: «a.type.name»
«ENDFOREACH»

All works well as long as the type is a class from the model itself. But if it is a primitive type, then all of the fields, including the name, is set to null. If I change «a.type.name» to «a.type», then the response is something like this:

org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@6e315086 (eProxyURI:
     pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String)

The debugger shows that only the eStorage private field is set on the object that is why the toString() produces the output above.

Interestingly the same expression in Acceleo is evaluated correctly:

[query public getType(t : Type) : String = t.name /]

Question: how can I get the type field of attributes be filled in for primitive uml types in Xtend?

EDIT: Issue narrowed down to this question: EProxy URI does not resolve in ecore model

Upvotes: 4

Views: 783

Answers (2)

Ferenc Magnucz
Ferenc Magnucz

Reputation: 11

My original solution is here.

After two days of searching, I found the solution.

The solution is write here: http://kompilatory.iiar.pwr.edu.pl/wiki/index.php/Acceleo/Getting_Started_33#Generating_java_beans

I had to modify the MANIFEST.MF and the Generate.java file in the following way.

  1. I had to add the org.eclipse.uml2.uml.resources as a new dependency.

  2. Moreover, I had to modify the Generate.java file in the following way.

2.1. The registerResourceFactories(ResourceSet resourceSet) method had to be set to "@generated NOT"

2.2. and the last line of the method had to be uncommented and added a semicolon ";" to the end of the line. UMLResourcesUtil.init(resourceSet);

2.3. And finally, had to be added a new import line. "import org.eclipse.uml2.uml.resources.util.UMLResourcesUtil;"

Upvotes: 1

thSoft
thSoft

Reputation: 22670

The code generated by Acceleo can resolve the unusual pathmap:// eProxyURIs. By default, a simple Xpand template or Xtend code can't resolve them. See this question for more details and the solution.

Upvotes: 1

Related Questions