Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Ordered unbound choices / EFeatureMapEntry
[Acceleo] Ordered unbound choices / EFeatureMapEntry [message #917937] Thu, 20 September 2012 15:22 Go to next message
Franck Malartic is currently offline Franck MalarticFriend
Messages: 5
Registered: September 2012
Junior Member
Hello,

I am new to Ecore and Acceleo so I'll try my best to be clear.

I've generated a model based on an XSD containing unbound choices. The order of the elements is important.

<xs:complexType name="MyChoicesType">
  <xs:sequence>
    <xs:choice maxOccurs="unbounded" minOccurs="0">
      <xs:element name="A" type="AType">
      </xs:element>
      <xs:element name="B" type="BType">
      </xs:element>
      <xs:element name="C" type="CType">
      </xs:element>
    </xs:choice>
  </xs:sequence>
</xs:complexType>


The model contains 4 lists: one for each element types, and a list of EFeatureMapEntry named "group".
What I understand from http://www.eclipse.org/modeling/emf/docs/overviews/FeatureMap.pdf is that I shall be able to retrieve the order of the elements thanks to the "group".

Now from the acceleo module, the iteration over the group is ok with:
[for (e: EFeatureMapEntry | sample.group)]

but I don't know how to get the value from the EFeatureMapEntry object since getValue() operation seems to not be available.
So the obvious question: is it possible, and if so, how ?

Thanks for your help,
Franck
Re: [Acceleo] Ordered unbound choices / EFeatureMapEntry [message #931534 is a reply to message #917937] Wed, 03 October 2012 09:44 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1638
Registered: July 2009
Senior Member
Hi Franck,

IIRC, the Feature maps are not modeled in the ecore metamodel as anything other than a DataType. In which case you cannot use them directly through Acceleo : you need to call a Java service that will call the "getValue" for you. See the answers on http://stackoverflow.com/questions/4760376/wrap-java-function-in-acceleo-in-eclipse if you never used a java service Smile.

Laurent Goubet
Obeo
Re: [Acceleo] Ordered unbound choices / EFeatureMapEntry [message #940205 is a reply to message #931534] Thu, 11 October 2012 12:17 Go to previous message
Franck Malartic is currently offline Franck MalarticFriend
Messages: 5
Registered: September 2012
Junior Member
Laurent,

Your solution works perfectly.

For other beginners, here is the wrapping example :

[query public getValue(entry : EFeatureMapEntry) : OclAny
    = invoke('org.eclipse.emf.ecore.util.FeatureMap$Entry', 
             'getValue()', 
             Sequence{entry}) /]


Nothing else is needed, that's great !

Thanks,
Franck
Previous Topic:[Acceleo]Using 2 metamodels in combination with 2 separate model instances
Next Topic:xtend2 dynamic classloading?
Goto Forum:
  


Current Time: Sun Nov 23 14:54:48 GMT 2014

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

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