Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to call an EOperation in atl program?
How to call an EOperation in atl program? [message #899947] Fri, 03 August 2012 07:21 Go to next message
Kosala Yapa is currently offline 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 #899968 is a reply to message #899947] Fri, 03 August 2012 09:22 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
someone has a solution to this issue?

Thanks
K
Re: How to call an EOperation in atl program? [message #900807 is a reply to message #899968] Wed, 08 August 2012 14:28 Go to previous message
Kosala Yapa is currently offline 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

Previous Topic:Execute atl in a java program
Next Topic:EMF version as the meta-model
Goto Forum:
  


Current Time: Fri Oct 31 13:03:56 GMT 2014

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

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