Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Mapping from DSL specific ecore to a model ecore
Mapping from DSL specific ecore to a model ecore [message #1228873] Wed, 08 January 2014 08:49 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hello,

Happy new year to all!!

I have an existing model ecore and want to create a DSL for it. But the structure of that model doesn't fit to the DSL I like to create. So my intention is to create a DSL and than map/create the data model instance from the DSL's model instance.

Can you point me to the direction where I can do this mapping?
The Generator seems a place, but I would prefer to get the resource of my mapped data model as parameter in the 'doGenerate' method. So another location seems t obe better.

Thank you,
Mark
Re: Mapping from DSL specific ecore to a model ecore [message #1228922 is a reply to message #1228873] Wed, 08 January 2014 10:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i am not quite sure what you are doing.
there is no default hook for m2m and then generating
so far.



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Mapping from DSL specific ecore to a model ecore [message #1228928 is a reply to message #1228922] Wed, 08 January 2014 11:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s. maybe the org.eclipse.xtext.resource.IDerivedStateComputer is a hook that does what you want,
but thus highly depends on your usecase


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Mapping from DSL specific ecore to a model ecore [message #1228967 is a reply to message #1228928] Wed, 08 January 2014 12:49 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi,

I don't wanna do the transformation when executing MWE to generate the stuff!
The transformation should be done, when I use the generated editor typing code in my DSL and save the file.

So the ordinary use case is:
- create a DSL and generate the editor from it
- launch the generated bundles
- use the editor to write code in my DSL's grammar.
- save the file and you get the DSL's EMF Resource with the model in it
- generate any code using the generated xtend generator class

What I want is:
- create a DSL and generate the editor from it
- launch the generated bundles
- use the editor to write code in my DSL's grammar.
- save the file and you get the DSL's EMF Resource with the model in it
- transform this data model into a model instance of the customers ecore
- generate any code using the generated xtend generator class from the model of the customers ecore

I already tried to import the big ecore and created a DSL from it, but the result was not very good. Even if I deleted unnecessary stuff and changed the grammar I didn't achieved a good result.

But I can create an instance of the complex model from the DSL's model which was created from scratch. For this I have to create corresponding objects in the big model, set a lot of default values, non containing cross references and so on. It doesn't matter for me, if I do this in code or using m2m.

I just wanted to know, if there is a good place to start this transformation, when saving the code in my DSL editor. Thats why I came to the idea, do this in the xtend generator class. But my feeling says this is not a good place to do such a transformation.

I cannot change the big model, because its the one from the customer.

Regards,
Mark

[Updated on: Wed, 08 January 2014 13:13]

Report message to a moderator

Re: Mapping from DSL specific ecore to a model ecore [message #1228969 is a reply to message #1228967] Wed, 08 January 2014 12:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

are you sure it is impossible to create a grammar for the big model manually?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Mapping from DSL specific ecore to a model ecore [message #1228982 is a reply to message #1228969] Wed, 08 January 2014 13:32 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi,

no, I am not sure if it is impossible, but creating the DSL from srcatch was not as expensive as modifying the imported one, that resulted in language that I and the customer dont really wanted.

In any case I would need a hook, where I can set non containing references, default values and so on after the syntax is valid. Something like postProcess or preCodeGenerate ...

Mark

[Updated on: Wed, 08 January 2014 13:33]

Report message to a moderator

Re: Mapping from DSL specific ecore to a model ecore [message #1228986 is a reply to message #1228982] Wed, 08 January 2014 13:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

why no simply on generate?

if not give IDerivedStateComputer a try,
afaik it is called during multiple phases so maybe even the cross ref thing will work fine.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Mapping from DSL specific ecore to a model ecore [message #1229009 is a reply to message #1228986] Wed, 08 January 2014 14:40 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Christian,

thank you I will use doGenerate and found this as a good starting point:
http://xtextcasts.org/episodes/18-model-optimization

Thank you

Mark
Previous Topic:Adding a library to runtime project
Next Topic:Maven build using Nexus with P2 repositories
Goto Forum:
  


Current Time: Fri Apr 19 20:26:42 GMT 2024

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

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

Back to the top