Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Association Constraint(Validation throws error on association constraints)
icon8.gif  OCL Association Constraint [message #1455620] Wed, 29 October 2014 15:16 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



Please let me know if I am making any mistakes or any other useful information.

Thanks,
Re: OCL Association Constraint [message #1455772 is a reply to message #1455620] Wed, 29 October 2014 18:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It was only in Luna that Papyrus 1.0.0 and OCL 5.0.1 integration started
to work effectively.

The particular problem you are seeing is one fixed in Luna UML where an
extra EAnnotation was made available to identify the original "UML"
spelling for the "uml" package enabling the ambiguity to be resolved.

(The UML loader 'corrects' OMG spellings to comply with Ecore's Java
expectations.)

Regards

Ed Willink


On 29/10/2014 19:19, Rishi Kanth wrote:
> 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
>
>
>
> Please let me know if I am making any mistakes or any other useful
> information.
>
> Thanks,
Re: OCL Association Constraint [message #1455808 is a reply to message #1455772] Wed, 29 October 2014 19:39 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi Ed,

Thanks for the help.
Question. Does the indexing for
memberEnd
start with 0 or 1 in OCL.
Yes, the suggestion helped, but not completely. Now when I try to validate the model i get the following warning

Severity	Description	Element	Parent	Type
Warning	The 'testLink::Constraint1' constraint is violated for '«testLink»model::testAssoc'	<<testLink>> <Association> testAssoc	model	EMF Problem
Re: OCL Association Constraint [message #1456251 is a reply to message #1455808] Thu, 30 October 2014 06:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

OCL is a specification language so indexes start from 1.

In Luna you can use the OCL debugger.

Ed


On 29/10/2014 20:39, Rishi Kanth wrote:
> Hi Ed,
>
> Thanks for the help. Question. Does the indexing for memberEnd start
> with 0 or 1 in OCL. Yes, the suggestion helped, but not completely. Now
> when I try to validate the model i get the following warning
>
>
> Severity Description Element Parent Type
> Warning The 'testLink::Constraint1' constraint is violated for
> '«testLink»model::testAssoc' <<testLink>> <Association> testAssoc
> model EMF Problem
>
Re: OCL Association Constraint [message #1456861 is a reply to message #1455808] Thu, 30 October 2014 20:13 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Thank you very much. I was able validate my model with the designed profile. 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).

By the way, I have changed the OCL constraint to the following.

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


Thanks.
Re: OCL Association Constraint [message #1457381 is a reply to message #1456861] Fri, 31 October 2014 09:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

A Complete OCL document complements another (meta)model, which know
nothing about the complement so by default will not use it.

You need at least to do OCL->Load Document to load the Complete OCL
document. You may also need to use OCL->Validate.

Regards

Ed Willink


On 30/10/2014 20:13, Rishi Kanth wrote:
> Thank you very much. I was able validate my model with the designed
> profile. 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).
>
> By the way, I have changed the OCL constraint to the following.
>
>
> self.base_Association.endType.getAppliedStereotypes()->asSequence().name->includesAll(Set{'ST1','ST2'})
>
>
>
> Thanks.
Re: OCL Association Constraint [message #1457666 is a reply to message #1457381] Fri, 31 October 2014 15:21 Go to previous messageGo to next message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Thanks for the reply. But, I am swimming in waters I am not familiar with. When i do that, I get the following exceptions
Problems encountered during validation. Missing 'invocationDelegates' delegate for 'TestOCL::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2'
(about 10 of them).
Re: OCL Association Constraint [message #1457688 is a reply to message #1457666] Fri, 31 October 2014 15:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Try following the Complete OCL tutorial.

Regards

Ed Willink


On 31/10/2014 15:21, Rishi Kanth wrote:
> Thanks for the reply. But, I am swimming in waters I am not familiar
> with. When i do that, I get the following exceptions Problems
> encountered during validation. Missing 'invocationDelegates' delegate
> for 'TestOCL::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2'
> (about 10 of them).
Re: OCL Association Constraint [message #1472195 is a reply to message #1457688] Thu, 13 November 2014 17:30 Go to previous message
Rishi Kanth is currently offline Rishi KanthFriend
Messages: 18
Registered: October 2014
Junior Member
Hi ,

I tried the Complete OCL Tutorial (http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FCompleteOCLTutorial.html), but face the same error.
Problems encountered during validation. Missing 'invocationDelegates' delegate for 'TestOCL::Test2::http://www.eclipse.org/uml2/2.0.0/UML::Test2'


One other thing I have also observed is, the tutorial says when I validate the OCL with the Papyrus model, I should see a warning (as shown in the figure), but I dont see anything. The validation is successful without any warnings or errors. Do I have to set anything specific in my eclipse environment or change OCL preferences.
Previous Topic:OCL Inheritance
Next Topic:Differences evaluating an OCL expression using Interactive OCL Console and xText Interactive Console
Goto Forum:
  


Current Time: Tue Mar 19 06:22:49 GMT 2024

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

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

Back to the top