Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [xtend] bidrectional references not set with two ecore models
[xtend] bidrectional references not set with two ecore models [message #625843] Wed, 22 September 2010 10:36 Go to next message
Richard Wood is currently offline Richard WoodFriend
Messages: 29
Registered: January 2010
Junior Member
Hello

I have two ecore models where one extends from the other.

I am trying to set a bidirectional reference between two elements with xtend, which works fine if I would be using only one ecore model.

PPP and AAA are elements of model Base
PPP references AAA
BBB is an element of model Extended
BBB extends from AAA

In xtend the following code

let bbb = new BBB :
bbb.setPpp(new PPP)

creates an error message
The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@48edb5 (name: PPP) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@1049d3 (name: PPP) (instanceClassName: null) (abstract: false, interface: false)'


Any help would be appreciated
Thanks
Richard

Ecore models attached
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Base"
    nsURI="http:///Base.ecore" nsPrefix="Base">
  <eClassifiers xsi:type="ecore:EClass" name="AAA">
    <eStructuralFeatures xsi:type="ecore:EReference" name="ppp" ordered="false" unique="false"
        eType="#//PPP" eOpposite="#//PPP/aaa"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="PPP">
    <eStructuralFeatures xsi:type="ecore:EReference" name="aaa" ordered="false" unique="false"
        upperBound="-1" eType="#//AAA" containment="true" eOpposite="#//AAA/ppp"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false" lowerBound="1"
        eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>


<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Extended"
    nsURI="http:///Extended.ecore" nsPrefix="Extended">
  <eClassifiers xsi:type="ecore:EClass" name="BBB" eSuperTypes="Base.ecore#//AAA"/>
</ecore:EPackage>
Re: [xtend] bidrectional references not set with two ecore models [message #626001 is a reply to message #625843] Wed, 22 September 2010 11:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello Richard,

i cannot reproduce this using this workflow and extension:

<workflow>

	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup">
		<registerEcoreFile value="src/metamodel/base.ecore" />
		<registerEcoreFile value="src/metamodel/extended.ecore" />
	</bean>
	
	<component class="org.eclipse.xtend.XtendComponent">
		<metaModel class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel" />
		<invoke value="template::test::getThePPP()" />
		<outputSlot value="model" /> 
	</component>
	
	<component class="org.eclipse.emf.mwe.utils.Writer">
		<uri value="test.xmi" />
		<modelSlot value="model" />
	</component>

</workflow>


import Extended;

Base::PPP getThePPP() :
let bbb = new BBB :
bbb.setPpp(new Base::PPP) ->
bbb.ppp;


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [xtend] bidrectional references not set with two ecore models [message #626213 is a reply to message #625843] Wed, 22 September 2010 12:48 Go to previous messageGo to next message
Richard Wood is currently offline Richard WoodFriend
Messages: 29
Registered: January 2010
Junior Member
Thanks a lot Christian

It was the workflow definition. The registering of ecore files did the trick.

I thought it was also possible to achieve the same result with multiple beans.

<bean id="mmExtended" 
	class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
	<metaModelFile value="Extended.ecore"/>
</bean>
<bean id="mmBase" 
	class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
	<metaModelFile value="Base.ecore"/>
</bean>

<component class="org.eclipse.xtend.XtendComponent">
	<metaModel idRef="mmExtended"/>
	<metaModel idRef="mmBase"/>
	<invoke value="template::test::getThePPP()" />
	<outputSlot value="model" /> 
</component>


Is there a possible solution with this kind of setup?

[Updated on: Wed, 22 September 2010 12:48]

Report message to a moderator

Re: [xtend] bidrectional references not set with two ecore models [message #626236 is a reply to message #626213] Wed, 22 September 2010 13:02 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i think this kind of setup is not possible with dynamic emf.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[Acceleo] Problem by passing null to a template
Next Topic:[xtend] problems with uml2 type adaption when migrating
Goto Forum:
  


Current Time: Thu Apr 25 16:53:01 GMT 2024

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

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

Back to the top