Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » need guidance for execution of OCL query(Response for Class)
need guidance for execution of OCL query [message #519916] Wed, 10 March 2010 09:02 Go to next message
No real name is currently offline No real name
Messages: 4
Registered: November 2009
Junior Member
Hi,

I am new to OCL and trying to define a query to find response for a class. The definition on which I am working to solve for response for query is : number of methods plus the methods communication with other classes.

- first I count Operations:
context Classifier
def: countFeatures(): Set(Feature) =
self.allFeatures()
def: countOperation(): Set(Feature) = 
self.countFeatures()->select(f|f.oclIsTypeOf(Operation))

-- I look for overridden methods, because these methods also communicate with the class
def: countOverriddentMethds(): Set(....) = 
.......// please help here

-- and then the behvioral methods ( i mean methods which communicate with the other classes in sequence diagram)

countOperation()->select(oclIsTypeOf(Operation).oclAsType(Message))


inv RFC: countOperation()->size()+countOverriddentMethds()->size()+countBehvioralMethods()->size()


I am using Topcased to execute these queries.

Thanks in advance,
A.J
Re: need guidance for execution of OCL query [message #520286 is a reply to message #519916] Thu, 11 March 2010 14:59 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 3842
Registered: July 2009
Senior Member
Hi AJ

You've given yourself a very difficult first problem.

Firstly, I would use clearer names: countFeatures() really ought to
return an Integer count, rather than just be a wrapper for an existing
method.

Next: an invariant must be a boolean expression.

-----

Overriding is a complex semantic issue that has different definitions in
different languages, you therefore need to understand your semantics
and realise them.

In order to determine an override you need to compare the signature of
operationA against the signature of operationB. You therefore need
helper functions such as

overrides(signatureA : OrderedSet(Type), signatureB : OrderedSet(Type))
: Boolean ...

getSignature(operation : Operation) : OrderedSet(Type) ...

which you can use in iterations/set subtractions.

-----

You may find the MDT/OCL Example OCL Interpreter Console very helpful
for empirical exploring of your logic. As of M6, you can embed your OCL
in Ecore. See http://wiki.eclipse.org/MDT/OCLinEcore

Regards

Ed Willink

On 10/03/2010 14:02, albertlala96@yahoo.com wrote:
> Hi,
>
> I am new to OCL and trying to define a query to find response for a
> class. The definition on which I am working to solve for response for
> query is : number of methods plus the methods communication with other
> classes.
>
>
> - first I count Operations:
> context Classifier
> def: countFeatures(): Set(Feature) =
> self.allFeatures()
> def: countOperation(): Set(Feature) =
> self.countFeatures()->select(f|f.oclIsTypeOf(Operation))
>
> -- I look for overridden methods, because these methods also communicate
> with the class
> def: countOverriddentMethds(): Set(....) = ......// please help here
>
> -- and then the behvioral methods ( i mean methods which communicate
> with the other classes in sequence diagram)
>
> countOperation()->select(oclIsTypeOf(Operation).oclAsType(Message))
>
>
> inv RFC:
> countOperation()->size()+countOverriddentMethds()->size()+countBehvioralMethods()- >size()
>
>
>
> I am using Topcased to execute these queries.
>
> Thanks in advance,
> A.J
Previous Topic:validate the dynamic instances of my ecore metamodel with OCL
Next Topic:OCL Expression error in a constraint
Goto Forum:
  


Current Time: Thu Apr 17 17:45:55 EDT 2014

Powered by FUDForum. Page generated in 0.03339 seconds