|
|
Re: ATL transformation from EObject [message #907190 is a reply to message #907101] |
Mon, 03 September 2012 13:38 |
|
Hello Hugo
Thanks so much for your reply and for the execution Java example. It have been very usefull.
I have been looking those method, but all of them are looking for a file. I have seen the follow form:
public void inject(IModel targetModel,
java.io.InputStream source,
java.util.Map<java.lang.String,java.lang.Object> options)
throws ATLCoreException
Perhaps I can get a InputStream from the Resource of my model and use it.
Thanks
|
|
|
Re: ATL transformation from EObject [message #907205 is a reply to message #907190] |
Mon, 03 September 2012 14:18 |
Hugo Bruneliere Messages: 674 Registered: July 2009 |
Senior Member |
|
|
If you handle an EMFInjector, you have several implementations of the "inject" method, for instance:
- inject(IModel targetModel, String source, Map<String, Object> options) - the "source" parameter can be an EMF URI (among other possible options as I told you before, cf. the Javadoc of that method)
- inject(IModel targetModel, Resource mainResource) - the "mainResource" parameter directly corresponds to the EMF model you want to load
Best regards,
Hugo
--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
|
|
|
Re: ATL transformation from EObject [message #908937 is a reply to message #907205] |
Thu, 06 September 2012 09:08 |
|
Hello Hugo.
Thanks for your reply. I was not seen this method because I was using EMFInjector form the interface IInjector, and there, this method don't exists.
I have been trying this form of inject a model (inject(IModel targetModel, Resource mainResource)) but I don't know what happen, It's not working::
For test it, I have create a very simple metamodel, and I have instance it using EMF:
Persona p = MailFactory.eINSTANCE.createPersona();
p.setName("Jose");
p.setEmail("jose@jose.com");
Persona p2 = MailFactory.eINSTANCE.createPersona();
p2.setName("Marta");
p2.setEmail("marta@marta.com");
Mail m = MailFactory.eINSTANCE.createMail();
m.setMessage("hello, how are you?");
m.setFrom(p);
m.getTo().add(p2);
Them I create a resource, and I add this model to it.
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(URI.createURI("file:/home/jozemi/output.prueba"));
resource.getContents().add(m);
(I don't registry the extension and other, because I thinks it's not necessary for the example, Isn't it?)
Well, I have a very short transformation only for try:
When I use this method:
IModel mailModel = modelFactory.newModel(mailMetamodel);
injector.inject(mailModel,resource);
It's like if may model was empty, however, if I persist the model:
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
And I use this other form:
IModel mailModel = modelFactory.newModel(mailMetamodel);
injector.inject(mailModel,"file:/home/jozemi/output.prueba");
It works perfectly.
I don't know if I'm forgetting something or I'm doing something wrong
Thanks in advance for your time
Best regards,
José Miguel.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02075 seconds