[ATL] Transform EString identifier to EReference [message #667338] |
Thu, 28 April 2011 04:41  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.04056 seconds