Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL Query format
OCL Query format [message #494775] Mon, 02 November 2009 15:42 Go to next message
pkojo is currently offline pkojoFriend
Messages: 27
Registered: October 2009
Junior Member
Hi,

This is a query which gives number of classes in a model:
getModel().allOwnedElements()->select(oclIsTypeOf(Class))->size()

Now I want to write this query in another format
context uml::Model::findClass()
body{
allOwnedElements()->select(oclIsTypeOf(Class))->size()
}

is this a right way to write above query, or any one has any other solution for this.

Thanks in advance,

pkojo
Re: OCL Query format [message #494897 is a reply to message #494775] Tue, 03 November 2009 06:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi pkojo

What you are trying to do looks to be quite conventional, so it is
unclear why you need help.

If you have not tried your example, you should try it before asking for
help.

If you have tried your example, you should clearly explain what problems
you are having.

Since the syntax of body is "body optionalName : oclExpression" rather
than "body optionalName { oclExpression }" it seems clear that you have
not tried your example. The { following body should give you an obvious
syntax error to discuss.

Regards

Ed Willink

pkojo wrote:
> Hi,
>
> This is a query which gives number of classes in a model:
> getModel().allOwnedElements()->select(oclIsTypeOf(Class))->size()
>
> Now I want to write this query in another format context
> uml::Model::findClass()
> body{
> allOwnedElements()->select(oclIsTypeOf(Class))->size()
> }
>
> is this a right way to write above query, or any one has any other
> solution for this.
>
> Thanks in advance,
>
> pkojo
>
Re: OCL Query format [message #494943 is a reply to message #494897] Tue, 03 November 2009 10:51 Go to previous message
pkojo is currently offline pkojoFriend
Messages: 27
Registered: October 2009
Junior Member
Hi Ed,

I tried query on OCL Interpreter Console, to count classes using
getModel().allOwnedElements()->select(oclIsTypeOf(Class))->size()
This works fine, when I use this query with context key word it gives me errors. I am very new to OCL and trying to understand how it works, I havent found any documentation which gives me hint where I use OCL query with context key word and where not.
In OCL documentation all queries are defined with context key word, if I tried same on OCL interpreter it does not work and it complains about the context key word.

Therefore I tried to compare my above query in context format like this:

context uml::Model::findClass()
body{
allOwnedElements()->select(oclIsTypeOf(Class))->size()
}

It will definitely complain about context keyword on OCL console.
Please little bit explain or refer me any material which explains where we can use context and where we cant.

I am sorry, I am beginner and my question is very basic, I hope you do not mind.

regards,
pokojo


Previous Topic:OCL Interpreter
Next Topic:OCL Console with history
Goto Forum:
  


Current Time: Thu Apr 18 11:09:43 GMT 2024

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

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

Back to the top