|Error in validating OCL for UML models [message #1427403]
||Sat, 20 September 2014 05:36
| azadeh jb
Registered: September 2013
I have some difficulties working with OCL constraints and validating them in Papyrus for UML models. I create a simple UML profile with a stereotype. I created a complete ocl file and add that to the project and load it to the profile (through Load Resource context menu ). I created a model and applied the profile on the model and applied its stereotype on the class of the model. When I validate the model, it doesn't check the ocl constraint.
Am I missing something here working with Complete OCL file? Because When I define the OCLs inside the profile and applying it to the model, it is checked.
I would appreciate if you can help me with this .
[Updated on: Sun, 21 September 2014 23:08]
Report message to a moderator
|Re: Error in Parsing OCL for UML profile [message #1430530 is a reply to message #1427403]
||Wed, 24 September 2014 13:29
|| Christian Damus
Registered: July 2009
Sets are unordered collections. They have no first() operation.
Try this instead, to access the first available member of the set:
self.stereotype2.Att3->asSet()->any(true) > 5
or use an ordered collection:
self.stereotype2.Att3->asSequence()->first() > 5
Of course, neither of these properly accounts for the possibility that
the value of Att3 may be an empty collection ...
On 2014-09-20 05:36:43 +0000, azadeh jb said:
> I have some difficulties working with OCL constraints and validating
> them in Papyrus for UML profiles. I create a simple UML profile with
> two stereotypes which are related through an association. When I try to
> write some of OCL expressions which has navigation from a stereotype to
> another one, I get Parsing error. E.g when I write the following
> constraint for Stereotype 1 to access the Att3 of the first element of
> stereotype2 : self.stereotype2.Att3->asSet()->first()>5
> constraint is invalid: 'self.stereotype2.Att3->asSet()->first()>5' 1:
> Unresolved Operation 'Set(Integer)::first()' 1: Unresolved Operation
> some other functions like sum() can be parsed but sometimes during
> validation of the OCLs on the models (with the profile applied on the
> models) they don't work properly. Not sure if it is a cache problem or
> I would appreciate if you can help me with this .
Powered by FUDForum
. Page generated in 0.02062 seconds