Skip to main content



      Home
Home » Eclipse Projects » Sirius » oclIsTypeOf()
oclIsTypeOf() [message #1770294] Wed, 09 August 2017 13:00 Go to next message
Eclipse UserFriend
Dear,

In my metamodel I have defined that the meta-class attribute has an "attributeType" datatype as you can see in the following image:
index.php/fa/30338/0/

Now, those attributes are contained in an Entity container. When the Entity container is the target class and I use the following statement: aql:self.attribute.attributeType.oclIsTypeOf(uMLEER::AttributeType::primaryKey), it always returns false, regardless of the attributeType...

I am definitely doing something wrong, although I can't seem to find what it is.

Kind regards,

Sonny
Re: oclIsTypeOf() [message #1770298 is a reply to message #1770294] Wed, 09 August 2017 14:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi

It is usually better to use oclIsKindOf rather than oclIsTypeOf.

oclIsKindOf tests for type conformance. primaryKey is an enumeration literal.

Regards

Ed Willink
Re: oclIsTypeOf() [message #1770359 is a reply to message #1770298] Thu, 10 August 2017 07:59 Go to previous messageGo to next message
Eclipse UserFriend
Hey Ed,

Thank you for your reply. I have tried both actually, and none worked. As you said, this might be due to the fact that primaryKey is an enumeration literal.

For my other tools I just used the statement aql:self.attribute.attributeType=uMLEER::AttributeType::primaryKey, which works fine.

But now, the self is an entity, which can contain multiple attributes, but can only contain one attribute with the type primaryKey. So I made a validation rule that should count how many attributes there are with the datatype primaryKey. If there is more than one, there is an error.

So what I need to know is how i can count how many instances of attribute have the type primaryKey for the self.

Thank you very much for your help in advance.

Kind regards,
Sonny Selhorst
Re: oclIsTypeOf() [message #1770370 is a reply to message #1770359] Thu, 10 August 2017 08:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The assignment works fine because it is type consistent; enum literal to enum literal.

The type test fails because you are not testing for a type.

Perhaps you want something like ...->selectByKind(uMLEER::Attribute)->select(attributeType = uMLEER::AttributeType::primaryKey)->size()

selectByKind() is a moderately recent OCL addition. Perhaps it is filter() in AQL.

Regards

Ed Willink
Re: oclIsTypeOf() [message #1770387 is a reply to message #1770370] Thu, 10 August 2017 11:55 Go to previous message
Eclipse UserFriend
Thank you very much for your answers Ed, your reasoning has helped me identify the problem, I have solved it with the following statement:

aql:self.attribute.attributeType->count(uMLEER::AttributeType::primaryKey)<2

Have a great day!
Previous Topic:Ordering tools and imported tools in palette
Next Topic:URGENT: Display tool in tool palette
Goto Forum:
  


Current Time: Wed Jul 23 16:01:15 EDT 2025

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

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

Back to the top