Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Question to OCL-expression used in EMF Query(OCL, EMF Query)
Question to OCL-expression used in EMF Query [message #642075] Mon, 29 November 2010 18:20 Go to next message
calimeah  is currently offline calimeah Friend
Messages: 1
Registered: November 2010
Junior Member
Hi,

I am currently using BooleanOCLConditions in EMF Query.

Simple OCL-expressions work fine but I am confronted with some rather complicated ones that wont work correctly.

The used ecore-model is a meta-model for UML-class-diagramms.
The model instance xmi-file contains some packages, some classes, operations with parameters... etc.

A simple and working OCL contraint is e.g.:

UMLOperation.allInstances()->select(id='123')->size()=1

This tells me wether the model instance xmi file contains an operation with the id '123'.

Now comes the tricky constraint, which should tell me if an operation with the same name already exists in the model instance and furthermore if thats the case, I want to know if that operation also consists of the same parameter count and the same parameter types in the same order.

My idea of the according OCL-expression was something like this:

UMLOperation.allInstances->select(id='123').class->forAll(c:UMLClass|c.operations- >select(name='theOperationName').parameters <> (UMLOperation.allInstances->select(id='123').parameters))->size()=0

Do you know a better and working way?

Thanx,
Calimeah
Re: Question to OCL-expression used in EMF Query [message #642304 is a reply to message #642075] Tue, 30 November 2010 17:56 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4150
Registered: July 2009
Senior Member
Hi calimeah

Your example has quite a few trivial typos, and the main logic looks
very suspect.

In principle if you write your algorithm in simple English, you can then
transcribe it to OCL.

Your problem is very similar to those that occur for UML itself, so you
might care to look at the UML specification for many relevant OCL
examples (you may need to correct minor typos).

Regards

Ed Willink


On 29/11/2010 18:20, calimeah wrote:
> Hi,
>
> I am currently using BooleanOCLConditions in EMF Query.
>
> Simple OCL-expressions work fine but I am confronted with some rather
> complicated ones that wont work correctly.
>
> The used ecore-model is a meta-model for UML-class-diagramms.
> The model instance xmi-file contains some packages, some classes,
> operations with parameters... etc.
>
> A simple and working OCL contraint is e.g.:
>
> UMLOperation.allInstances()->select(id='123')->size()=1
>
> This tells me wether the model instance xmi file contains an operation
> with the id '123'.
>
> Now comes the tricky constraint, which should tell me if an operation
> with the same name already exists in the model instance and
> furthermore if thats the case, I want to know if that operation also
> consists of the same parameter count and the same parameter types in
> the same order.
>
> My idea of the according OCL-expression was something like this:
>
> UMLOperation.allInstances->select(id='123').class->forAll(c:UMLClass|c.operations-
> >select(name='theOperationName').parameters <>
> (UMLOperation.allInstances->select(id='123').parameters))->size()=0
>
> Do you know a better and working way?
>
> Thanx,
> Calimeah
Previous Topic:Extend OCL editor
Next Topic:Add OCL Console View to perspective
Goto Forum:
  


Current Time: Sun Nov 23 14:42:55 GMT 2014

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

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