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?
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?
"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
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.
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.
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.
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.
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".
On 17/07/2015 10:58, Jens Bürger wrote:
> 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 |
> The result is:
> So how can I access the tagged values?
> The respective part of the .uml-file looks like this:
> <ensureRole:ensureRole xmi:id="_e75g0Cu0EeWNw6GF_Fgubg"
On 22/07/2015 16:27, Jens Bürger wrote:
> 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"
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:
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
On 31/07/2015 18:36, Ed Willink wrote:
> 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.
> Ed Willink
On 01/08/2015 10:02, Ed Willink wrote:
> Further correspondence on:
> Ed Willink
> On 31/07/2015 18:36, Ed Willink wrote:
>> 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.
>> Ed Willink