m2m.atl.core.IModel- How to pull out objects? [message #882796] |
Thu, 07 June 2012 04:14  |
Eclipse User |
|
|
|
Hi,
My ATL transformation is from sourceMetamodel to targetMetamodel.
In my ATL transformation outModel(of the type IModel) is attached to targetMetamodel.
I can extract outModel into xmi file using EMFExtractor (org.eclipse.m2m.atl.core.emf.EMFExtractor). But, I cannot use this to get object instances inside outModel.
I tried following coding,
Object deviceObject=outModel.getReferenceModel().getMetaElementByName("Device");
System.out.println(outModel.getElementsByType(deviceObject));
This only display the type of the element, such as Device, but without instances.
I am just wondering, if someone knows how to pull out object instances from the outModel, other than extracting to an xmi file? Is there any class/package available something like (org.eclipse.m2m.atl.core.emf.EMFExtractor) to pull out object instances from IModels?
Thanks in advance !
Kosala
|
|
|
|
Re: m2m.atl.core.IModel- How to pull out objects? [message #883349 is a reply to message #883015] |
Fri, 08 June 2012 06:37  |
Eclipse User |
|
|
|
done ! may be useful for someone.
final PipedOutputStream outputStream = new PipedOutputStream();
PipedInputStream inputStream = new PipedInputStream(outputStream);
new Thread(new Runnable() {
public void run() {
try {
(new EMFExtractor()).extract(outModel, outputStream, null);
} catch (ATLCoreException e) {
e.printStackTrace();
}
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
XMIResourceImpl resource = new XMIResourceImpl();
resource.load( inputStream, new HashMap<Object,Object>());
Project root = (Project)resource.getContents().get(0);
System.out.println(root);
|
|
|
Powered by
FUDForum. Page generated in 0.28405 seconds