Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: EMF Query and EvaluationEnvironment
Re: EMF Query and EvaluationEnvironment [message #418000] Tue, 01 April 2008 15:38 Go to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Xavier,

This is an EMF Query question, so I am including the EMF newsgroup in my
reply.

If you are not using "context-free" queries, then a subclass of
AbstractOCLCondition can obtain its Query object (from the OCL API) via the
protected getQuery() method. This Query provides access to the
EvaluationEnvironment, in which you can then bind the values of your
variables.

Note that this will have to be done on each individual condition object; the
statement has no knowledge of OCL dependencies.

The "context-free" queries add a wrinkle to the picture, because they
construct OCL Query objects on-the-fly for each metaclass in which context
they are applicable (i.e., can parse). For most purposes, you wouldn't
need these, anyway.

HTH,

Christian


Xavier Maysonnave wrote:

> Hi,
>
> I'm implementing ocl variables support in our query facilities.
>
> To start my implemenation I have followed this post :
>
> http://www.eclipsepowered.org/eclipse/forums/t103864.html
>
> Through EMF Validation I can successfully validate OCL statement with
> variable support. To execute my queries I use EMF Query. I can build
> EObjectCondition and feed the ocl environment of each condition with
> variables definition.
>
> However I cannot figure out how to feed variables value in the
> EvaluationEnvironment as I use STATEMENT with WHERE clause. WHERE is
> populated with EObjectCondition.
>
> Is there a way to access the OCL EvaluationEnvironment from a STATEMENT or
> there is another way to valuate ocl variables before executing any EMF
> Query STATEMENT ?
>
> Best Regards.
Re: EMF Query and EvaluationEnvironment [message #418002 is a reply to message #418000] Tue, 01 April 2008 15:57 Go to previous messageGo to next message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
Thanks for your quick reply.

I'm using the web interface so I cannot cross post message on both EMFT
and OCL newsgroup. sorry for that.

The hint is definitely helpful.

However about the context free. I'm not sure to understand what you mean
about 'wrinkle'. Does it mean that we can't assign variables in the same
way we do with contextual query ?

At the moment I build BooleanOCLCondition for contextual and non
contextual element (our user choose which query they want to use). I will
probably specialize BooleanOCLCondition to define and bind our defined
variables.

Thanks.
Re: EMF Query and EvaluationEnvironment [message #418008 is a reply to message #418002] Tue, 01 April 2008 18:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Xavier,

The wrinkle I was thinking of is simply that the "context-free" condition
lazily parses its OCL text against the metaclasses of elements as it
encounters them during the execution of the SELECT statement. Thus, there
is no single OCL Query object whose evaluation environment you must poke,
but many, and all created lazily. I don't think there is even a hook by
which a subclass can be notified that a query has been constructed, as an
opportunity to initialize it with variable bindings. Such a hook would, I
can see, be beneficial. Unfortunately, it would be new API in a class that
has subclasses, so it would be difficult to do at this stage, past API
Freeze for the 1.2 release.

Your BooleanOCLCondition subclass can work around this, however. The
AbstractOCLCondition, when used in "context-free" mode, implements
isSatisfied() to (among other things) set the oclQuery field to the Query
instance applicable to the current element. Thus, you could extend the
isSatisfied() method to check, first, whether the AbstractOCLCondition can
find an appropriate Query and, if so, look to see whether the appropriate
variables are present in its EvaluationEnvironment, lazily binding them as
necessary. Then, check the Query to see whether the condition holds.

HTH,

Christian


Xavier Maysonnave wrote:

> Thanks for your quick reply.
>
> I'm using the web interface so I cannot cross post message on both EMFT
> and OCL newsgroup. sorry for that.
>
> The hint is definitely helpful.
>
> However about the context free. I'm not sure to understand what you mean
> about 'wrinkle'. Does it mean that we can't assign variables in the same
> way we do with contextual query ?
>
> At the moment I build BooleanOCLCondition for contextual and non
> contextual element (our user choose which query they want to use). I will
> probably specialize BooleanOCLCondition to define and bind our defined
> variables.
>
> Thanks.
Re: EMF Query and EvaluationEnvironment [message #418015 is a reply to message #418008] Wed, 02 April 2008 10:07 Go to previous messageGo to next message
Xavier Maysonnave is currently offline Xavier MaysonnaveFriend
Messages: 30
Registered: July 2009
Member
Christian W. Damus wrote:

> Hi, Xavier,

> The wrinkle I was thinking of is simply that the "context-free" condition
> lazily parses its OCL text against the metaclasses of elements as it
> encounters them during the execution of the SELECT statement. Thus, there
> is no single OCL Query object whose evaluation environment you must poke,
> but many, and all created lazily. I don't think there is even a hook by
> which a subclass can be notified that a query has been constructed, as an
> opportunity to initialize it with variable bindings. Such a hook would, I
> can see, be beneficial. Unfortunately, it would be new API in a class that
> has subclasses, so it would be difficult to do at this stage, past API
> Freeze for the 1.2 release.

May I open a bugzilla for this possible enhancement ?

> Your BooleanOCLCondition subclass can work around this, however. The
> AbstractOCLCondition, when used in "context-free" mode, implements
> isSatisfied() to (among other things) set the oclQuery field to the Query
> instance applicable to the current element. Thus, you could extend the
> isSatisfied() method to check, first, whether the AbstractOCLCondition can
> find an appropriate Query and, if so, look to see whether the appropriate
> variables are present in its EvaluationEnvironment, lazily binding them as
> necessary. Then, check the Query to see whether the condition holds.

The AbstractEvaluationEnvironment doesn't expose a containsKey method,
however I can catch the exception in the add method to check whether or
not the variable value is already bound. I assume that the variable
definitions feed in ocl environment is propagated to the many query object
implied by a context free query (it means that I don't need to check the
ocl environment to see if a variable definition exists).

Best Regards.

Xavier

> HTH,

> Christian


> Xavier Maysonnave wrote:

>> Thanks for your quick reply.
>>
>> I'm using the web interface so I cannot cross post message on both EMFT
>> and OCL newsgroup. sorry for that.
>>
>> The hint is definitely helpful.
>>
>> However about the context free. I'm not sure to understand what you mean
>> about 'wrinkle'. Does it mean that we can't assign variables in the same
>> way we do with contextual query ?
>>
>> At the moment I build BooleanOCLCondition for contextual and non
>> contextual element (our user choose which query they want to use). I will
>> probably specialize BooleanOCLCondition to define and bind our defined
>> variables.
>>
>> Thanks.
Re: EMF Query and EvaluationEnvironment [message #418024 is a reply to message #418015] Wed, 02 April 2008 12:38 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Xavier,

You may always raise enhancement requests in Bugzilla. You can even attach
patches to those requests, too :-)

Deliberately causing exceptions isn't very pretty. The
EvaluationEnvironment does have a getValueOf(...) operation with which you
can test whether a non-null value is bound. If the value that you need to
bind to a variable happens to be null, then just check whether the value
isn't already null.

You should find that each OCL Query object creates its own evaluation
environment, so your variable bindings will not be shared by them.

Cheers,

Christian


Xavier Maysonnave wrote:

> Christian W. Damus wrote:
>
>> Hi, Xavier,
>
>> The wrinkle I was thinking of is simply that the "context-free" condition
>> lazily parses its OCL text against the metaclasses of elements as it
>> encounters them during the execution of the SELECT statement. Thus,
>> there is no single OCL Query object whose evaluation environment you must
>> poke,
>> but many, and all created lazily. I don't think there is even a hook by
>> which a subclass can be notified that a query has been constructed, as an
>> opportunity to initialize it with variable bindings. Such a hook would,
>> I
>> can see, be beneficial. Unfortunately, it would be new API in a class
>> that has subclasses, so it would be difficult to do at this stage, past
>> API Freeze for the 1.2 release.
>
> May I open a bugzilla for this possible enhancement ?
>
>> Your BooleanOCLCondition subclass can work around this, however. The
>> AbstractOCLCondition, when used in "context-free" mode, implements
>> isSatisfied() to (among other things) set the oclQuery field to the Query
>> instance applicable to the current element. Thus, you could extend the
>> isSatisfied() method to check, first, whether the AbstractOCLCondition
>> can find an appropriate Query and, if so, look to see whether the
>> appropriate variables are present in its EvaluationEnvironment, lazily
>> binding them as
>> necessary. Then, check the Query to see whether the condition holds.
>
> The AbstractEvaluationEnvironment doesn't expose a containsKey method,
> however I can catch the exception in the add method to check whether or
> not the variable value is already bound. I assume that the variable
> definitions feed in ocl environment is propagated to the many query object
> implied by a context free query (it means that I don't need to check the
> ocl environment to see if a variable definition exists).
>
> Best Regards.
>
> Xavier
>
>> HTH,
>
>> Christian
>
>
>> Xavier Maysonnave wrote:
>
>>> Thanks for your quick reply.
>>>
>>> I'm using the web interface so I cannot cross post message on both EMFT
>>> and OCL newsgroup. sorry for that.
>>>
>>> The hint is definitely helpful.
>>>
>>> However about the context free. I'm not sure to understand what you mean
>>> about 'wrinkle'. Does it mean that we can't assign variables in the same
>>> way we do with contextual query ?
>>>
>>> At the moment I build BooleanOCLCondition for contextual and non
>>> contextual element (our user choose which query they want to use). I
>>> will probably specialize BooleanOCLCondition to define and bind our
>>> defined variables.
>>>
>>> Thanks.
Previous Topic:Show children in Property Sheet
Next Topic:xs:choice support in Ecore
Goto Forum:
  


Current Time: Thu Sep 19 18:51:24 GMT 2024

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

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

Back to the top