Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Debugging OCL constraints in UML profiles
Debugging OCL constraints in UML profiles [message #1132953] Fri, 11 October 2013 13:56 Go to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

Consider the project in attach. When validating the model, there's an exception [*] generated ("evaluation returns invalid" when evaluating the constraint 'Mass Version of don't call me your name!'

After some trial and error, I couldn't find the cause of the error Sad

When I would have a similar situation for constraints on an ecore model, I would typically use the OCL console on an instance of the ecore model to debug this kind of problem, but in this case, it's not very helpful to run the OCL console on the UML model itself. For instance, if I open the xtext OCL console and select the 'Attribute1' attribute of Class1, I found out after some (a lot) trial and error, that I can (only?) access the tagged values using the "getValue" method in the console, fi.

Evaluating:
self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'st2')
Results:
Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean


however, for instance, I couldn't find a way of returning the lower and upper boundaries of yourName (by adding calls to the above expression, that is)?

So two questions:
- Anyone has a clue what is wrong with that particular constraint?
- Does there exist a (convenient) way of debugging OCL constraints in profiles?

TIA,

Klaas


[*]
 Error	An exception occurred while delegating evaluation of the 'MassVersionofdontcallmeyourname' invariant on 'Stereotype1 -> <<Stereotype1>> <Property> Attribute1 : Boolean': OCL validation result of 'Stereotype1::MassVersionofdontcallmeyourname' is invalid for 'Stereotype Stereotype1'	<<Stereotype1>> <Property> Attribute1 : Boolean	Model::Class1	EMF Problem


Tooling info: Kepler SR1
OCL End User SDK 4.2.0.v20130819-1305 org.eclipse.ocl.all.sdk.feature.group Eclipse Modeling Project
OCL Examples and Editors 3.3.1.v20130916-1423 org.eclipse.ocl.examples.feature.group Eclipse Modeling Project
Re: Debugging OCL constraints in UML profiles [message #1132965 is a reply to message #1132953] Fri, 11 October 2013 14:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Without studying your attachment I can already see a problem:

'Mass Version of don't call me your name!'


has a single quote character in it. You need to escape it.

An OCL debugger is getting to the top of my priority list. It will be
invokable in the context of third party applications so that the
debugger comes to your model, rather than requiring you to struggle to
reproduce your models in the Console. Hopefully this will be available
for Luna.

Regards

Ed Willink


On 11/10/2013 14:57, Klaas Gadeyne wrote:
> Hi,
>
> Consider the project in attach. When validating the model, there's an exception [*] generated ("evaluation returns invalid" when evaluating the constraint 'Mass Version of don't call me your name!'
>
> After some trial and error, I couldn't find the cause of the error :(
>
> When I would have a similar situation for constraints on an ecore model, I would typically use the OCL console on an instance of the ecore model to debug this kind of problem, but in this case, it's not very helpful to run the OCL console on the UML model itself. For instance, if I open the xtext OCL console and select the 'Attribute1' attribute of Class1, I found out after some (a lot) trial and error, that I can (only?) access the tagged values using the "getValue" method in the console, fi.
>
>
> Evaluating:
> self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'st2')
> Results:
> Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean
>
>
> however, for instance, I couldn't find a way of returning the lower and upper boundaries of yourName (by adding calls to the above expression, that is)?
>
> So two questions:
> - Anyone has a clue what is wrong with that particular constraint?
> - Does there exist a (convenient) way of debugging OCL constraints in profiles?
>
> TIA,
>
> Klaas
>
>
> [*] Error An exception occurred while delegating evaluation of the 'MassVersionofdontcallmeyourname' invariant on 'Stereotype1 -> <<Stereotype1>> <Property> Attribute1 : Boolean': OCL validation result of 'Stereotype1::MassVersionofdontcallmeyourname' is invalid for 'Stereotype Stereotype1' <<Stereotype1>> <Property> Attribute1 : Boolean Model::Class1 EMF Problem
>
>
> Tooling info: Kepler SR1
> OCL End User SDK 4.2.0.v20130819-1305 org.eclipse.ocl.all.sdk.feature.group Eclipse Modeling Project
> OCL Examples and Editors 3.3.1.v20130916-1423 org.eclipse.ocl.examples.feature.group Eclipse Modeling Project
Re: Debugging OCL constraints in UML profiles [message #1134310 is a reply to message #1132965] Sat, 12 October 2013 11:48 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Ed Willink wrote on Fri, 11 October 2013 10:06
Without studying your attachment I can already see a problem:

'Mass Version of don't call me your name!'


has a single quote character in it. You need to escape it.

Maybe, but there are two constraints in the profile, the other constraint's name was "don't call me your name" and evaluated without exception? Nevertheless I tried removing the single quote character, but as expected it didn't solve the problem.

Quote:

An OCL debugger is getting to the top of my priority list. It will be
invokable in the context of third party applications so that the
debugger comes to your model, rather than requiring you to struggle to
reproduce your models in the Console. Hopefully this will be available
for Luna.


Good to know. Thx! Meanwhile, are there any workarounds one can use for debugging UML profile constraints using the console?

k


On 11/10/2013 14:57, Klaas Gadeyne wrote:
> Hi,
>
> Consider the project in attach. When validating the model, there's an exception [*] generated ("evaluation returns invalid" when evaluating the constraint 'Mass Version of don't call me your name!'
>
> After some trial and error, I couldn't find the cause of the error Sad
>
> When I would have a similar situation for constraints on an ecore model, I would typically use the OCL console on an instance of the ecore model to debug this kind of problem, but in this case, it's not very helpful to run the OCL console on the UML model itself. For instance, if I open the xtext OCL console and select the 'Attribute1' attribute of Class1, I found out after some (a lot) trial and error, that I can (only?) access the tagged values using the "getValue" method in the console, fi.
>
>
> Evaluating:
> self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'st2')
> Results:
> Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean
>
>
> however, for instance, I couldn't find a way of returning the lower and upper boundaries of yourName (by adding calls to the above expression, that is)?
>
> So two questions:
> - Anyone has a clue what is wrong with that particular constraint?
> - Does there exist a (convenient) way of debugging OCL constraints in profiles?
>
> TIA,
>
> Klaas
>
>
> [*] Error An exception occurred while delegating evaluation of the 'MassVersionofdontcallmeyourname' invariant on 'Stereotype1 -> <<Stereotype1>> <Property> Attribute1 : Boolean': OCL validation result of 'Stereotype1::MassVersionofdontcallmeyourname' is invalid for 'Stereotype Stereotype1' <<Stereotype1>> <Property> Attribute1 : Boolean Model::Class1 EMF Problem
>
>
> Tooling info: Kepler SR1
> OCL End User SDK 4.2.0.v20130819-1305 org.eclipse.ocl.all.sdk.feature.group Eclipse Modeling Project
> OCL Examples and Editors 3.3.1.v20130916-1423 org.eclipse.ocl.examples.feature.group Eclipse Modeling Project[/quote]
Re: Debugging OCL constraints in UML profiles [message #1134404 is a reply to message #1134310] Sat, 12 October 2013 13:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The console assigns the selected EObject to self, so if you select an
interesting object in the UML Model Editor or Papyrus Class Diagram, you
should be able to practice evaluations.

Regards

Ed Willink

On 12/10/2013 12:48, Klaas Gadeyne wrote:
> Ed Willink wrote on Fri, 11 October 2013 10:06
>> Without studying your attachment I can already see a problem:
>>
>> 'Mass Version of don't call me your name!'
>>
>>
>> has a single quote character in it. You need to escape it.
>
> Maybe, but there are two constraints in the profile, the other
> constraint's name was "don't call me your name" and evaluated without
> exception? Nevertheless I tried removing the single quote character,
> but as expected it didn't solve the problem.
>
> Quote:
>> An OCL debugger is getting to the top of my priority list. It will be
>> invokable in the context of third party applications so that the
>> debugger comes to your model, rather than requiring you to struggle
>> to reproduce your models in the Console. Hopefully this will be
>> available for Luna.
>
>
> Good to know. Thx! Meanwhile, are there any workarounds one can use
> for debugging UML profile constraints using the console?
>
> k
>
>
> On 11/10/2013 14:57, Klaas Gadeyne wrote:
>> Hi,
>>
>> Consider the project in attach. When validating the model, there's
>> an exception [*] generated ("evaluation returns invalid" when
>> evaluating the constraint 'Mass Version of don't call me your name!'
>>
>> After some trial and error, I couldn't find the cause of the error :(
>>
>> When I would have a similar situation for constraints on an ecore
>> model, I would typically use the OCL console on an instance of the
>> ecore model to debug this kind of problem, but in this case, it's not
>> very helpful to run the OCL console on the UML model itself. For
>> instance, if I open the xtext OCL console and select the 'Attribute1'
>> attribute of Class1, I found out after some (a lot) trial and error,
>> that I can (only?) access the tagged values using the "getValue"
>> method in the console, fi.
>>
>>
>> Evaluating:
>> self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'st2')
>>
>> Results:
>> Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean
>>
>>
>> however, for instance, I couldn't find a way of returning the lower
>> and upper boundaries of yourName (by adding calls to the above
>> expression, that is)?
>>
>> So two questions:
>> - Anyone has a clue what is wrong with that particular constraint?
>> - Does there exist a (convenient) way of debugging OCL constraints in
>> profiles?
>>
>> TIA,
>>
>> Klaas
>>
>>
>> [*] Error An exception occurred while delegating evaluation of
>> the 'MassVersionofdontcallmeyourname' invariant on 'Stereotype1 ->
>> <<Stereotype1>> <Property> Attribute1 : Boolean': OCL validation
>> result of 'Stereotype1::MassVersionofdontcallmeyourname' is invalid
>> for 'Stereotype Stereotype1' <<Stereotype1>> <Property>
>> Attribute1 : Boolean Model::Class1 EMF Problem
>>
>>
>> Tooling info: Kepler SR1
>> OCL End User SDK 4.2.0.v20130819-1305
>> org.eclipse.ocl.all.sdk.feature.group Eclipse Modeling Project
>> OCL Examples and Editors 3.3.1.v20130916-1423
>> org.eclipse.ocl.examples.feature.group Eclipse Modeling
>> Project[/quote]
>
Re: Debugging OCL constraints in UML profiles [message #1137538 is a reply to message #1134404] Mon, 14 October 2013 15:08 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Ed Willink wrote on Sat, 12 October 2013 09:17
Hi
The console assigns the selected EObject to self, so if you select an
interesting object in the UML Model Editor or Papyrus Class Diagram, you
should be able to practice evaluations.


At least this is what I (think I) tried. However, I don't succeed in debugging the erroneous OCL constraint in my example profile in this way (see attached project in original message). So, as I tried to explain in my original post, I select Attribute1 in the StereoTypeMultiplicity.uml model and then try to use the OCL console to figure out what's wrong (see also attached screenshot!)

self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2')

correctly resolves to {{Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean}}

However, the call to
self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2').name

results in a parsing failure, which I tried to circumvent using

self.getValue(self.getAppliedStereotypes()->asOrderedSet()>first(),'multiple_st2').oclAsType(uml::Property).name


But then I end up with an "evaluation failure" as you can see in the screenshot. Could you explain me concretely for this example what I could additionally or alternatively do to debug the "invalid" result" exception that occurs when evaluating the "Mass Version of dont call me your name!" constraint?

Thx,

Klaas
Re: Debugging OCL constraints in UML profiles [message #1137608 is a reply to message #1137538] Mon, 14 October 2013 16:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I am not convinced that getAppliedStereotypes() is necessary. It seems
to be a bad API that tries to workaround deficient OCL functionality.
Bad, because it loses type information and in the case of collections
requires troublesome Object/Collection casts.

The pivot-based approach endeavours to make base_XXXX and extension_XXXX
work as indicated by the UML specification. When the UML
metamodel/profile is loaded and realized as a pivot model, the synthetic
base_XXXX / extension_XXXX at M2 are reified as static properties at M1,
so that they can be navigated in a relatively conventional fashion.

So rather than
"self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2')",
I think it should be possible to write something like
"self.extension_multiple_st2->first()" if you expect success, or guard
with oclIsInvalid() if you're unsure that the extension exists.

Regards

Ed Willink



On 14/10/2013 16:08, Klaas Gadeyne wrote:
> Ed Willink wrote on Sat, 12 October 2013 09:17
>> Hi
>> The console assigns the selected EObject to self, so if you select an
>> interesting object in the UML Model Editor or Papyrus Class Diagram, you
>> should be able to practice evaluations.
>
> At least this is what I (think I) tried. However, I don't succeed in debugging the erroneous OCL constraint in my example profile in this way (see attached project in original message). So, as I tried to explain in my original post, I select Attribute1 in the StereoTypeMultiplicity.uml model and then try to use the OCL console to figure out what's wrong (see also attached screenshot!)
>
>
> self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2')
>
> correctly resolves to {{Stereotype2 -> <<Stereotype2>> <Property> yourName : Boolean}}
>
> However, the call to
>
> self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2').name
>
> results in a parsing failure, which I tried to circumvent using
>
>
> self.getValue(self.getAppliedStereotypes()->asOrderedSet()>first(),'multiple_st2').oclAsType(uml::Property).name
>
>
> But then I end up with an "evaluation failure" as you can see in the screenshot. Could you explain me concretely for this example what I could additionally or alternatively do to debug the "invalid" result" exception that occurs when evaluating the "Mass Version of dont call me your name!" constraint?
>
> Thx,
>
> Klaas
Re: Debugging OCL constraints in UML profiles [message #1138657 is a reply to message #1137608] Tue, 15 October 2013 08:29 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Ed Willink wrote on Mon, 14 October 2013 12:08
Hi
So rather than
"self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2')",
I think it should be possible to write something like
"self.extension_multiple_st2->first()" if you expect success, or guard
with oclIsInvalid() if you're unsure that the extension exists.


OK (I guess you mean "self.extension_Stereotype1.multiple_st2->first()", right?

However, the "extension_" stuff doesn't seem to work Sad

This happens with xtext console and having selected Attribute1 as context element
Evaluating:
self
Results:
<<Stereotype1>> <Property> Attribute1 : Boolean

Evaluating:
self.extension_Stereotype1
Results:
Parsing failure

1: Unresolved Property 'uml::Property::extension_Stereotype1'


Klaas

Re: Debugging OCL constraints in UML profiles [message #1138712 is a reply to message #1138657] Tue, 15 October 2013 09:17 Go to previous messageGo to next message
Klaas Gadeyne is currently offline Klaas GadeyneFriend
Messages: 165
Registered: July 2009
Senior Member
Hi Ed,

I think I've discovered at least some problems with the MDT/OCL stuff
Please see the attached Project:
- When trying to add constraints to the model, I can successfully use your approach of 'extension_XXX' , as long as the stereotype is applied to the UML meta-class Class. See 'Constraint1'.
- However, this seems not to work if the stereotype is applied to a UML::Property. Then the context assist only yields extension_EDataType (where it should offer 'extension_Stereotype1'.
- Furthermore (see also previous post), I cannot use the extension_ keyword in the xtext console (nor in the old console)

Re: Debugging OCL constraints in UML profiles [message #1139526 is a reply to message #1138657] Tue, 15 October 2013 20:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Comments below:

On 15/10/2013 09:29, Klaas Gadeyne wrote:
> Ed Willink wrote on Mon, 14 October 2013 12:08
>> Hi
>> So rather than
>> "self.getValue(self.getAppliedStereotypes()->asOrderedSet()->first(),'multiple_st2')",
>> I think it should be possible to write something like
>> "self.extension_multiple_st2->first()" if you expect success, or
>> guard with oclIsInvalid() if you're unsure that the extension exists.
>
>
> OK (I guess you mean
> "self.extension_Stereotype1.multiple_st2->first()", right?
Yes.
> However, the "extension_" stuff doesn't seem to work :(
Yes. There is a missing adaptation of the selection from UML elements.
So all UML selections are treated as simple Ecore objects; no metaclass,
no profiles etc etc.

Easily fixed.
>
> This happens with xtext console and having selected Attribute1 as
> context element
This is rather more interesting. Properties of Properties are in the
gaping hole between UML and OCL. Obviously required by UML but contrary
to the limited OCL exposition.
The underlying Metaclass<T> support of the pivot-based Eclipse OCL
should be able to support this without difficulty; I hope. ? tomorrow.

Regards

Ed Willink
Re: Debugging OCL constraints in UML profiles [message #1140141 is a reply to message #1139526] Wed, 16 October 2013 06:49 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

On 15/10/2013 21:54, Ed Willink wrote:
>> However, the "extension_" stuff doesn't seem to work :(
> Yes. There is a missing adaptation of the selection from UML elements.
> So all UML selections are treated as simple Ecore objects; no
> metaclass, no profiles etc etc.
>
> Easily fixed.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419556
>>
>> This happens with xtext console and having selected Attribute1 as
>> context element
> This is rather more interesting. Properties of Properties are in the
> gaping hole between UML and OCL. Obviously required by UML but
> contrary to the limited OCL exposition.
> The underlying Metaclass<T> support of the pivot-based Eclipse OCL
> should be able to support this without difficulty; I hope. ? tomorrow.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=419557

Regards

Ed Willink
Previous Topic:OCL Validation outside of eclipse
Next Topic:Programmatically load a complete OCL file
Goto Forum:
  


Current Time: Tue Apr 16 20:27:36 GMT 2024

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

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

Back to the top