Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Define OCL constrain for a modelElements association relationship
Define OCL constrain for a modelElements association relationship [message #832155] Thu, 29 March 2012 21:07 Go to next message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi,
I have an EMF meta-model diagram, for a GMF editor.

In the attached meta-model diagram, I have a Workspace object that can contain modelElements. The ModelElement class is an abstract class, and just below it, it is inherited by a Project, DesignRepository and KnowledgeRepository.

How can I define the OCL constrain for the modelElements -> 0..* relationship?

index.php/fa/7678/0/

The OCL constrain annotation could look like this, but I'm not sure how to properly write the derive value

Key = derive
Value = let modelElements : Set(pcbdesignrules::ModelElement) = self.objects->select(oclIsKindOf(pcbdesignrules::ModelElement))->collect(oclAsType(pcbdesignrules::ModelElement))->asSet() in modelElements->symmetricDifference(modelElements.modelElements->asSet())

I think the last few statements are wrong in the above value declaration, i.e. in modelElements->symmetricDifference(modelElements.modelElements->asSet())

Elvis Dowson

Re: Define OCL constrain for a modelElements association relationship [message #833984 is a reply to message #832155] Sun, 01 April 2012 08:02 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

did you try to create your statement usign Eclipse's OCL console (http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.ocl.doc/references/examples/oclInterpreterExample.html). This can be very helpful when working with complexe expressions. You should execute the OCL constraint part by part like this:

1) let modelElements : Set(pcbdesignrules::ModelElement) = self.objects
*) See if you get the expected result
2) let modelElements : Set(pcbdesignrules::ModelElement) = self.objects->select(oclIsKindOf(pcbdesignrules::ModelElement))
*) See if you get the expected result
3) and so on

I think this approach should help you much more further then getting a vague guess on your error.

Do you use OCLinEcore (http://wiki.eclipse.org/MDT/OCLinEcore) to specify the derive?

Ralph
Previous Topic:Location of ConnectionAnchor within a line segment
Next Topic:Rectangle background image
Goto Forum:
  


Current Time: Tue Apr 23 10:50:49 GMT 2024

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

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

Back to the top