Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Interpreter on ecore M1
OCL Interpreter on ecore M1 [message #729395] Mon, 26 September 2011 01:45 Go to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Dear all,

with my own EMF model, the OCL interpreter parses and executes fine on the M2 level.
However, I would like to specify queries on the M1 level as well. Obviously, OCL would need to know more about my model-structure for that. Is there any way / API to extend OCL in such a way?

Would that be in any way related to the Environment API? And if, how would I add another environment, since the extension point seems deprecated?

Best Regards,

Andreas
Re: OCL Interpreter on ecore M1 [message #729407 is a reply to message #729395] Mon, 26 September 2011 02:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4030
Registered: July 2009
Senior Member
Hi Andreas

I'm afraid that the terms M1 and M2 etc can be very confusing,
particular in regard to evaluation, and so while one person may think
they understand them another may have another interpretation.

Mx levels are not really applicable to OCL which can apply at any level;
you just provide the meta-model.

So by saying that M2 works and M1 doesn't, it seems you want to use OCL
as an application language, which is ordinary usage with Eclipse OCL, so
either I'm misunderstanding you, or you've overlooked something obvious.

Please provide a clearer example ow what you want.

Regards

Ed Willink

On 26/09/2011 06:45, Andreas Graf wrote:
> Dear all,
>
> with my own EMF model, the OCL interpreter parses and executes fine on
> the M2 level.
> However, I would like to specify queries on the M1 level as well.
> Obviously, OCL would need to know more about my model-structure for
> that. Is there any way / API to extend OCL in such a way?
>
> Would that be in any way related to the Environment API? And if, how
> would I add another environment, since the extension point seems
> deprecated?
>
> Best Regards,
>
> Andreas
Re: OCL Interpreter on ecore M1 [message #729425 is a reply to message #729407] Mon, 26 September 2011 03:05 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Dear Ed,

I was referring to "M2" and "M1" as the choices on the drop down box of the OCL interpreter. I have attached a screenshot to illustrate my question.

I am opening my EMF model with the sample reflective ecore editor and then opening an ocl interpreter console with the context menu.

As long as the choice box is set to M2, the queries work well. But I want to be able to specify queries on the M1 level (not execute them, just use the ocl console to edit them).

In the example, a query "self" with M2 set returns "Node LogicalFunction". However, for further processing in another tool, I would like to be able to specify queries on "M1", which I'd expect to return an object "LogicalFunction" for "self".

But obviously, OCL could not know how to infer types and attributes for arbitrary meta-models.

In the end, for nodes LogicalFunction / InPort etc. as from the example, I would like to be able to use those as "1st class citizens" in the OCL query.

Hope that clarifies,

Andreas


Re: OCL Interpreter on ecore M1 [message #729443 is a reply to message #729425] Mon, 26 September 2011 03:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4030
Registered: July 2009
Senior Member
Hi

Ah, that M1/M2. When I cloned the OCL Console for the OCL Xtext Console
I had no idea what the M1/M2 dropdown really did and so I dropped it.
The main usage seems to be for UML where the auto-translation to Ecore
can provide confusion over which model is in use.

You could try the OCL Xtext Console; it might be less fussy, but I don't
think what you're trying to do is reasonable.

OCL can evaluate values in any context but as soon as you want to use
objects, you must have meta-models.

Your LogicalFunction Node is an instance of the Node meta-model element
and so you may use Node-related functionality.

If you want to use LogicalFunction-related functionality then you need
to provide the meta-model in which presumably LogicalFunction is a form
of Operation.

Eclipse OCL is Open Source software so of course it's possible, but
emulating the existing Ecore or UML bindings for 'Logical' is a
significant undertaking. The xxxEnvironment is just a small part of this
activity.

The new Pivot model that supports the Xtext-based functionalities is
neutral, so there you have the much simpler task of providing a
Logical2Pivot converter. However the pivot code is of example quality
and is evolving to provide APIs that should make this kind of activity
significantly easier.

I've raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=358853 so that
an Xtext Console might reinstate the 'M1' option to support an
Alien2Pivot converter, which might be what you want.

Today, you could try a Logical2Ecore converter, or, not recommended at
all, arrange for your LogicalFunction to extend EOperation.

Regards

Ed Willink

On 26/09/2011 08:05, Andreas Graf wrote:
> Dear Ed,
>
> I was referring to "M2" and "M1" as the choices on the drop down box of the OCL interpreter. I have attached a screenshot to illustrate my question.
>
> I am opening my EMF model with the sample reflective ecore editor and then opening an ocl interpreter console with the context menu.
>
> As long as the choice box is set to M2, the queries work well. But I want to be able to specify queries on the M1 level (not execute them, just use the ocl console to edit them).
>
> In the example, a query "self" with M2 set returns "Node LogicalFunction". However, for further processing in another tool, I would like to be able to specify queries on "M1", which I'd expect to return an object "LogicalFunction" for "self".
>
> But obviously, OCL could not know how to infer types and attributes for arbitrary meta-models.
>
> In the end, for nodes LogicalFunction / InPort etc. as from the example, I would like to be able to use those as "1st class citizens" in the OCL query.
>
> Hope that clarifies,
>
> Andreas
>
>
>
Re: OCL Interpreter on ecore M1 [message #729451 is a reply to message #729443] Mon, 26 September 2011 04:35 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas Graf
Messages: 151
Registered: July 2009
Senior Member
Hi Ed,

thanks for your answer. It gives me an impression of what would be necessary to achieve what I'd need.

Quote:
You could try the OCL Xtext Console; it might be less fussy, but I don't
think what you're trying to do is reasonable.

OCL can evaluate values in any context but as soon as you want to use
objects, you must have meta-models.

Your LogicalFunction Node is an instance of the Node meta-model element
and so you may use Node-related functionality.

If you want to use LogicalFunction-related functionality then you need
to provide the meta-model in which presumably LogicalFunction is a form
of Operation.


Yes, it is reasonable. In fact, in my use case the "Node LogicalFuntion" element can be seen as a meta-model specification. In the full story, I would have a 2nd model that defines "instance specifications" (not instances!) of LogicalFunction, e.g.

LogicalFunction: x
LogicalFunction: y

and then I would have wanted to run the OCL queries on that "instance specification model". It would be similar to what UML does with the "InstanceSpecification" model element, but based on different meta-models.

Thank you very much for the information!

Andreas

Re: OCL Interpreter on ecore M1 [message #729498 is a reply to message #729451] Mon, 26 September 2011 06:24 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4030
Registered: July 2009
Senior Member
Hi Andreas

You might find Complete OCL more helpful. This allows you to complement
an existing meta-model.

So perhaps if you have a transient reference from LogicalFunction to an
EOperation you could add the OCL directly or indirectly to the EOperation.

Regards

Ed Willink

On 26/09/2011 09:35, Andreas Graf wrote:
> Hi Ed,
>
> thanks for your answer. It gives me an impression of what would be
> necessary to achieve what I'd need.
>
> Quote:
>> You could try the OCL Xtext Console; it might be less fussy, but I don't
>> think what you're trying to do is reasonable.
>>
>> OCL can evaluate values in any context but as soon as you want to use
>> objects, you must have meta-models.
>>
>> Your LogicalFunction Node is an instance of the Node meta-model element
>> and so you may use Node-related functionality.
>>
>> If you want to use LogicalFunction-related functionality then you need
>> to provide the meta-model in which presumably LogicalFunction is a form
>> of Operation.
>
>
> Yes, it is reasonable. In fact, in my use case the "Node
> LogicalFuntion" element can be seen as a meta-model specification. In
> the full story, I would have a 2nd model that defines "instance
> specifications" (not instances!) of LogicalFunction, e.g.
>
> LogicalFunction: x
> LogicalFunction: y
>
> and then I would have wanted to run the OCL queries on that "instance
> specification model". It would be similar to what UML does with the
> "InstanceSpecification" model element, but based on different
> meta-models.
>
> Thank you very much for the information!
>
> Andreas
>
>
Previous Topic:[Announce] Final Eclipse OCL 3.1.1 (Indigo Service Release 1) is now available
Next Topic:Evaluate operations defined via OCLinEcore in the interactive console yields OCLinvalid
Goto Forum:
  


Current Time: Sat Aug 23 07:31:31 EDT 2014

Powered by FUDForum. Page generated in 0.02378 seconds