Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Behaviour of EObject.eContainer() dyn. ecore != gen. model
Behaviour of EObject.eContainer() dyn. ecore != gen. model [message #425189] Tue, 18 November 2008 20:47 Go to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: July 2009
Junior Member
Hello,

say you have this model:

pkgRoot
|-- pkgChild1
|-- stuff...
|-- pkgChild2
|-- stuff...
|-- pkgChild3
|-- pkgChild31
|-- clClass311

once a model instance is loaded from a serialized representation and used
either with dynamic ecore or with the generated java classes, I observed a
different behaviour of EObject.eContainer().

Dynamic ecore works as expected, no problem.

The generated java classes not. clClass311_instance.eContainer() returns
pkgChild31_instance, but pkgChild31_instance.eContainer() returns null and
not pkgChild3_instance as exptected...

Having a look at the generated java classes, one can see that pkgChild3
has no package factory nor metadata. This seems to be so because the
package contains no classes, only a subpackage, namely pkgChild31. So the
whole package hierarchy is not well initialized (init() method not called
since not present).

Did I misunderstood something concening EMF generation? or it is generally
a bad idea to have a package hierarchy depth of more than 1 level?

Thanks
Marc
Re: Behaviour of EObject.eContainer() dyn. ecore != gen. model [message #425190 is a reply to message #425189] Tue, 18 November 2008 21:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Marc,

Your situation is an instance of this:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=142856

The EMF code generation does not generate the code (nor, in consequence,
the initialization) of EPackages that do not contain any classifiers.
Not even if they have sub-packages that do contain classifiers.

And, yes, I think I have seen it recommended in this newsgroup avoid
package nesting in Ecore. Think of it more like the flat namespaces of XSD.

Cheers,

Christian

Marc Schlienger wrote:
> Hello,
>
> say you have this model:
>
> pkgRoot
> |-- pkgChild1
> |-- stuff...
> |-- pkgChild2
> |-- stuff...
> |-- pkgChild3
> |-- pkgChild31
> |-- clClass311
>
> once a model instance is loaded from a serialized representation and
> used either with dynamic ecore or with the generated java classes, I
> observed a different behaviour of EObject.eContainer().
>
> Dynamic ecore works as expected, no problem.
>
> The generated java classes not. clClass311_instance.eContainer() returns
> pkgChild31_instance, but pkgChild31_instance.eContainer() returns null
> and not pkgChild3_instance as exptected...
>
> Having a look at the generated java classes, one can see that pkgChild3
> has no package factory nor metadata. This seems to be so because the
> package contains no classes, only a subpackage, namely pkgChild31. So
> the whole package hierarchy is not well initialized (init() method not
> called since not present).
>
> Did I misunderstood something concening EMF generation? or it is
> generally a bad idea to have a package hierarchy depth of more than 1
> level?
>
> Thanks
> Marc
>
Re: Behaviour of EObject.eContainer() dyn. ecore != gen. model [message #425191 is a reply to message #425189] Tue, 18 November 2008 21:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Marc,

Comments below.


Marc Schlienger wrote:
> Hello,
>
> say you have this model:
>
> pkgRoot
> |-- pkgChild1
> |-- stuff...
> |-- pkgChild2
> |-- stuff...
> |-- pkgChild3
> |-- pkgChild31
> |-- clClass311
>
> once a model instance is loaded from a serialized representation and
> used either with dynamic ecore or with the generated java classes, I
> observed a different behaviour of EObject.eContainer().
>
> Dynamic ecore works as expected, no problem.
>
> The generated java classes not. clClass311_instance.eContainer()
> returns pkgChild31_instance, but pkgChild31_instance.eContainer()
> returns null and not pkgChild3_instance as exptected...
Yes, it sounds like https://bugs.eclipse.org/bugs/show_bug.cgi?id=142856.
>
> Having a look at the generated java classes, one can see that
> pkgChild3 has no package factory nor metadata. This seems to be so
> because the package contains no classes, only a subpackage, namely
> pkgChild31. So the whole package hierarchy is not well initialized
> (init() method not called since not present).
>
> Did I misunderstood something concening EMF generation? or it is
> generally a bad idea to have a package hierarchy depth of more than 1
> level?
Right now it's a bad idea to expect there to be a generated EPackage for
it....
>
> Thanks
> Marc
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Re: Starting a CDO Server
Next Topic:org.eclipse.emf.ecore source not found in Eclipse Ganymede build
Goto Forum:
  


Current Time: Thu Apr 25 11:25:46 GMT 2024

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

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

Back to the top