Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » ocl newbie question
ocl newbie question [message #26912] Thu, 02 March 2006 15:29 Go to next message
Eclipse UserFriend
Originally posted by: saya.txesystems.com

Hi,
I have been experimenting with emf's ocl and I have a related question.

I form the following expression:

exp = QueryFactory.eINSTANCE.createQuery(
"self.declaredFacets->asSet()->union(self.superTypes.declaredFacets)- >asSet())",
CorePackage.eINSTANCE.getPartyType());

PartyType is an EObject.It has supertypes of EObjects. It has an
eStructuralFeature declaredFacets. When I evaluate this expression on a
PartyType object which has two declared facets but no superType, I get an
"IllegalArgumentException: Illegal operation(null.union(null)".

When I change the expression to:
exp = QueryFactory.eINSTANCE.createQuery(
"self.declaredFacets->asSet()->union(self.superTypes->asSet()- >collect(p :
PartyType|p.declaredFacets)->asSet())",
CorePackage.eINSTANCE.getPartyType());

everything works fine. Do I have to use collect whenever an eStructural
feature (in this case superTypes) might return null, is this a bug or am I
doing something wrong?

I would appreciate any comments,
thanks,
Selcuk
Re: ocl newbie question [message #26993 is a reply to message #26912] Thu, 02 March 2006 17:53 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Selcuk,

You should never need to use an explicit collect iterator in place of the
dot notation when the collect would simply navigate another reference; the
notations are equivalent.

There definitely is a bug, here. I can parse the following expression:

IOCLHelper helper = HelperUtil.createOclHelper();
helper.setContext(ExpressionsPackage.eINSTANCE);

OCLExpression expr = helper.createQuery(
"self.eClassifiers->asSet()->union(" +
"self.eSubpackages->collect(eClassifiers)->asSet())");

but not this:

self.eClassifiers->asSet()->union(
self.eSubpackages.eClassifiers->asSet())

which should work equally well. Instead, I get a "No common supertype:
(EClassifier), (null)". It seems that in my case and yours, the parser
cannot determine the type of a dot navigation expression through two
collections.

I have raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=130239 to
address this problem.

Thanks,

Christian


Selcuk Aya wrote:

> Hi,
> I have been experimenting with emf's ocl and I have a related question.
>
> I form the following expression:
>
> exp = QueryFactory.eINSTANCE.createQuery(
>
"self.declaredFacets->asSet()->union(self.superTypes.declaredFacets)- >asSet())",
> CorePackage.eINSTANCE.getPartyType());
>
> PartyType is an EObject.It has supertypes of EObjects. It has an
> eStructuralFeature declaredFacets. When I evaluate this expression on a
> PartyType object which has two declared facets but no superType, I get an
> "IllegalArgumentException: Illegal operation(null.union(null)".
>
> When I change the expression to:
> exp = QueryFactory.eINSTANCE.createQuery(
> "self.declaredFacets->asSet()->union(self.superTypes->asSet()- >collect(p :
> PartyType|p.declaredFacets)->asSet())",
> CorePackage.eINSTANCE.getPartyType());
>
> everything works fine. Do I have to use collect whenever an eStructural
> feature (in this case superTypes) might return null, is this a bug or am I
> doing something wrong?
>
> I would appreciate any comments,
> thanks,
> Selcuk
Re: ocl newbie question [message #571230 is a reply to message #26912] Thu, 02 March 2006 17:53 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Selcuk,

You should never need to use an explicit collect iterator in place of the
dot notation when the collect would simply navigate another reference; the
notations are equivalent.

There definitely is a bug, here. I can parse the following expression:

IOCLHelper helper = HelperUtil.createOclHelper();
helper.setContext(ExpressionsPackage.eINSTANCE);

OCLExpression expr = helper.createQuery(
"self.eClassifiers->asSet()->union(" +
"self.eSubpackages->collect(eClassifiers)->asSet())");

but not this:

self.eClassifiers->asSet()->union(
self.eSubpackages.eClassifiers->asSet())

which should work equally well. Instead, I get a "No common supertype:
(EClassifier), (null)". It seems that in my case and yours, the parser
cannot determine the type of a dot navigation expression through two
collections.

I have raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=130239 to
address this problem.

Thanks,

Christian


Selcuk Aya wrote:

> Hi,
> I have been experimenting with emf's ocl and I have a related question.
>
> I form the following expression:
>
> exp = QueryFactory.eINSTANCE.createQuery(
>
"self.declaredFacets->asSet()->union(self.superTypes.declaredFacets)- >asSet())",
> CorePackage.eINSTANCE.getPartyType());
>
> PartyType is an EObject.It has supertypes of EObjects. It has an
> eStructuralFeature declaredFacets. When I evaluate this expression on a
> PartyType object which has two declared facets but no superType, I get an
> "IllegalArgumentException: Illegal operation(null.union(null)".
>
> When I change the expression to:
> exp = QueryFactory.eINSTANCE.createQuery(
> "self.declaredFacets->asSet()->union(self.superTypes->asSet()- >collect(p :
> PartyType|p.declaredFacets)->asSet())",
> CorePackage.eINSTANCE.getPartyType());
>
> everything works fine. Do I have to use collect whenever an eStructural
> feature (in this case superTypes) might return null, is this a bug or am I
> doing something wrong?
>
> I would appreciate any comments,
> thanks,
> Selcuk
Previous Topic:ocl newbie question
Next Topic:Discovering transaction insertion point
Goto Forum:
  


Current Time: Sun May 25 00:49:07 EDT 2025

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

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

Back to the top