Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Error in validating OCL for UML models
Error in validating OCL for UML models [message #1427403] Sat, 20 September 2014 05:36 Go to next message
azadeh jb is currently offline azadeh jbFriend
Messages: 18
Registered: September 2013
Junior Member
Hi,
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 .

Thanks,
Azadeh

[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 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1206
Registered: July 2009
Location: Canada
Senior Member

Hi, Azadeh,

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 ...

HTH,

Christian

On 2014-09-20 05:36:43 +0000, azadeh jb said:

> Hi,
> 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
> 'OclInvalid::>(UnlimitedNatural)'"
>
> 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
> not.
>
> I would appreciate if you can help me with this .
>
> Thanks,
> Azadeh
Previous Topic:ModelExplorer customization, EMF Facet and MODISCO
Next Topic:create parametrized templates with Papyrus
Goto Forum:
  


Current Time: Sun Jul 12 20:19:31 GMT 2020

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

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

Back to the top