Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Transform EString identifier to EReference
[ATL] Transform EString identifier to EReference [message #667338] Thu, 28 April 2011 08:41 Go to next message
Melanie Bats is currently offline Melanie BatsFriend
Messages: 35
Registered: July 2009
Member
Hello,

I am using ATL to transform a DSL model (named RPY) to another DSL model (named RPYB).

In the IN model, the elements class and port are defined like this:
<class id="1"/>
<class id="2">
<port dependency="1"/>
</class>

Here is an extract of the IN metamodel:
<eClassifiers xsi:type="ecore:EClass" name="Class">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Port">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="dependency" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>

in the IN metamodel attributes id and dependency are EStrings.

In the OUT model I will have:
<classes guid="1"/>
<classes guid="2">
<ports xsi:type="rpyb:PortBinding" requiredInterfaces="1"/>
</classes>

Here is an extract of the OUT metamodel:
<eClassifiers xsi:type="ecore:EClass" name="ClassBinding">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="guid" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" iD="true"/>
</eClassifiers>

<eClassifiers xsi:type="ecore:EClass" name="PortBinding">
<eStructuralFeatures xsi:type="ecore:EReference" name="requiredInterfaces" upperBound="-1"
eType="#//ClassBinding"/>
</eClassifiers>

in the OUT model the guid is defined with ID=true and the requiredInterfaces is an EReference.

How to write the ATL rule to generate from the string class id in the IN model, the associated ClassBinding in the OUT model?

A solution is to get all the class instances from IN model and search the one which defines the expected id :
rule Port{
from
port: RPY!Port
to
portb: RPYB!PortBinding(
guid <- port.id,
requiredInterfaces <- port.getRequiredInterfaces()
)
}
helper context RPY!Port def: getRequiredInterfaces(): Sequence(RPY!Class) =
RPY!Class.allInstances()->select(class|self.getRequiredInterfaceIds()- >includes(class.id));

Problem, as my model is huge, transformation is really too slow!

Is there another way to do without using allInstances?

Thanks for your help,
Melanie
Re: [ATL] Transform EString identifier to EReference [message #667356 is a reply to message #667338] Thu, 28 April 2011 10:00 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can map each id to its corresponding class :

helper def : map : Map(String,RPY!Class) =
RPY!Class.allInstances()->iterate(e; res : Map(String,RPY!Class) = Map{} | res.including(e.id,e));

Then your binding becomes :
requiredInterfaces <- thisModule.map.get(port.id)

In fact, the map references Classes, but with the resolve mechanism of ATL, in the end it will reference the ClassBindings resulting from the transformation of the Classes.
Re: [ATL] Transform EString identifier to EReference [message #667540 is a reply to message #667356] Fri, 29 April 2011 12:54 Go to previous message
Melanie Bats is currently offline Melanie BatsFriend
Messages: 35
Registered: July 2009
Member
Hello,

Thanks, it works fine now.

Melanie
Previous Topic:adding to containment features with eSet
Next Topic:[ATL]struts-config rules with MoDisco generix XML Model
Goto Forum:
  


Current Time: Thu Apr 18 23:57:12 GMT 2024

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

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

Back to the top