Hi,
I am having problems with cross referenced models using ATL.
Here is my context:
I execute Xtext as a stand-alone Java application to parse a set of files. As an output, I obtain a set of ecore model stored in a single resource set. I then apply a model transformation using ATL (still stand-alone). When executing the transformation, I get an error message saying that one of the referenced object is null but the trace contains the name of this object...
Here is the content of the resource (after saving it in a xmi file) that represents the object I take as input of my faulty transformation rule:
<componentInstance xmi:id="_TH4iUM62EeGfzdj5pK2F1w" name="the_mem" category="memory">
<ownedPropertyAssociation xmi:id="_TIPHoM62EeGfzdj5pK2F1w">
<property href="file:/home/etienne/Dev/propertyset/Memory_Properties.aadl2#//@ownedProperty.11"/>
<ownedValue xmi:id="_TIPHoc62EeGfzdj5pK2F1w">
<ownedValue xsi:type="aadl2:IntegerLiteral" xmi:id="_TIPHos62EeGfzdj5pK2F1w" value="80000"/>
</ownedValue>
</ownedPropertyAssociation>
<subcomponent xsi:type="aadl2:MemorySubcomponent" href="file:/home/etienne/test/arinc653-blackboard/test_blackboard.aadl2#//@ownedPublicSection/@ownedClassifier.1/@ownedMemorySubcomponent.0"/>
</componentInstance>
Now, here is the ATL rule that transforms this object:
rule Memory_Instance {
from
c : AADLI!ComponentInstance (c.category = #memory)
to
sub : AADLBA!MemorySubcomponent(
name <- c.name.debug('memory instance'),
ownedPropertyAssociation <- c.ownedPropertyAssociation->collect (e|thisModule.PropertyAssociation (e))
)
}
lazy rule PropertyAssociation {
from
p : AADLI!PropertyAssociation
to
p2 : AADLBA!PropertyAssociation (
property <- p.property.debug(' property')
)
}
When launching the model transformation, I allow inter model cross references:
Map<String, Object> options = new HashMap<String, Object>() ;
options.put("allowInterModelReferences", "true") ;
launcher.launch(EMFVMLauncher.RUN_MODE, new NullProgressMonitor(), options, atlModules) ;
When I execute my java standalone application, I obtain the following trace:
system instance: 'root.impl'
memory instance: 'the_mem'
property: MEMORY_PROPERTIES!Byte_Count
org.eclipse.m2m.atl.engine.emfvm.VMException: org.eclipse.m2m.atl.engine.emfvm.lib.OclUndefined cannot be cast to Property
What is funny is that the trace suggests that the Property object is null, while "Byte_Count" is actually the value of the field name in the object...
I did not find any solution; when debugging, I see that objects are correctly set, but I get this obscure behavior when executing the model transformation.
Thanks for your help,
Etienne.