Skip to main content


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 08:14 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
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 16:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 10:37 Go to previous message
Kosala Yapa is currently offline Kosala YapaFriend
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: Thu Apr 25 05:24:27 GMT 2024

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

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

Back to the top