Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Multiple metamodels not supported?
Multiple metamodels not supported? [message #140434] Thu, 28 June 2007 17:28 Go to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Hi,

I have the metamodel inheritance A.ecore -> B.ecore -> C.ecore


I created an GMF editor for Metamodel A.ecore. Everythink is fine except
when I use OCL constraints like "self.oclIsKindOf(TypeFromA)" where
TypeFromA is defined in A.ecore. If I use "self.oclIsKindOf(TypeFromB)"
where TypeFromB is defined in B.ecore, this works! and
"self.oclIsKindOf(TypeFromC)" not works again. So the middle metamodel
works! So this seems randomly what metamodel works for OCL constraints.
Its remarkable thats the middle metamodel (middle in inheritance
hierarchy), since A.ecore is the "root" metamodel when I generated the
GMF xml files.

However in the generated GMF editor itself I can create model elements
of classes in all three metamodels without problem. Only when
referencing to metamodel classes of A.ecore or C.ecore, it not works.
Can anybody tell where the metamodels are registered to the OCL engine?
And, second, can anyone tell why full qualified names for the metamodels
not work, but only names without the top level package name of the
metamodel (this may be related to the problem)?

Thanks!
Re: Multiple metamodels not supported? [message #140448 is a reply to message #140434] Thu, 28 June 2007 17:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

John,

Probably asking on the OCL newsgroup, which I've added to the "to" list
of the reply, is likely more appropriate. Christian is likely to see
your question more quickly there.


John Smith wrote:
> Hi,
>
> I have the metamodel inheritance A.ecore -> B.ecore -> C.ecore
>
>
> I created an GMF editor for Metamodel A.ecore. Everythink is fine
> except when I use OCL constraints like "self.oclIsKindOf(TypeFromA)"
> where TypeFromA is defined in A.ecore. If I use
> "self.oclIsKindOf(TypeFromB)" where TypeFromB is defined in B.ecore,
> this works! and "self.oclIsKindOf(TypeFromC)" not works again. So the
> middle metamodel works! So this seems randomly what metamodel works
> for OCL constraints. Its remarkable thats the middle metamodel (middle
> in inheritance hierarchy), since A.ecore is the "root" metamodel when
> I generated the GMF xml files.
>
> However in the generated GMF editor itself I can create model elements
> of classes in all three metamodels without problem. Only when
> referencing to metamodel classes of A.ecore or C.ecore, it not works.
> Can anybody tell where the metamodels are registered to the OCL
> engine? And, second, can anyone tell why full qualified names for the
> metamodels not work, but only names without the top level package name
> of the metamodel (this may be related to the problem)?
>
> Thanks!
Re: Multiple metamodels not supported? [message #140459 is a reply to message #140434] Thu, 28 June 2007 17:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, John,

if "self.oclIsKindOf(TypeFromB)" works without qualifying the TypeFromB with
its package name, then you are defining this constraint in the context of
some type in your B package. References to types in other packages must be
qualified by the package names. Soo, assuming that the EPackage in A.ecore
is named "a" (the convention seems to be to use lower case as in Java),
then you could do:

self.oclIsKindOf(a::TypeFromA)

The OCL parser knows about all of the EPackages that are registered on EMF's
generated_package extension point. It just can't guess what package a type
might be in if the name is unqualified and does not match a type in the
same package as the context type.

HTH,

Christian


John Smith wrote:

> Hi,
>
> I have the metamodel inheritance A.ecore -> B.ecore -> C.ecore
>
>
> I created an GMF editor for Metamodel A.ecore. Everythink is fine except
> when I use OCL constraints like "self.oclIsKindOf(TypeFromA)" where
> TypeFromA is defined in A.ecore. If I use "self.oclIsKindOf(TypeFromB)"
> where TypeFromB is defined in B.ecore, this works! and
> "self.oclIsKindOf(TypeFromC)" not works again. So the middle metamodel
> works! So this seems randomly what metamodel works for OCL constraints.
> Its remarkable thats the middle metamodel (middle in inheritance
> hierarchy), since A.ecore is the "root" metamodel when I generated the
> GMF xml files.
>
> However in the generated GMF editor itself I can create model elements
> of classes in all three metamodels without problem. Only when
> referencing to metamodel classes of A.ecore or C.ecore, it not works.
> Can anybody tell where the metamodels are registered to the OCL engine?
> And, second, can anyone tell why full qualified names for the metamodels
> not work, but only names without the top level package name of the
> metamodel (this may be related to the problem)?
>
> Thanks!
Re: Multiple metamodels not supported? [message #140490 is a reply to message #140459] Thu, 28 June 2007 19:30 Go to previous messageGo to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
> Hi, John,
>
> if "self.oclIsKindOf(TypeFromB)" works without qualifying the TypeFromB with
> its package name, then you are defining this constraint in the context of
> some type in your B package. References to types in other packages must be
> qualified by the package names. Soo, assuming that the EPackage in A.ecore
> is named "a" (the convention seems to be to use lower case as in Java),
> then you could do:

The error appears in the problems view when transforming from gmfmap to
gmfgen. Is it relevant?
Re: Multiple metamodels not supported? [message #140501 is a reply to message #140490] Thu, 28 June 2007 19:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

I don't know about transforming gmfmaps to gmfgens, but I don't imagine that
this would be relevant to the problem.

I need more information to guess at what the problem might be. At a
minimum:

- what are the names of the EPackage elements in the A.ecore, B.ecore
and C.ecore models?
- what is the context classifier of the OCL constraint? i.e., which
model EClassifier does it constrain? In which package is it?
- what is the error message reported by the OCL parser?

Cheers,

Christian

exquisitus wrote:

>> Hi, John,
>>
>> if "self.oclIsKindOf(TypeFromB)" works without qualifying the TypeFromB
>> with its package name, then you are defining this constraint in the
>> context of
>> some type in your B package. References to types in other packages must
>> be
>> qualified by the package names. Soo, assuming that the EPackage in
>> A.ecore is named "a" (the convention seems to be to use lower case as in
>> Java), then you could do:
>
> The error appears in the problems view when transforming from gmfmap to
> gmfgen. Is it relevant?
Re: Multiple metamodels not supported? [message #140523 is a reply to message #140501] Thu, 28 June 2007 21:37 Go to previous messageGo to next message
John Smith is currently offline John SmithFriend
Messages: 137
Registered: July 2009
Senior Member
Christian W. Damus wrote:
> I don't know about transforming gmfmaps to gmfgens, but I don't imagine that
> this would be relevant to the problem.
>
> I need more information to guess at what the problem might be. At a
> minimum:
>
> - what are the names of the EPackage elements in the A.ecore, B.ecore
> and C.ecore models?
> - what is the context classifier of the OCL constraint? i.e., which
> model EClassifier does it constrain? In which package is it?

The OCL expression is

self.oclIsKindOf(SubPackageOfMetamodelB::MetamodelClassOfB)

or

self.oclIsKindOf(MetamodelClassOfB)

which works but

self.oclIsKindOf(TopLebelPackageOfMetamodelB::SubPackageOfMe tamodelB::MetamodelClassOfB)

works not and for A or C works nothing.

I have not the concrete error message because I am not at home but its
from the sense that the qualified name cannot be resolved.

Greetings
Re: Multiple metamodels not supported? [message #140643 is a reply to message #140523] Fri, 29 June 2007 14:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi,

Do your top-level packages have any EClassifiers in them, or are they only
namespaces for nested packages? This is an important point, because EMF
will not generate an EPackage implementation for such packages, nor will it
register them in the package registry on the generated_package extension
point.

The OCL metamodel has this problem. It is structured thus:

package ocl
package types
... numerous EClassifiers ...
package expressions
... numerous EClassifiers ...
package utilities
... numerous EClassifiers ...

The "ocl" package is empty as far as EMF is concerned, so it is not
generated. The OCL implementation works around this by adding it to the
package registry in the initialization of the other packages.

If the package isn't in the package registry, then the OCL parser will not
find it. Conversely, if it is, then the parser should find it.

HTH,

Christian


exquisitus wrote:

> Christian W. Damus wrote:
>> I don't know about transforming gmfmaps to gmfgens, but I don't imagine
>> that this would be relevant to the problem.
>>
>> I need more information to guess at what the problem might be. At a
>> minimum:
>>
>> - what are the names of the EPackage elements in the A.ecore, B.ecore
>> and C.ecore models?
>> - what is the context classifier of the OCL constraint? i.e., which
>> model EClassifier does it constrain? In which package is it?
>
> The OCL expression is
>
> self.oclIsKindOf(SubPackageOfMetamodelB::MetamodelClassOfB)
>
> or
>
> self.oclIsKindOf(MetamodelClassOfB)
>
> which works but
>
>
self.oclIsKindOf(TopLebelPackageOfMetamodelB::SubPackageOfMe tamodelB::MetamodelClassOfB)
>
> works not and for A or C works nothing.
>
> I have not the concrete error message because I am not at home but its
> from the sense that the qualified name cannot be resolved.
>
> Greetings
Re: Multiple metamodels not supported? [message #162232 is a reply to message #140459] Fri, 23 November 2007 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stefan.bley.dd.gmx.de

Hi Christian,

I've ran into the same problem.
I was following your suggestion to put the namespace in front, i.e.
a::TypeFromA, so the gmfmap validation passes but when I want to create
gmfgen it complains:
"Invalid expression body 'self.oclIsKindOf(a::TypeFromA)'. Cause: ERROR in
(enumerationOrClassLiteralExpCS): (Unkown type ([a, TypeFromA]))"

You said that package 'a' must be registered on generated_package extension
point. Maybe there lies the problem. It is registered, but within a
different plugin, let's say a plugin named 'com.example.a' whereas the
gmfmap, gmfgen etc are in plugin 'com.example.a.gmf'.
Do you think this could be the reason?

Cheers, Stevy

"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:f60ssp$8rf$1@build.eclipse.org...
> Hi, John,
>
> ... assuming that the EPackage in A.ecore
> is named "a" (the convention seems to be to use lower case as in Java),
> then you could do:
>
> self.oclIsKindOf(a::TypeFromA)
>
> The OCL parser knows about all of the EPackages that are registered on
> EMF's
> generated_package extension point. It just can't guess what package a
> type
> might be in if the name is unqualified and does not match a type in the
> same package as the context type.
>
> HTH,
> Christian
Re: Multiple metamodels not supported? [message #162314 is a reply to message #162232] Fri, 23 November 2007 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Stevy,

The likeliest reason why the parser doesn't find the "a::TypeFromA" class is
that it couldn't find the "a" package. The likeliest reason for that is
that the "a" package hasn't yet been initialized (e.g., because no instance
of it has been deserialized or otherwise constructed by the application) so
it is still just a descriptor in the package registry.

The problem for OCL is that it can't access packages that haven't yet been
resolved in the registry, because the descriptor has no information about
the name, and OCL doesn't want to just load all descriptors (and their
corresponding OSGi bundles) until it finds the right one.

If you can make sure that your OCL initializes the "a" package by, e.g.,

APackage.eINSTANCE.getName();

before parsing any OCLs, then you should be OK.

HTH,

Christian

Stefan Bley wrote:

> Hi Christian,
>
> I've ran into the same problem.
> I was following your suggestion to put the namespace in front, i.e.
> a::TypeFromA, so the gmfmap validation passes but when I want to create
> gmfgen it complains:
> "Invalid expression body 'self.oclIsKindOf(a::TypeFromA)'. Cause: ERROR in
> (enumerationOrClassLiteralExpCS): (Unkown type ([a, TypeFromA]))"
>
> You said that package 'a' must be registered on generated_package
> extension point. Maybe there lies the problem. It is registered, but
> within a different plugin, let's say a plugin named 'com.example.a'
> whereas the gmfmap, gmfgen etc are in plugin 'com.example.a.gmf'.
> Do you think this could be the reason?
>
> Cheers, Stevy
>
> "Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
> news:f60ssp$8rf$1@build.eclipse.org...
>> Hi, John,
>>
>> ... assuming that the EPackage in A.ecore
>> is named "a" (the convention seems to be to use lower case as in Java),
>> then you could do:
>>
>> self.oclIsKindOf(a::TypeFromA)
>>
>> The OCL parser knows about all of the EPackages that are registered on
>> EMF's
>> generated_package extension point. It just can't guess what package a
>> type
>> might be in if the name is unqualified and does not match a type in the
>> same package as the context type.
>>
>> HTH,
>> Christian
Re: Multiple metamodels not supported? [message #162361 is a reply to message #162314] Fri, 23 November 2007 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stefan.bley.dd.gmx.de

Hi Christian,

unfortunately I don't know when/where OCL starts parsing. I have got these
OCL link constraints that cause my gmfmap and gmfgen to be marked with red
crosses. But: The generation works fine (when "ignore validation errors" is
checked) and the link constraints are included in the generated editor, no
problem.
It is just the gmfmap/gmfgen validators that do not find package 'a'. So
where am I supposed to put your code snippet? Can I initialize the package
elsewise, e.g. through 'Load Resource...'?

Thanks, Stevy

"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:fi6j4g$qi$1@build.eclipse.org...
> Hi, Stevy,
>
> The likeliest reason why the parser doesn't find the "a::TypeFromA" class
> is
> that it couldn't find the "a" package. The likeliest reason for that is
> that the "a" package hasn't yet been initialized (e.g., because no
> instance
> of it has been deserialized or otherwise constructed by the application)
> so
> it is still just a descriptor in the package registry.
>
> The problem for OCL is that it can't access packages that haven't yet been
> resolved in the registry, because the descriptor has no information about
> the name, and OCL doesn't want to just load all descriptors (and their
> corresponding OSGi bundles) until it finds the right one.
>
> If you can make sure that your OCL initializes the "a" package by, e.g.,
>
> APackage.eINSTANCE.getName();
>
> before parsing any OCLs, then you should be OK.
Re: Multiple metamodels not supported? [message #162377 is a reply to message #162361] Fri, 23 November 2007 15:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Stevy,

Ah, so it's in the GMF model editors that you're getting problems? Not in
running the generated diagram editor?

In that case, simply opening an instance of the "a" package in its
corresponding editor should do the trick (i.e., open a *.a file). This
will cause the package to be resolved in your development workbench's
package registry.

This is all assuming, of course, that I guessed right in the first place.
:-)

cW

Stefan Bley wrote:

> Hi Christian,
>
> unfortunately I don't know when/where OCL starts parsing. I have got these
> OCL link constraints that cause my gmfmap and gmfgen to be marked with red
> crosses. But: The generation works fine (when "ignore validation errors"
> is checked) and the link constraints are included in the generated editor,
> no problem.
> It is just the gmfmap/gmfgen validators that do not find package 'a'. So
> where am I supposed to put your code snippet? Can I initialize the package
> elsewise, e.g. through 'Load Resource...'?
>
> Thanks, Stevy

-----8<-----
Re: Multiple metamodels not supported? [message #162951 is a reply to message #162377] Wed, 28 November 2007 08:22 Go to previous message
Eclipse UserFriend
Originally posted by: stefan.bley.dd.gmx.de

Hi Christian,

> Ah, so it's in the GMF model editors that you're getting problems? Not in
> running the generated diagram editor?

That's right.

> In that case, simply opening an instance of the "a" package in its
> corresponding editor should do the trick (i.e., open a *.a file). This
> will cause the package to be resolved in your development workbench's
> package registry.

How can I open an *.a file with its generated emf tree editor, if this
editor itself is being developed in this workbench and thus is not installed
as plugin? Or have I misunderstood sth.?
Note that actually all three, the 'a' package and its emf editor and the gmf
editor are being developed in the same workspace.

~Stevy
Previous Topic:Connecting two nodes makes them disappear
Next Topic:Who is responsible?
Goto Forum:
  


Current Time: Fri Mar 29 08:25:52 GMT 2024

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

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

Back to the top