Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Creating context-free queries
Creating context-free queries [message #52029] Mon, 03 March 2008 19:53 Go to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi...

I'm trying to create a simple context-free query
("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
always get an Exception because I never set the context-classifier with
Environment#setSelfVariable(Variable).
If I set the self-variable to any valid classifier, everything works fine.
If I set it to an empty variable (no setType(EClassifier)), I run into a
StackOverflow.

So what is the right way to create a context-free query?

Stefan
Re: Creating context-free queries [message #52055 is a reply to message #52029] Mon, 03 March 2008 23:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Stefan,

OCL doesn't have a concept of context-free queries. All OCL expressions
have a context classifier.

The stack-overflow on an untyped variable looks like a bug.

HTH,

Christian


Stefan Schulze wrote:

> Hi...
>
> I'm trying to create a simple context-free query
> ("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
> always get an Exception because I never set the context-classifier with
> Environment#setSelfVariable(Variable).
> If I set the self-variable to any valid classifier, everything works fine.
> If I set it to an empty variable (no setType(EClassifier)), I run into a
> StackOverflow.
>
> So what is the right way to create a context-free query?
>
> Stefan
Re: Creating context-free queries [message #52081 is a reply to message #52055] Tue, 04 March 2008 00:29 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi Christian,

the method Query#evaluate() seems to be designed for context-free usage. If
I want to use that method, what should I set as self-variable? Is it correct
to set it to a random EClass from my metamodel?

Stefan

"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:fqi1a4$6du$1@build.eclipse.org...
> Hi, Stefan,
>
> OCL doesn't have a concept of context-free queries. All OCL expressions
> have a context classifier.
>
> The stack-overflow on an untyped variable looks like a bug.
>
> HTH,
>
> Christian
>
>
> Stefan Schulze wrote:
>
>> Hi...
>>
>> I'm trying to create a simple context-free query
>> ("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
>> always get an Exception because I never set the context-classifier with
>> Environment#setSelfVariable(Variable).
>> If I set the self-variable to any valid classifier, everything works
>> fine.
>> If I set it to an empty variable (no setType(EClassifier)), I run into a
>> StackOverflow.
>>
>> So what is the right way to create a context-free query?
>>
>> Stefan
>
Re: Creating context-free queries [message #52132 is a reply to message #52081] Tue, 04 March 2008 13:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Stefan,

I see, now. That API is a bit of an anachronism. I suppose that any
EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.

I suppose it depends on what your application is doing, but often it isn't
practical for an application to know a priori whether an expression will
reference 'self.' Hence, my previous reply was more OCL-oriented than
API-oriented.

Cheers,

Christian


Stefan Schulze wrote:

> Hi Christian,
>
> the method Query#evaluate() seems to be designed for context-free usage.
> If I want to use that method, what should I set as self-variable? Is it
> correct to set it to a random EClass from my metamodel?
>
> Stefan
>
> "Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
> news:fqi1a4$6du$1@build.eclipse.org...
>> Hi, Stefan,
>>
>> OCL doesn't have a concept of context-free queries. All OCL expressions
>> have a context classifier.
>>
>> The stack-overflow on an untyped variable looks like a bug.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Stefan Schulze wrote:
>>
>>> Hi...
>>>
>>> I'm trying to create a simple context-free query
>>> ("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
>>> always get an Exception because I never set the context-classifier with
>>> Environment#setSelfVariable(Variable).
>>> If I set the self-variable to any valid classifier, everything works
>>> fine.
>>> If I set it to an empty variable (no setType(EClassifier)), I run into a
>>> StackOverflow.
>>>
>>> So what is the right way to create a context-free query?
>>>
>>> Stefan
>>
Re: Creating context-free queries [message #52491 is a reply to message #52132] Sun, 09 March 2008 02:14 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan SchulzeFriend
Messages: 70
Registered: July 2009
Member
Hi Christian,

using EcorePackage.Literals.ESTRING works fine on one condition. If the
first self-variable I set to an Environment is an
EcorePackage.Literals.EString, the contextPackage of this Environment is set
to EcorePackage.eINSTANCE.
Because the contextPackage will never be updated, all subsequent evaluations
are failing.

It's not hard to work around this problem, but I thought it'd be good to
know for other people with the same problems. ;)

Bye,
Stefan

"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:fqjki2$nqc$1@build.eclipse.org...
> Hi, Stefan,
>
> I see, now. That API is a bit of an anachronism. I suppose that any
> EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.
>
> I suppose it depends on what your application is doing, but often it isn't
> practical for an application to know a priori whether an expression will
> reference 'self.' Hence, my previous reply was more OCL-oriented than
> API-oriented.
Re: Creating context-free queries [message #52545 is a reply to message #52491] Mon, 10 March 2008 13:32 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, stefan,

Right, that's a good point that I neglected to mention. The context
classifier also determines what is the default package for resolution of
unqualified classifier names.

You should be able to use the fully-qualified name to reference any type in
any package (so long as its name is unique, of course).

This sounds like a good FAQ item for the Wiki ...

Cheers,

Christian


Stefan Schulze wrote:

> Hi Christian,
>
> using EcorePackage.Literals.ESTRING works fine on one condition. If the
> first self-variable I set to an Environment is an
> EcorePackage.Literals.EString, the contextPackage of this Environment is
> set to EcorePackage.eINSTANCE.
> Because the contextPackage will never be updated, all subsequent
> evaluations are failing.
>
> It's not hard to work around this problem, but I thought it'd be good to
> know for other people with the same problems. ;)
>
> Bye,
> Stefan
>
> "Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
> news:fqjki2$nqc$1@build.eclipse.org...
>> Hi, Stefan,
>>
>> I see, now. That API is a bit of an anachronism. I suppose that any
>> EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.
>>
>> I suppose it depends on what your application is doing, but often it
>> isn't practical for an application to know a priori whether an expression
>> will
>> reference 'self.' Hence, my previous reply was more OCL-oriented than
>> API-oriented.
Previous Topic:Support for UML 2 collaborations
Next Topic:CollectionItem -> item direct edition
Goto Forum:
  


Current Time: Fri Mar 29 01:09:57 GMT 2024

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

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

Back to the top