|
|
|
|
|
|
|
Re: How to call an EOperation in atl program? [message #900575 is a reply to message #900511] |
Tue, 07 August 2012 15:37 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Thanks.
My problem is, yes I defined EOperation (hexToInt(String)) signature at target.ecore diagram, however the EOperation is implemented at the code base, which is generated from the target.genmodel.
How to call this hexToInt() in my ATL module? This is my problem.
Can I use run configuration settings to call this operation? I do not think so, because run configuration is not linked with generated code. (is there any way to make that link?)
As the other option,
I created an ATL plugin, and trying to run as a java application.
Properties file:
# Metamodels paths or nsUris
TPF2PSSu2.metamodels.source = file:/C:/..../source.ecore
TPF2PSSu2.metamodels.target = file:/C:/.../target.ecore
loading models:
/**
* Load the input and input/output models, initialize output models.
* @generated
*/
public void loadModels(String inModelPath) throws ATLCoreException {
ModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IReferenceModel sourceMetamodel = factory.newReferenceModel();
injector.inject(sourceMetamodel, getMetamodelUri("source"));
IReferenceModel targetMetamodel = factory.newReferenceModel();
injector.inject(targetMetamodel, getMetamodelUri("target"));
this.inModel = factory.newModel(sourceMetamodel);
injector.inject(inModel, inModelPath);
this.outModel = factory.newModel(targetMetamodel);
}
I still get the error:
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: OUT!<unnamed>.hexToInt(java.lang.String)
at rule_getModule#40(TPF2PSSu2.atl[87:15-87:45])
Yes, I can understand, this launcher is not yet connected with the generated code.
Is there any approach to load the target meta model from the generated code?
It looks to me some modification is needed at
injector.inject(targetMetamodel, getMetamodelUri("target"));
this.inModel = factory.newModel(sourceMetamodel);
I really appriciate any help to solve this problem.
Thanks
Kosala
[Updated on: Tue, 07 August 2012 15:41] Report message to a moderator
|
|
|
Re: How to call an EOperation in atl program? [message #900669 is a reply to message #900575] |
Wed, 08 August 2012 06:23 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Kosala,
Comments below.
On 07/08/2012 5:37 PM, Kosala Yapa wrote:
> Thanks.
>
> but my problem is, yes I defined EOperation at target.ecore, but the
> EOperation (hexToInt(String)) defined at the code base, which is
> generated from the target.genmodel.
So you have a generated model and it compiles okay?
>
> How call this hexToInt() in my ATL module? This is my problem.
This is an ATL question. I don't know the answer.
>
> Can I use run configuration settings to call this operation? I do not
> think so, because run configuration is not linked with generated code.
> (is there any way to make that link?)
I think this is an ATL question as well.
>
> As the other option,
> I created an ATL plugin, and trying to run as a java application.
>
> Properties file:
> # Metamodels paths or nsUris
> TPF2PSSu2.metamodels.source = file:/C:/..../source.ecore
> TPF2PSSu2.metamodels.target = file:/C:/.../target.ecore
>
>
> loading models:
>
> /**
> * Load the input and input/output models, initialize output models.
> * @generated
> */
> public void loadModels(String inModelPath) throws ATLCoreException {
> ModelFactory factory = new EMFModelFactory();
> IInjector injector = new EMFInjector();
> IReferenceModel sourceMetamodel = factory.newReferenceModel();
> injector.inject(sourceMetamodel, getMetamodelUri("source"));
> IReferenceModel targetMetamodel = factory.newReferenceModel();
>
>
> injector.inject(targetMetamodel, getMetamodelUri("target"));
> this.inModel = factory.newModel(sourceMetamodel);
> injector.inject(inModel, inModelPath);
> this.outModel = factory.newModel(targetMetamodel);
> }
>
>
> I still get the error:
>
> org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found:
> OUT!<unnamed>.hexToInt(java.lang.String)
> at rule_getModule#40(TPF2PSSu2.atl[87:15-87:45])
>
> Yes, I can understand, this launcher is not yet connected with the
> target model generated code.
In a launcher for an Eclipse application you can specify which bundles
should be part of the application.
>
>
> Is there any approach to load the target meta model from the generated
> code?
>
> It looks to me some modification is needed at
> injector.inject(targetMetamodel, getMetamodelUri("target"));
> this.inModel = factory.newModel(sourceMetamodel);
>
>
> I really appriciate any help to solve this problem.
Best you ask on the ATL newsgroup questions that are specific to ATL.
>
> Thanks
> Kosala
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to call an EOperation in atl program? [message #900703 is a reply to message #900669] |
Wed, 08 August 2012 08:37 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Thanks for all. I got it working.
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
Kosala
[Updated on: Thu, 09 August 2012 08:49] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04047 seconds