Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How can i iterate throught my emf model from a gmf editor without parsing the xml model file?
How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #644091] Thu, 09 December 2010 13:13 Go to next message
lalakis  is currently offline lalakis Friend
Messages: 48
Registered: October 2009
Member
I have successfully created a GMF editor which draws models based on my EMF model.What i wanted to do is to iterate through my model's EClasses .Can this be achieved at runtime through my plugin code without having to read the xml file that the gmf editor creates ?Is there such an API from EMF?

[Updated on: Thu, 09 December 2010 14:12]

Report message to a moderator

Re: How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #644162 is a reply to message #644091] Thu, 09 December 2010 17:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Is your model serialized to a file that's separate from GMF's notation
model for the diagram. If so, you can load that directly and traverse it.

iraklis wrote:
> I have successfully created a GMF editor which draws models based on
> my EMF model.What i wanted to do is to iterate through the model
> objects .Can this be achieved at runtime my plugin code from without
> having to read the xml file that the gmf editor creates ?Is there such
> an API from EMF?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #644178 is a reply to message #644162] Thu, 09 December 2010 18:42 Go to previous messageGo to next message
lalakis  is currently offline lalakis Friend
Messages: 48
Registered: October 2009
Member
Ed Merks wrote on Thu, 09 December 2010 12:26
Is your model serialized to a file that's separate from GMF's notation
model for the diagram. If so, you can load that directly and traverse it.

iraklis wrote:
> I have successfully created a GMF editor which draws models based on
> my EMF model.What i wanted to do is to iterate through the model
> objects .Can this be achieved at runtime my plugin code from without
> having to read the xml file that the gmf editor creates ?Is there such
> an API from EMF?


What do you mean separate from GMF notation?The model finally is saved into an xmi file.
Also i do not know how to start to traverse it.I do not want to use xml parsers etc.Is there any simple example which loads the xmi file and travers it?
Thanks
Re: How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #644208 is a reply to message #644178] Thu, 09 December 2010 21:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Comments below.

iraklis wrote:
> Ed Merks wrote on Thu, 09 December 2010 12:26
>> Is your model serialized to a file that's separate from GMF's
>> notation model for the diagram. If so, you can load that directly
>> and traverse it.
>>
>> iraklis wrote:
>> > I have successfully created a GMF editor which draws models based
>> on > my EMF model.What i wanted to do is to iterate through the model
>> > objects .Can this be achieved at runtime my plugin code from
>> without > having to read the xml file that the gmf editor creates ?Is
>> there such > an API from EMF?
>
>
> What do you mean separate from GMF notation?The model finally is saved
> into an xmi file.
The notation model (diagram) is saved to a file as well. Is it a
separate file from your domain model or the same file.
> Also i do not know how to start to traverse it.I do not want to use
> xml parsers etc.Is there any simple example which loads the xmi file
> and travers it?
If you invoke Generate Test Code there's an XyzExample.java that shows
how to load and save instances. I'd suggest reading some of the
introductory overview documentation before asking more questions.
> Thanks


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #645042 is a reply to message #644208] Wed, 15 December 2010 10:45 Go to previous messageGo to next message
lalakis  is currently offline lalakis Friend
Messages: 48
Registered: October 2009
Member
Thanks.I finally figure it out and i can iterate throught my model with the EMF API.I have another question.
I have an EClass at my ecore metamodel which has a connection to another Eclass.This EReference it is called connection at my ecore.What i am seeing at my xmi file after the creation of an instance of my metamodel is something like this :
<?xml version="1.0" encoding="UTF-8"?>
<atagmetamodel:ATAGPlan xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:atagmetamodel="http://atagmetamodel/1.0">
  <DataItem Name="Temp" Connection="//@InputChannel.0"/>
  <InputChannel Connection="//@Task.1" Interest="efd"/>
  <Task Name="Tempgen" Connection="//@OutputChannel.0" BasicInstantiationParameter="h" InstantiationAbilityAttribute="12" InstantiationRegionAttribute="all" ParameterforFiringRule="1"/>
  <Task Name="Temp" BasicInstantiationParameter="6" InstantiationAbilityAttribute="3" InstantiationRegionAttribute="2" ParameterforFiringRule="j"/>
  <OutputChannel Connection="//@DataItem.0" Interest="local"/>
</atagmetamodel:ATAGPlan>


As you can see each connection reference is like an attribute at the xmi file but it has a different syntax : //@<Type of the object that is connected to >.<number>
How can i take advantage of this syntax and grab the connected object?I mean how could i know that //@OutputChannel1.0 indexes at my specific OutputChannel.There is no unique id identifier.

Thank you


Ed Merks wrote on Thu, 09 December 2010 16:58
Comments below.

iraklis wrote:
> Ed Merks wrote on Thu, 09 December 2010 12:26
>> Is your model serialized to a file that's separate from GMF's
>> notation model for the diagram. If so, you can load that directly
>> and traverse it.
>>
>> iraklis wrote:
>> > I have successfully created a GMF editor which draws models based
>> on > my EMF model.What i wanted to do is to iterate through the model
>> > objects .Can this be achieved at runtime my plugin code from
>> without > having to read the xml file that the gmf editor creates ?Is
>> there such > an API from EMF?
>
>
> What do you mean separate from GMF notation?The model finally is saved
> into an xmi file.
The notation model (diagram) is saved to a file as well. Is it a
separate file from your domain model or the same file.
> Also i do not know how to start to traverse it.I do not want to use
> xml parsers etc.Is there any simple example which loads the xmi file
> and travers it?
If you invoke Generate Test Code there's an XyzExample.java that shows
how to load and save instances. I'd suggest reading some of the
introductory overview documentation before asking more questions.
> Thanks

Re: How can i iterate throught my emf model from a gmf editor without parsing the xml model file? [message #645150 is a reply to message #645042] Wed, 15 December 2010 16:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Comments below.

iraklis wrote:
> Thanks.I finally figure it out and i can iterate throught my model
> with the EMF API.I have another question.
> I have an EClass at my ecore metamodel which has a connection to
> another Eclass.This EReference it is called connection at my
> ecore.What i am seeing at my xmi file after the creation of an
> instance of my metamodel is something like this :
> <?xml version="1.0" encoding="UTF-8"?>
> <atagmetamodel:ATAGPlan xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:atagmetamodel="http://atagmetamodel/1.0">
> <DataItem Name="Temp" Connection="//@InputChannel.0"/>
> <InputChannel Connection="//@Task.1" Interest="efd"/>
> <Task Name="Tempgen" Connection="//@OutputChannel.0"
> BasicInstantiationParameter="h" InstantiationAbilityAttribute="12"
> InstantiationRegionAttribute="all" ParameterforFiringRule="1"/>
> <Task Name="Temp" BasicInstantiationParameter="6"
> InstantiationAbilityAttribute="3" InstantiationRegionAttribute="2"
> ParameterforFiringRule="j"/>
> <OutputChannel Connection="//@DataItem.0" Interest="local"/>
> </atagmetamodel:ATAGPlan>
>
> As you can see each connection reference is like an attribute at the
> xmi file but it has a different syntax : //@<Type of the object that
> is connected to >.<number>
> How can i take advantage of this syntax and grab the connected
> object?I mean how could i know that //@OutputChannel1.0 indexes at my
> specific OutputChannel.There is no unique id identifier.
EMF handles the for you when deserializing so when you inspect your
in-memory instances you should just see the resolved objects themselves.
>
> Thank you
>
>
> Ed Merks wrote on Thu, 09 December 2010 16:58
>> Comments below.
>>
>> iraklis wrote:
>> > Ed Merks wrote on Thu, 09 December 2010 12:26
>> >> Is your model serialized to a file that's separate from GMF's >>
>> notation model for the diagram. If so, you can load that directly >>
>> and traverse it.
>> >>
>> >> iraklis wrote:
>> >> > I have successfully created a GMF editor which draws models
>> based >> on > my EMF model.What i wanted to do is to iterate through
>> the model >> > objects .Can this be achieved at runtime my plugin
>> code from >> without > having to read the xml file that the gmf
>> editor creates ?Is >> there such > an API from EMF?
>> >
>> >
>> > What do you mean separate from GMF notation?The model finally is
>> saved > into an xmi file.
>> The notation model (diagram) is saved to a file as well. Is it a
>> separate file from your domain model or the same file.
>> > Also i do not know how to start to traverse it.I do not want to use
>> > xml parsers etc.Is there any simple example which loads the xmi
>> file > and travers it?
>> If you invoke Generate Test Code there's an XyzExample.java that
>> shows how to load and save instances. I'd suggest reading some of
>> the introductory overview documentation before asking more questions.
>> > Thanks
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Setting initial values with Dynamic Feature Delegation
Next Topic:[CDO] Race condition between commit() and resolveConflicts()?
Goto Forum:
  


Current Time: Fri Apr 26 09:39:19 GMT 2024

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

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

Back to the top