Home » Modeling » OCL » Debugging OCL constraints in UML profiles
Debugging OCL constraints in UML profiles [message #1132953] |
Fri, 11 October 2013 13:56 |
Klaas Gadeyne 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
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 |
Ed Willink 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 |
Klaas Gadeyne Messages: 165 Registered: July 2009 |
Senior Member |
|
|
Ed Willink wrote on Fri, 11 October 2013 10:06Without 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 #1134404 is a reply to message #1134310] |
Sat, 12 October 2013 13:17 |
Ed Willink 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 |
Klaas Gadeyne Messages: 165 Registered: July 2009 |
Senior Member |
|
|
Ed Willink wrote on Sat, 12 October 2013 09:17Hi
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 |
Ed Willink 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
|
|
| | | | |
Goto Forum:
Current Time: Fri Apr 26 09:56:18 GMT 2024
Powered by FUDForum. Page generated in 0.03552 seconds
|