Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Applying OCL on UML profiles
Applying OCL on UML profiles [message #1754975] Fri, 24 February 2017 18:41 Go to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 119
Registered: September 2012
Location: York, UK
Senior Member
Hello there,

I am creating an UML profile at the moment, I use Stereotypes that extend Association to describe relationships between entities. I have provided a minimal example. In this example, I create Stereotypes Flowchart and Node that extend Class. I then created a Stereotype that extends Association named 'nodes' to describe the relationship between Flowchart and Node.

I then applied 3 OCL constraints on Stereotype 'nodes':

1. CheckEndTypes which checks that the end types are of type Flowchart and Node.
2. CheckAggregation which checks that it should be composition from Flowchart to Node.
3. CheckMultiplicity which checks that the multiplicity from Flowchart to Node should be 0..*

These constraints used to work on the example model that I provided this morning. But now the constraints 2 and 3 are violated. I have looked into the cause and it appears that the association memberEnds are of type Class (let's assume they are A and B, and A represents Stereotype Flowchart and B represents Stereotype Node), I found out that the memberEnd A (of type UML::Property) can refer to its class (by calling A.class). However, memberEnd B cannot refer to its class, when i tried B.class it returns null.

Could you please advise what could possibly go wrong?

Cheers,
Will
  • Attachment: example.zip
    (Size: 10.01KB, Downloaded 86 times)


Research Associate
Department of Computer Science
University of York

[Updated on: Fri, 24 February 2017 19:25]

Report message to a moderator

Re: Applying OCL on UML profiles [message #1754977 is a reply to message #1754975] Fri, 24 February 2017 19:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I suspect that your logic is wrong. When I use the Xtext OCL console to practice evaluating

let memberEnds = self.memberEnd in
let flowChartEnd = memberEnds->select(p|p.class.extension_Flowchart->notEmpty()),
nodeEnd = memberEnds->select(p|p.class.extension_Node->notEmpty())in
if flowChartEnd->notEmpty() and nodeEnd->notEmpty() then
flowChartEnd->first().aggregation = UML::AggregationKind::composite and
nodeEnd->first().aggregation = UML::AggregationKind::none
else
false
endif

flowChartEnd is not empty but nodeEnd is empty


Evaluating:
let memberEnds = self.memberEnd in
let flowChartEnd = memberEnds->select(p|p.class.extension_Flowchart->notEmpty()),
nodeEnd = memberEnds->select(p|p.class.extension_Node->notEmpty())in
flowChartEnd
Results:
RootElement::Class1::class2

Evaluating:
let memberEnds = self.memberEnd in
let flowChartEnd = memberEnds->select(p|p.class.extension_Flowchart->notEmpty()),
nodeEnd = memberEnds->select(p|p.class.extension_Node->notEmpty())in
nodeEnd
Results:

so of course the result is false and validation fails.

Regards

Ed Willink
Re: Applying OCL on UML profiles [message #1754979 is a reply to message #1754977] Fri, 24 February 2017 19:49 Go to previous messageGo to next message
Ran Wei is currently offline Ran WeiFriend
Messages: 119
Registered: September 2012
Location: York, UK
Senior Member
Hi Ed,

Thanks for your response. Could you please tell me why nodeEnd is empty? Is it supposed to be empty?

Cheers,
Will


Research Associate
Department of Computer Science
University of York
Re: Applying OCL on UML profiles [message #1754991 is a reply to message #1754979] Sat, 25 February 2017 06:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You need to study the UML Association/Class/Property more carefully. They are from from obvious.

You have a unidirectional association and so the unnavigable end is a property owned by the association that is not a class.

Regards

Ed Willink
Re: Applying OCL on UML profiles [message #1754993 is a reply to message #1754991] Sat, 25 February 2017 09:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I thought that memberEnds->select(p|p.classifier.... might work, but hit Bug 512726 now fixed on GIT master. It gives you two containers but not two types.

The problem is that in UML, a Property does not know its type, just its referred type, so the trick is to use the referred type of each memberEnd to find the 'containing' types of the opposites and accommodate the wronf ended-ness.

let memberEnds = self.memberEnd in
let nodeEnd = memberEnds->select(type.oclIsKindOf(UML::Class) and type.oclAsType(UML::Class).extension_Flowchart->notEmpty()),
flowChartEnd = memberEnds->select(type.oclIsKindOf(UML::Class) and type.oclAsType(UML::Class).extension_Node->notEmpty())in
if flowChartEnd->notEmpty() and nodeEnd->notEmpty() then
flowChartEnd->first().aggregation = UML::AggregationKind::composite and
nodeEnd->first().aggregation = UML::AggregationKind::none
else
false
endif

Since the constraint is an AND, your users may find it more helpful to use two constraints, one for each end, so that they get a more precise failure diagnostic.

Regards

Ed Willink
Re: Applying OCL on UML profiles [message #1754995 is a reply to message #1754993] Sat, 25 February 2017 10:34 Go to previous message
Ran Wei is currently offline Ran WeiFriend
Messages: 119
Registered: September 2012
Location: York, UK
Senior Member
Hi Ed,

Thanks very much for your response. The new constraint is now working properly and I have rectified CheckMultiplicity with the same measure. Thanks again.

Cheers,
Will


Research Associate
Department of Computer Science
University of York
Previous Topic:Extending Associations in UML Profile
Next Topic:Reduce default value selection list
Goto Forum:
  


Current Time: Thu Apr 18 14:27:47 GMT 2024

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

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

Back to the top