Skip to main content



      Home
Home » Modeling » EMF » Ecore/Genmodel override "Root Extends Interface"(Do not use the default interface which is specified in the genmodel)
Ecore/Genmodel override "Root Extends Interface" [message #1827668] Wed, 20 May 2020 06:23 Go to next message
Eclipse UserFriend
With the property "Roots Extends Interface" in the genmodel, we can set the default interface for our generated classes.

The EMF book states, that this property is only used for classes without any super type.
In my case though, also the classes with a super type will use this interface in the generated code.
What could I be doing wrong? How can I prevent the usage of the default interface for a single class in my ecore?
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827674 is a reply to message #1827668] Wed, 20 May 2020 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Using Root Extends Interface is intended to be pervasive. If you selectively want some things to extend some interface and others not, then model that interface as an EClass. If you don't want that thing (EClass) itself to generate any actual new interface, set the Instance Type Name to some existing (hand written) interface and set Interface to true and Abstract to true. Unfortunately I really don't understand your goal without an example...
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827683 is a reply to message #1827674] Wed, 20 May 2020 11:50 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the clarification so far.

So my use-case is the following:
* Convert XSD => Ecore
* Migrate the ecore to CDO (which sets the "Root Extend Interface" property to CDOObject)
* Generate the code

The problem now is, that the generated ecore will always have an element "DocumentRoot" which contains a featuremap.
Since the newest CDO build, it will not be possible to use featuremaps anymore at all. Before, you were fine if you did not commit them to the archive.

So my thought was to let the DocumentRoot class explicitly inherit from EObject. But that only affects the base class und does not change the interface.
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827685 is a reply to message #1827683] Wed, 20 May 2020 11:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi

A badly designed irregular root for your model can easily turn in to a major PITA. I suggest you revisit before it becomes one.

You first need to distinguish what is part of the model, i.e. visible to someone who browses UML/Ecore class diagrams or uses OCL expressions from what is ONLY visible to Java programmers. Once you have identified what is in the model you can then design your root 'Element' class from which all other classes transitively derive; it can be very inconvenient not to have a common root class. Then you can probably use a standard Root Extends Interface else follow Ed Merks advice else use custom @extends annotations. But I strongly recommend making it regular and easy.

Regards

Ed Willink
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827686 is a reply to message #1827685] Wed, 20 May 2020 12:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed Willink,
I am not sure if you answered to my last post, because it was quite shortly before yours.
Anyway - a separation between the automatically created ecore from XSD (for serialization) and another internal ecore would be possible of course. But it would be a good chunk of work and also would require constant maintenance in the future if the XSD changes. I would really like to find a better solution to this.
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827687 is a reply to message #1827686] Wed, 20 May 2020 13:45 Go to previous messageGo to next message
Eclipse UserFriend
This is more a CDO question. Perhaps Eike will answer it...
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827689 is a reply to message #1827687] Wed, 20 May 2020 15:37 Go to previous messageGo to next message
Eclipse UserFriend
HI

Indeed messages passed. However my reaction to XSD is always - don't. Since you have successfully done the XSD to Ecore migration, I suggest that you now treat Ecore as the master and XSD as a derived output. You can then evolve the Ecore to be more sensible and CDO compliant.

Regards

Ed Willink
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827703 is a reply to message #1827683] Thu, 21 May 2020 02:17 Go to previous messageGo to next message
Eclipse UserFriend
Robert Schulk wrote on Wed, 20 May 2020 17:50
Since the newest CDO build, it will not be possible to use featuremaps anymore at all. Before, you were fine if you did not commit them to the archive.


Hi Robert, I've just provided a small fix on https://bugs.eclipse.org/bugs/show_bug.cgi?id=562011 . Happy Vatertag ;-)
Re: Ecore/Genmodel override "Root Extends Interface" [message #1827711 is a reply to message #1827703] Thu, 21 May 2020 10:14 Go to previous message
Eclipse UserFriend
Thanks Eike, the fix works for me!

Also: no fiddling with class inheritance would have been necessary. Simply setting the contents of the featuremap to transient would have also done the trick (for us, because only loading the xml needs to be done. Saving it would not work of course).
But having an out-of-the-box solution is definitely good for anyone who would encounter the same problem.

Happy Vartertag as well :D.

[Updated on: Fri, 22 May 2020 02:26] by Moderator

Previous Topic:How should a derived property fail?
Next Topic:Error log interpretation
Goto Forum:
  


Current Time: Fri Nov 07 23:29:41 EST 2025

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

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

Back to the top