How to call an EOperation in atl program? [message #899947] |
Fri, 03 August 2012 07:21 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Hi,
I defined an hexToInt(string) EOperation in the ecore diagram(within the Module class). Then I call that operation in an ATL rule.
lazy rule rule_getModule{
from
b:source!ModuleItem
to
d:target!Module(
s7ModuleReference <- b.ModuleReference,
isSelectedWithinStep7<-b.IsSelected
)
do{
d.deviceID<-d.hexToInt(b.getIdentNumber());
}
}
I did debug the atl program. It seems to me that ATL VM cannot find the hexToInt() operation.
This gives an error at hexToInt() operation call,
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: OUT!<unnamed>.hexToInt(java.lang.String)
at rule_getModule#40(TPF2PSSu2.atl[85:15-85:45])
I set source.ecore, target.ecore, input.xml and output.xml at run configuration.
Can someone help me to fix this error?
Thanks in advance.
K
[Updated on: Fri, 03 August 2012 07:55] Report message to a moderator
|
|
|
|
Re: How to call an EOperation in atl program? [message #900807 is a reply to message #899968] |
Wed, 08 August 2012 14:28 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Hi all,
Hope this info is useful.
I defined EOperations in the target model and load them using its URI.
code example:
public void loadModels(String inputModelPath) throws ATLCoreException{
ResourceSet resourceSet = getResourceSet();
EMFModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
//inject path of the source meta model to IReferenceModel instance
IReferenceModel sourceMetamodel = factory.newReferenceModel();
injector.inject(sourceMetamodel, this.getSourceMetamodelPath());
//inject path of the target meta model from URI to IReferenceModel instance
IReferenceModel targetMetamodel = factory.newReferenceModel();
injector.inject(targetMetamodel, getPackage_eNS_URI());
//create new model instance and inject source model
this.inModel = factory.newModel(sourceMetamodel);
injector.inject(inModel, inputModelPath);
//create new model instance for target model
this.outModel = factory.newModel(targetMetamodel);
}
In order to load the target model, I am using "getPackage_eNS_URI()", which gives the URI of the target model. I defined Eoperations in the target model.
Kosala
[Updated on: Thu, 09 August 2012 08:43] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.09293 seconds