|OCL in UML Profile [message #1747164]
||Thu, 10 November 2016 11:40
| Vetle Volden-Freberg
Registered: February 2016
Hello! I am working on a project where I need to define a relatively simple Constraint on a <<Stereotype>> of the <<Metaclass>> Message using OCL. I want to check if the Lifeline on the receiving end of the message is of a certain stereotype.|
I am a newbie with OCL and I've been going through a steep learning curve lately.
So let's say you have a profile "MyProfile" that defines a stereotype: <<MyMessage>> that extends <<Metaclass>> Message and a stereotype: <<MyLifeline>> that extends <<Metaclass>> Lifeline.
How could you write an OCL invariant in an OpaqueExpression that ensures that the lifeline on the receiveEvent of the <<myMessage>> stereotype is of type <<MyLifeline>>?
So far I have experimented with some OpaqueExpressions that sadly do not work as I intended. There is most likely something I've misunderstood when it comes to using OCL.
A result of my experiments is the OpaqueExpression:
It is syntactically correct according to the OCL editor, but when I try it out it always yields the result that the invariant has been violated. I also tried to replace the MyProfile::MyLifeline with extension_MyLifeline but that is not accepted by the parser.
I tried to study the constraint used in the UML 2.5.0 Metamodel EPackage that checks if the ordering of the sendEvent & receiveEvent is correct for Messages that has receiveEvent & sendEvent pointing to the same Lifeline.
That (OCL) constraint looks like this:
let f : Lifeline = sendEvent->select(oclIsKindOf(MessageOccurrenceSpecification)).oclAsType(MessageOccurrenceSpecification)->asOrderedSet()->first().covered in
f = receiveEvent->select(oclIsKindOf(MessageOccurrenceSpecification)).oclAsType(MessageOccurrenceSpecification)->asOrderedSet()->first().covered implies
f.events->indexOf(sendEvent.oclAsType(MessageOccurrenceSpecification)->asOrderedSet()->first() ) <
I tried to see if there was anything in that constraint I could use to my advantage in my case, but nothing has worked so far..
Any ideas on how I can solve this issue?
(I am using Papyrus Neon to make the UML profile)
Cheers, Vetle VF.
[Updated on: Fri, 11 November 2016 13:05]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.03572 seconds