Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » m2m.atl.core.IModel- How to pull out objects?
m2m.atl.core.IModel- How to pull out objects? [message #882796] Thu, 07 June 2012 04:14 Go to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
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 #883015 is a reply to message #882796] Thu, 07 June 2012 12:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
HI

Your question was answerred a coup[le of days ago.

Regards

Ed Willink

On 07/06/2012 09:14, Kosala Yapa wrote:
> 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 Go to previous message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
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);
Previous Topic:Why isn't my profile applied?
Next Topic:How to retrieve index of statement in java model?
Goto Forum:
  


Current Time: Sat Aug 30 08:22:54 EDT 2014

Powered by FUDForum. Page generated in 0.04239 seconds