Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to count associative classes in a UML model
How to count associative classes in a UML model [message #518203] Wed, 03 March 2010 08:36 Go to next message
pkojo is currently offline pkojo
Messages: 27
Registered: October 2009
Junior Member
Hi,

I want to check whether model contains associative classes or not.

context Model
inv: allOwnedElements()->select(oclIsTypeOf(Class)->exists(c|c.ownedType = oclIsTypeOf(Association)))

please let me know, where I am making mistake.
Re: How to count associative classes in a UML model [message #518375 is a reply to message #518203] Wed, 03 March 2010 17:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
On 03/03/2010 13:36, Gilbert wrote:
> Hi,
>
> I want to check whether model contains associative classes or not.
> context Model
> inv: allOwnedElements()->select(oclIsTypeOf(Class)->exists(c|c.ownedType
> = oclIsTypeOf(Association)))
>
> please let me know, where I am making mistake.
>
It is far from clear what you are asking.

Your title is "count", but your description and code are "check". May be
this is your mistake.

Or does the invariant malfunction in some way that you have not explained?

Regards

Ed Willink
Re: How to count associative classes in a UML model [message #518510 is a reply to message #518375] Thu, 04 March 2010 05:42 Go to previous messageGo to next message
pkojo is currently offline pkojo
Messages: 27
Registered: October 2009
Junior Member
sorry I want to count, want to know is this a correct way to count associative class.

context Model
inv: allOwnedElements()->select(oclIsTypeOf(Class)->exists(c|c.ownedType = oclIsTypeOf(Association))) ->size()

regards,
gil
Re: How to count associative classes in a UML model [message #518653 is a reply to message #518510] Thu, 04 March 2010 12:00 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi Gil

It's still not clear what you want or what is failing.

However:

An invariant is a statement/expression that is always true of its
context, it is therefore a boolean.

....->size()

is not boolean

....->isEmpty()

or

....->size() = 0

is.

Try expressing your intent in semi-formal English.

"It is invariably true that the model does not contain any classes that
are association classes."

Then you may understand the problem you are trying to solve and may then
be able to transliterate it into OCL.

Regards

Ed Willink

On 04/03/2010 10:42, Gilbert wrote:
> sorry I want to count, want to know is this a correct way to count
> associative class.
>
> context Model
> inv: allOwnedElements()->select(oclIsTypeOf(Class)->exists(c|c.ownedType
> = oclIsTypeOf(Association))) ->size()
>
> regards,
> gil
Previous Topic:Single OCL constraint for multiple properties
Next Topic:validate the dynamic instances of my ecore metamodel with OCL
Goto Forum:
  


Current Time: Fri Aug 01 04:05:01 EDT 2014

Powered by FUDForum. Page generated in 0.04992 seconds