Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [MMT] EMFInjector to inject objects
[MMT] EMFInjector to inject objects [message #986899] Thu, 22 November 2012 10:18 Go to next message
Hassan BAZOUN is currently offline Hassan BAZOUN
Messages: 54
Registered: April 2012
Member
Hello,

i want to use the EMFInjector (or an extension of this class) in order to inject an object into an IModel is this possible?

i don't want to use an xmi file but the object directly !!! i found some limits since am using CDO Objects and thus the resource's content of such objects is a list of all available cdo objects and not the desired object.

in brief i want to do the following:

source metamodel is a .ecore file (OK)
target metamodel is a .ecore file (OK)
source model is an object containing other children object (possible??)
taregt model is an xmi file (OK)

i don't want to use xmi file for the input model ?

any ideas and suggestions are welcomed.

thanks in advance.
HB


[Updated on: Thu, 22 November 2012 10:18]

Report message to a moderator

Re: [MMT] EMFInjector to inject objects [message #986904 is a reply to message #986899] Thu, 22 November 2012 10:39 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 607
Registered: July 2009
Senior Member
Hello,

You can load any EMF metamodel/model registered in the EMF Registry by using its URI.
Instead of passing a path for the injection, you can use a string such as "URI:MyModelURI" (cf. the Javadoc of the EMFInjector.inject methods).

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: [MMT] EMFInjector to inject objects [message #986951 is a reply to message #986904] Thu, 22 November 2012 13:55 Go to previous messageGo to next message
Hassan BAZOUN is currently offline Hassan BAZOUN
Messages: 54
Registered: April 2012
Member
hey Hugo,

I read the javadoc of the EMFInjector, my question was to inject an Object called MyLibrary for example and to apply the atl transformation rules to this object.

Is it obligatory to use .xmi files as input?

The reason of my question is that i don't want to create XMI files and resources, so to avoid this i want to pass directly the object to be transformed (root object of my model)

Did you det my point?

Thanks.
HB
Re: [MMT] EMFInjector to inject objects [message #986995 is a reply to message #986951] Thu, 22 November 2012 17:46 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 607
Registered: July 2009
Senior Member
In EMF a model is a Resource (or several ones).
As I told you in my previous post, in ATL you are not forced to load a model from a file and you can also do it from the memory using the EMF model (Resource) URI.
Your root EObject should be contained in a Resource, so you can get its URI.
Anyway, for more EMF related questions, using the EMF forum would be preferable.

I hope this helps.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: [MMT] EMFInjector to inject objects [message #987078 is a reply to message #986995] Fri, 23 November 2012 10:34 Go to previous messageGo to next message
Hassan BAZOUN is currently offline Hassan BAZOUN
Messages: 54
Registered: April 2012
Member
there are two scenarios:


1-IModel bsmModel = modelFactory.newModel(bsmMetamodel);
((EMFInjector)injector).inject(bsmModel, "transformation/inputFile.xmi");

2-IModel bsmModel1 = modelFactory.newModel(bsmMetamodel);((CDOInjector)injector).inject(bsmModel1, bsmServiceSystemModel);

in the first one am injecting from xmi file
in the second am using a customised class CDOInjector which does the following

public void inject(IModel targetModel, BsmServiceSystemModel bsmServiceSystemModel){
    ResourceSet resourceSet =    ((EMFModelFactory)targetModel.getModelFactory()).getResourceSet();
    Resource resource = resourceSet.createResource(URI.createURI("new-model.xmi"));
    BsmServiceSystemModel copyBsm = EcoreUtil.copy(bsmServiceSystemModel);
    resource.getContents().add(copyBsm);
    inject(targetModel, resource);//call the EMFInjector.inject
	}


the difference is that in the first the bsmModel's content contains a DynamicEObjectImpl while in the second it contains an EObject

while launching the tranformation the atl file is applied to the first while no result for the second one.
Re: [MMT] EMFInjector to inject objects [message #987372 is a reply to message #986899] Mon, 26 November 2012 10:48 Go to previous messageGo to next message
Hassan BAZOUN is currently offline Hassan BAZOUN
Messages: 54
Registered: April 2012
Member
Hey,

Can anybody confirm that the resource's contents must be of type DynamicEObjectImpl so that ATL transformation is launched properly?

Thanks.
HB
Re: [MMT] EMFInjector to inject objects [message #990618 is a reply to message #987372] Thu, 13 December 2012 13:16 Go to previous messageGo to next message
Greg L is currently offline Greg L
Messages: 9
Registered: November 2012
Junior Member
Hi Hassan,

Did you find the answer to your question?
I am also facing the problem with resource injecting to model using EMFInjector. Resource is injected, but I can not retrieve its content with the TCS.extractor due to the same problem as you have.

Thanks in advance for some ideas.. suggestions!
Greg
Re: [MMT] EMFInjector to inject objects [message #990619 is a reply to message #990618] Thu, 13 December 2012 13:24 Go to previous message
Hassan BAZOUN is currently offline Hassan BAZOUN
Messages: 54
Registered: April 2012
Member
//Hi Hassan,
//
//Did you find the answer to your question?
//I am also facing the problem with resource injecting to model using EMFInjector. //Resource is injected, but I can not retrieve its content with the TCS.extractor due //to the same problem as you have.
//
//Thanks in advance for some ideas.. suggestions!
//Greg

Hello Greg,

I didn't find answers in the forum concerning this subject, it seems to me that there are some limits here. For the moment i moved to another subject, so i stopped on trying and searching. if you find anything please give me a sign Razz and i will do the same.

Good Luck
HB
Previous Topic:Keeping an exact reference to source model element
Next Topic:ATL ant task standalone application
Goto Forum:
  


Current Time: Thu Oct 23 17:57:36 GMT 2014

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

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