Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » OCL Association Constraint(Validation throws error on association constraints)
OCL Association Constraint [message #1455768] Wed, 29 October 2014 18:43 Go to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi,

I am relatively new to OCL and its application to UML Profiles. I have created a simpled profile with two stereotypes ST1 and ST2 that extend metaclass UML Class and one stereotypes testLink that extends metaclass Association. In this profile, I have created the following constraint
self.base_Association.memberEnd->at(1).oclIsTypeOf(profile::Test1::ST1)
and
self.base_Association.memberEnd->at(2).oclIsTypeOf(profile::Test1::ST2)

When I save the profile, I also check the options to save the OCL constraints with the profile. I am using Kepler and Papyrus (0.10.2). In the windows Preferences->OCL, I have selected /ECore/OCL/Pivot.

When I apply the profile to an UML Class diagram (two classes and one association, applied with stereotypes) and validate the application, I have the following error

Severity	Description	Element	Parent	Type
Error	An exception occurred while delegating evaluation of the 'Constraint1' invariant on 'Test Link -> <<testLink>> <Association> myassocication': Errors in '
self.base_Association.memberEnd->at(1).oclIsTypeOf(profile::Test1::ST1)
and
self.base_Association.memberEnd->at(2).oclIsTypeOf(profile::Test1::ST2)'
2: Unresolved Property 'profile::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2::testLink::base_Association'
2: Ambiguous resolution:
	Property : uml::Association.memberEnd
	Property : UML::Association.memberEnd
2: Unresolved Operation 'Set(OclInvalid)::at(UnlimitedNatural)'
4: Unresolved Property 'profile::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2::testLink::base_Association'
4: Ambiguous resolution:
	Property : uml::Association.memberEnd
	Property : UML::Association.memberEnd
4: Unresolved Operation 'Set(OclInvalid)::at(UnlimitedNatural)'	<<testLink>> <Association> class1_class2_1	model	EMF Problem



Thanks
Re: OCL Association Constraint [message #1456143 is a reply to message #1455768] Thu, 30 October 2014 04:07 Go to previous messageGo to next message
Mahin Abbasipour is currently offline Mahin AbbasipourFriend
Messages: 24
Registered: June 2013
Junior Member
Hi,

I don't know what is wrong with "Test1::ST1". Others may help you with that. But If you want to specify the end members of an association meta class, you can write this:

self.base_Association->collect(e|e.endType().getAppliedStereotypes()->asSequence()->at(1).name)->includes('ST1')
and
self.base_Association->collect(e|e.endType().getAppliedStereotypes()->asSequence()->at(1).name)->includes('ST2')

Also, you made an assumption that the member ends first and last (i.e. at(1), at(2)) are in order which is not usually the case.
Instead of using "includes" twice, I tried the constraint below, but didn't work for me, which again I don't know the reason:

self.base_Association->collect(e|e.endType().getAppliedStereotypes()->asSequence()->at(1).name)->includesAll(Set{'ST1','ST2'})

A question that I have, Is how you will navigate with association metaclass (i.e. testLink) to write other OCLs? for example, ST1 has Attribute1 and ST2 has Attribute2 both from type of Real. You want to be sure that the value of Attribute1 is less than Attribute2. Can we do that really with meta class Associations? How about the time we need to navigate from multiple associations? This seems complicated to me.
Re: OCL Association Constraint [message #1456865 is a reply to message #1456143] Thu, 30 October 2014 20:19 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi,

Thanks. You example, helped me to figure out the right way. Furthermore, the new LUNA with OCL Console is very useful. I have used the following constraint for my purpose:

 self.base_Association.endType.getAppliedStereotypes()->asSequence().name->includesAll(Set{'ST1','ST2'}) 


But here is the interesting thing I have found. There were two ways, I have defined the OCL constrains.

1. I have used "Constraint" node from the designed Palette in Papyrus and associated "Contextual Link" to the respective stereotype. I defined the OCL constraint in the "Constraint" box and saved the profile.

2. I have defined a .ocl file using "OCL->Complete OCL File" (OCL 5.0.2) and placed it in the profile along with (.di, .notation and .uml). I have moved the OCL constraints into the .ocl file.

When I validate the model, option 1 works fine, but option 2 does'not.

Do I have to do anything specific when dealing with .ocl and papyrus (profile and class diagram).

Thanks,
Re: OCL Association Constraint [message #1456873 is a reply to message #1455768] Thu, 30 October 2014 20:25 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1206
Registered: July 2009
Location: Canada
Senior Member

Hi,

The oclIsTypeOf operation tests that a model element's metaclass is
exactly the argument. Stereotypes are not metaclasses, so your
expressions don't make sense.

You navigated the context stereotype's metaclass extension to access
the association; you need to do similarly for the member-end
properties. Something like this (not tested by me) may work:

self.base_Association.memberEnd->at(1).extension_ST1->notEmpty()
and
self.base_Association.memberEnd->at(2).extension_ST2->notEmpty()

HTH,

Christian

On 2014-10-29 18:43:01 +0000, Rishi Kanth said:

> Hi,
>
> I am relatively new to OCL and its application to UML Profiles. I have
> created a simpled profile with two stereotypes ST1 and ST2 that extend
> metaclass UML Class and one stereotypes testLink that extends metaclass
> Association. In this profile, I have created the following constraint
>
> self.base_Association.memberEnd->at(1).oclIsTypeOf(profile::Test1::ST1)
> and
> self.base_Association.memberEnd->at(2).oclIsTypeOf(profile::Test1::ST2)
>
> When I save the profile, I also check the options to save the OCL
> constraints with the profile. I am using Kepler and Papyrus (0.10.2).
> In the windows Preferences->OCL, I have selected /ECore/OCL/Pivot.
> When I apply the profile to an UML Class diagram (two classes and one
> association, applied with stereotypes) and validate the application, I
> have the following error
>
>
> Severity Description Element Parent Type
> Error An exception occurred while delegating evaluation of the
> 'Constraint1' invariant on 'Test Link -> <<testLink>> <Association>
> myassocication': Errors in '
> self.base_Association.memberEnd->at(1).oclIsTypeOf(profile::Test1::ST1)
> and
> self.base_Association.memberEnd->at(2).oclIsTypeOf(profile::Test1::ST2)'
> 2: Unresolved Property
> 'profile::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2::testLink::base_Association'
>
> 2: Ambiguous resolution:
> Property : uml::Association.memberEnd
> Property : UML::Association.memberEnd
> 2: Unresolved Operation 'Set(OclInvalid)::at(UnlimitedNatural)'
> 4: Unresolved Property
> 'profile::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2::testLink::base_Association'
>
> 4: Ambiguous resolution:
> Property : uml::Association.memberEnd
> Property : UML::Association.memberEnd
> 4: Unresolved Operation 'Set(OclInvalid)::at(UnlimitedNatural)'
> <<testLink>> <Association> class1_class2_1 model EMF Problem
>
>
>
> Thanks
Re: OCL Association Constraint [message #1456893 is a reply to message #1456873] Thu, 30 October 2014 20:48 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
HI,

Thanks. I wil try, but do you know anything about the other problem I am currently facing (constraints within the profile and constraints in .ocl file)
Re: OCL Association Constraint [message #1456916 is a reply to message #1456893] Thu, 30 October 2014 21:22 Go to previous messageGo to next message
azadeh jb is currently offline azadeh jbFriend
Messages: 18
Registered: September 2013
Junior Member
Hi ,

About your second problem ( validating the completeOCL file on the models) I should say I had the same problem and after asking it in the OCL forum they told me to fill a bug report for that. Still no response.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=446007


Regards,
Azadeh
Re: OCL Association Constraint [message #1457613 is a reply to message #1456916] Fri, 31 October 2014 14:10 Go to previous message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Thanks for reply. I will follow the bug progress.
Previous Topic:Re: How to apply a profile to an Activity Diagram
Next Topic:Working with Papyrus Search
Goto Forum:
  


Current Time: Fri Jul 10 14:05:05 GMT 2020

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

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

Back to the top