Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to query UML models with OCL?
How to query UML models with OCL? [message #1701830] Thu, 16 July 2015 05:26 Go to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Hello everyone,
I am working on using OCL to query UML models.

Besides diverse examples, I don't know how certain UML metamodel elements are accessed via OCL when an instance model is given.

Where am I supposed to look after this information?
Re: How to query UML models with OCL? [message #1701849 is a reply to message #1701830] Thu, 16 July 2015 08:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

There is a bit of a specification chasm between UML and OCL when you get
to the detail.

Use of Class/Property is pretty obvious. State is fairly obvious.

What UML elements are you interested in?

Regards

Ed Willink


On 16/07/2015 06:26, Jens Bürger wrote:
> Hello everyone,
> I am working on using OCL to query UML models.
>
> Besides diverse examples, I don't know how certain UML metamodel
> elements are accessed via OCL when an instance model is given.
>
> Where am I supposed to look after this information?
Re: How to query UML models with OCL? [message #1701860 is a reply to message #1701849] Thu, 16 July 2015 09:43 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Thanks for your answer,
For example, the handling of stereotypes as provided by UML profiles is unclear to me.

Currently I am experimenting using a model loaded in Papyrus UML and the interactive Xtext OCL console.

The only thing I managed so far is querying an element directly (when it's selected) using getAppliedStereotypes().

What I want to do is query the model on root-level, find instances of specific stereotypes, get the elements they are applied to and so on.
Re: How to query UML models with OCL? [message #1701870 is a reply to message #1701860] Thu, 16 July 2015 10:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

"stereotype" is not mentioned at all in the OCL spec. The UML 2.5 spec
has one tiny example in 12.3.3 Extensions, from which I have been
extrapolating a typesafe solution that is implemented by the pivot-based
Eclipse OCL.

You should never need to use the unsafe Java API. Navigation using
base_XXX or extension_YYY should achieve what you want without loss of
type information. There is completion assist in Papyrus. Unfortunately
this documentatiuon is one of the many jobs that didn't get done for Mars.

Regards

Ed Willink





On 16/07/2015 10:43, Jens Bürger wrote:
> Thanks for your answer,
> For example, the handling of stereotypes as provided by UML profiles
> is unclear to me.
>
> Currently I am experimenting using a model loaded in Papyrus UML and
> the interactive Xtext OCL console.
>
> The only thing I managed so far is querying an element directly (when
> it's selected) using getAppliedStereotypes().
>
> What I want to do is query the model on root-level, find instances of
> specific stereotypes, get the elements they are applied to and so on.
Re: How to query UML models with OCL? [message #1701877 is a reply to message #1701870] Thu, 16 July 2015 11:31 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Ed Willink wrote on Thu, 16 July 2015 06:48

The UML 2.5 spec
has one tiny example in 12.3.3 Extensions, from which I have been
extrapolating a typesafe solution that is implemented by the pivot-based
Eclipse OCL.

Which components use the pivot-based Eclipse OCL? I am using Kepler, Papyrus and the interactive Xtext Console.

self_ and extension_ seem not to be recognized there.
Re: How to query UML models with OCL? [message #1701879 is a reply to message #1701877] Thu, 16 July 2015 11:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

My recollection is that it was Papyrus Luna for which we worked hard on
the OCL integration. Mars should be better.

The pivot-based tooling is used by all the UI tooling
- Papyrus (except batch validation with EMFv/EMFq)
- OCL editors/valiodation view/debugger
- Xext OCL console (not non-Xtext console)

As a minimum you really should use the final Luna maintenance releases.

Regards

Ed Willink

On 16/07/2015 12:31, Jens Bürger wrote:
> Ed Willink wrote on Thu, 16 July 2015 06:48
>> The UML 2.5 spec has one tiny example in 12.3.3 Extensions, from
>> which I have been extrapolating a typesafe solution that is
>> implemented by the pivot-based Eclipse OCL.
>
> Which components use the pivot-based Eclipse OCL? I am using Kepler,
> Papyrus and the interactive Xtext Console.
>
> self_ and extension_ seem not to be recognized there.
>
Re: How to query UML models with OCL? [message #1701993 is a reply to message #1701879] Fri, 17 July 2015 09:58 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Thanks,

so for now I will use Mars.

I managed to get close to what I want in a first test case.
I have a state chart and a transition with a stereotype <<ensureRole>>.
This stereotype has a tagged value "role" which is represented as a String array. The actual only element is "a=b".

I use the following query:
Transition.allInstances()->select(t | t.getAppliedStereotypes().name->includes('ensureRole')).getAppliedStereotypes().getAllAttributes()->select(x|x.name='role')


The result is:
ensureRole::ensureRole::role


So how can I access the tagged values?
The respective part of the .uml-file looks like this:
...
  </uml:Model>
  <ensureRole:ensureRole xmi:id="_e75g0Cu0EeWNw6GF_Fgubg" base_Transition="__AaxQIRzEeSbXcAiNcJFPQ">
    <role>a=b</role>
   <role>x=y</role>
  </ensureRole:ensureRole>
</xmi:XMI>

Re: How to query UML models with OCL? [message #1702039 is a reply to message #1701993] Fri, 17 July 2015 19:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

Perhaps you want

Transition.allInstances().extension_ensureRole->excluding(null).role

Regards

Ed Willink

On 17/07/2015 10:58, Jens Bürger wrote:
> Thanks,
>
> so for now I will use Mars.
>
> I managed to get close to what I want in a first test case.
> I have a state chart and a transition with a stereotype <<ensureRole>>.
> This stereotype has a tagged value "role" which is represented as a
> String array. The actual only element is "a=b".
>
> I use the following query:
> Transition.allInstances()->select(t |
> t.getAppliedStereotypes().name->includes('ensureRole')).getAppliedStereotypes().getAllAttributes()->select(x|x.name='role')
>
> The result is:
> ensureRole::ensureRole::role
>
> So how can I access the tagged values?
> The respective part of the .uml-file looks like this:
>
> ..
> </uml:Model>
> <ensureRole:ensureRole xmi:id="_e75g0Cu0EeWNw6GF_Fgubg"
> base_Transition="__AaxQIRzEeSbXcAiNcJFPQ">
> <role>a=b</role>
> <role>x=y</role>
> </ensureRole:ensureRole>
> </xmi:XMI>
>
>
Re: How to query UML models with OCL? [message #1702157 is a reply to message #1702039] Mon, 20 July 2015 11:52 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Parsing failure

1: Unresolved Property 'Set(UML::Transition[*|1])::extension_ensureRole'
Re: How to query UML models with OCL? [message #1702471 is a reply to message #1702039] Wed, 22 July 2015 14:27 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
P.S.:

I think the problem is that the relationship between the transition and the stereotype isn't bi-directional: there is no extension-attribute at the transition:

<transition xmi:type="uml:Transition" xmi:id="__AaxQIRzEeSbXcAiNcJFPQ" name="Transition3" source="_9qKwAIRzEeSbXcAiNcJFPQ" target="_pExbcIBkEeSC14s56zC7NQ"/>

Re: How to query UML models with OCL? [message #1702484 is a reply to message #1702471] Wed, 22 July 2015 16:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

As I commented in my previous accidentally off-list reply,

Without models I cannot offer any further help. See

http://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink

On 22/07/2015 16:27, Jens Bürger wrote:
> P.S.:
>
> I think the problem is that the relationship between the transition and
> the stereotype isn't bi-directional: there is no extension-attribute at
> the transition:
>
>
> <transition xmi:type="uml:Transition" xmi:id="__AaxQIRzEeSbXcAiNcJFPQ"
> name="Transition3" source="_9qKwAIRzEeSbXcAiNcJFPQ"
> target="_pExbcIBkEeSC14s56zC7NQ"/>
>
>
Re: How to query UML models with OCL? [message #1702485 is a reply to message #1702484] Wed, 22 July 2015 16:14 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
OK, I'm sorry, here we go.
Re: How to query UML models with OCL? [message #1702503 is a reply to message #1702485] Wed, 22 July 2015 18:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

A model helps, but not much without a profile too.

Regards

Ed Willink


On 22/07/2015 18:14, Jens Bürger wrote:
> OK, I'm sorry, here we go.
>
Re: How to query UML models with OCL? [message #1702699 is a reply to message #1702503] Fri, 24 July 2015 08:12 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Right Cool
Re: How to query UML models with OCL? [message #1702855 is a reply to message #1702699] Sun, 26 July 2015 09:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

Without ALL models I cannot offer any further help. Read

http://wiki.eclipse.org/OCL/ForumNetiquette

carefully. You are wasting both of our times.

Regards

Ed Willink

On 24/07/2015 09:12, Jens Bürger wrote:
> Right 8)
>
Re: How to query UML models with OCL? [message #1703280 is a reply to message #1702855] Thu, 30 July 2015 09:06 Go to previous messageGo to next message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Many apologies.
I saw that there were some unneeded profile applications left in the model.
However, I hereby provide an zipped project containing (hopefully) all necessary data. I revised the test model.
Additional information as requested:

Problem description:

I want to query instances of UML-stereotypes and their tagged values.
In the specific case, I want to get values of the tagged value "role" of the stereotype "ensureRole" which is attached to state chart transitions.

Actually I'm trying to do this queries using the Xtext OCL console.

Eclipse version: Mars Release 4.5.0
org.eclipse.ocl.ecore: 3.5.0.v20150525-1635
org.eclipse.ocl.pivot: 1.0.0.v20150603-1503
  • Attachment: ocltest.zip
    (Size: 121.01KB, Downloaded 65 times)
Re: How to query UML models with OCL? [message #1703463 is a reply to message #1703280] Fri, 31 July 2015 17:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

Ok, I can now load the model and see some problems.

[It is very bad practice and probably illegal to use the same spelling
for a Package and a contained Class. In your case you use "ensureRole"
for both Profile and Stereotype.]

I see your problem in the Xtext OCL console. Oddly when I set up a JUnit
test to do the same thing in an animated console it works.
Investigating.

Regards

Ed Willink
Re: How to query UML models with OCL? [message #1703493 is a reply to message #1703463] Sat, 01 August 2015 09:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

Further correspondence on:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=474085

Regards

Ed Willink

On 31/07/2015 18:36, Ed Willink wrote:
> Hi
>
> Ok, I can now load the model and see some problems.
>
> [It is very bad practice and probably illegal to use the same spelling
> for a Package and a contained Class. In your case you use "ensureRole"
> for both Profile and Stereotype.]
>
> I see your problem in the Xtext OCL console. Oddly when I set up a
> JUnit test to do the same thing in an animated console it works.
> Investigating.
>
> Regards
>
> Ed Willink
Re: How to query UML models with OCL? [message #1703645 is a reply to message #1703493] Mon, 03 August 2015 19:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5970
Registered: July 2009
Senior Member
Hi

http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.0.1/N201508031256/mdt-ocl-Update-N201508031256.zip

should fix the problem.

Regards

Ed Willink

On 01/08/2015 10:02, Ed Willink wrote:
> Hi
>
> Further correspondence on:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=474085
>
> Regards
>
> Ed Willink
>
> On 31/07/2015 18:36, Ed Willink wrote:
>> Hi
>>
>> Ok, I can now load the model and see some problems.
>>
>> [It is very bad practice and probably illegal to use the same
>> spelling for a Package and a contained Class. In your case you use
>> "ensureRole" for both Profile and Stereotype.]
>>
>> I see your problem in the Xtext OCL console. Oddly when I set up a
>> JUnit test to do the same thing in an animated console it works.
>> Investigating.
>>
>> Regards
>>
>> Ed Willink
>
Re: How to query UML models with OCL? [message #1705442 is a reply to message #1703463] Sat, 15 August 2015 14:40 Go to previous message
Jens Bürger is currently offline Jens BürgerFriend
Messages: 46
Registered: October 2012
Member
Looks like it works now. Thanks!
Previous Topic:Nested OCL forAlls
Next Topic:Cannot access OCL functions
Goto Forum:
  


Current Time: Tue Jul 17 19:34:16 GMT 2018

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

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

Back to the top