|Parsing of ecore models [message #1089258]
||Sun, 18 August 2013 08:19
| Phil H
Registered: November 2012
First my use case: I want to extend my EMF editor so that users can import other ecore models, which differs in structure and naming. For example I've got ecoreA, which represents my EMF Editor. EcoreB describes a part of EcoreA, but with difference in structure and naming.
So when a user wants now to import an instance of ecoreB, there must be something like a parser which translates the ecoreB instance so that it fit in for ecoreA.
So what would be the best way to realize this? Are there any tools which I could use?
At the moment, I've extended the context menu with an Import menu item, which opens a FileDialog by clicking. This should be the hooking point for importig the other ecore instance and parse it.
I'm a little bit afraid that it could be a little bit complicated to include it then into the main model. Maybe there are some examples already?
|Re: Parsing of ecore models [message #1090616 is a reply to message #1089258]
||Tue, 20 August 2013 08:04
| Daniel Strueber
Registered: March 2011
To my impression, writing a dedicated parser would be a rather low-level solution to your use case. Since EMF provides a parser for EcoreB models out of the box, you might as well use this parser and then use model transformation to convert your EcoreB model (parsed by EMF's default mechanism) into an EcoreA model.|
Such a model transformation would then involve two steps: You define some conversion rules and then you execute them on some input EcoreB model. If you employ a model transformation engine that comes along with an API, such as EMF Henshin, the second step can be executed from your context menu just as you described.
You might check out the Ecore-to-RDB example for a model-to-model-transformation in Henshin. Note that at this moment we're still resolving some compatibility issues with Eclipse Kepler. To give Henshin a try, you should thus use Eclipse Juno.
[Updated on: Tue, 20 August 2013 10:10]
Report message to a moderator
|Re: Parsing of ecore models [message #1105270 is a reply to message #1105252]
||Mon, 09 September 2013 11:55
| Ed Merks
Registered: July 2009
On 09/09/2013 5:34 PM, Phil H wrote:
> Hi Ed,
> as you told me, I used my genmodel to generate test code, but this
> doesn't work..
What specifically doesn't work?
> What I have now is a project containing the ecore, genmodel and the
> generated test code..
Better to generate it to a different project. So it sounds like it did
work and you've just not found the XyzExample.java?
> What I still haven't understand yet if it's enough to have just the
> ecore model, or need I also the gen model and generate all the code?
> I expected that the ecore model would be sufficient..
For many models it's possible just to use dynamic Ecore. E.g., if you
right click on an EClass in the model, you can invoke Create Dynamic
Instance. But if you're going to write a model to model
transformation, you probably want to do that with the generated API for
the two models.
Powered by FUDForum
. Page generated in 0.02321 seconds