Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » oclIsTypeOf()
oclIsTypeOf() [message #1770294] Wed, 09 August 2017 17:00 Go to next message
sonny selhorst is currently offline sonny selhorstFriend
Messages: 60
Registered: May 2015
Member
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 18:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6985
Registered: July 2009
Senior Member
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 11:59 Go to previous messageGo to next message
sonny selhorst is currently offline sonny selhorstFriend
Messages: 60
Registered: May 2015
Member
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 12:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6985
Registered: July 2009
Senior Member
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 15:55 Go to previous message
sonny selhorst is currently offline sonny selhorstFriend
Messages: 60
Registered: May 2015
Member
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: Sun Jan 17 20:12:39 GMT 2021

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

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

Back to the top