|
|
|
|
Re: ATL transformation from EObject [message #908937 is a reply to message #907205] |
Thu, 06 September 2012 05:08   |
Eclipse User |
|
|
|
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.06682 seconds