Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » problem with oclIsKindOf()
problem with oclIsKindOf() [message #1848232] Thu, 25 November 2021 16:31 Go to next message
Ilja Kraval is currently offline Ilja KravalFriend
Messages: 34
Registered: October 2021
Member
Hi all,

while researching the properties of Dependency ends and their types, I came across this discrepancy (see also the picture attached).

I have one InstanceSpecification1 with two Dependency Dep1 and Dep2, one leading to Class Class1 and the other to Activity Activity1.

When I apply oclIsKindOf(Class) on suppliers,
I got "truetrue" - it is not correct, one is Class and the second is Activity.

When I apply the same with Activity as input parameter, I got "falsetrue" correctly.

I think it's a bug, right?
Re: problem with oclIsKindOf() [message #1848240 is a reply to message #1848232] Thu, 25 November 2021 19:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7518
Registered: July 2009
Senior Member
Hi

As in my other answer, I suggest you read https://wiki.eclipse.org/OCL/ForumNetiquette to see how to ask questions that provoke answers rather than mutual irritation.

All I can be sure about is that you are not doing what you are claiming since I cannot believe that a library facility returns "truetrue". Looks like a bug in your 'printing' that you have chosen to keep secret.

Regards

Ed Willink
Re: problem with oclIsKindOf() [message #1848242 is a reply to message #1848240] Thu, 25 November 2021 19:41 Go to previous messageGo to next message
Ilja Kraval is currently offline Ilja KravalFriend
Messages: 34
Registered: October 2021
Member
Hi Ed,

I do not understand.
I wrote these expressions into the editor and this worked out for me, which I copied as a screen.
I hope you don't think I falsified the output.

Regards,
Ilya

[Updated on: Thu, 25 November 2021 22:14]

Report message to a moderator

Re: problem with oclIsKindOf() [message #1848253 is a reply to message #1848242] Fri, 26 November 2021 05:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7518
Registered: July 2009
Senior Member
Hi

No. I certainly don't think that you deliberately falsified the output.

But those with experience of non-trivial software know that it has endless opportunities for mistakes and confusion that easily cause a leap to a false conclusion that can be very time consuming to resolve.

For not-obvious problems it is much easier to resolve them when a repro demonstrates all of the problem rather than the reporter's subjective guess.

"truetrue" is not credible for what you claim to do. Therefore you are not doing what you think you are and so a repro will allow the actual rather than suspected to be investigated.

Regards

Ed Willink
Re: problem with oclIsKindOf() [message #1848264 is a reply to message #1848232] Fri, 26 November 2021 08:06 Go to previous messageGo to next message
Carsten Pitz is currently offline Carsten PitzFriend
Messages: 440
Registered: May 2015
Location: Germany
Senior Member
Hi Ilya,

the answer given by Acceleo is correct in both cases. You have to consider according to the UML specification an Activity is a Behavior which is a Class. Consequently applying oclIsKindOf on Class will also return true for an Activity.

Nevertheless, if I got your intention correctly you might can use a construct like:

[self.getClientDependencies().supplier->asOrderedSet()->reject(e|e.oclIsTypeOf(Class))/]

This gives you the non-conforming suppliers as an OrderedSet.

/Carsten
Re: problem with oclIsKindOf() [message #1848265 is a reply to message #1848264] Fri, 26 November 2021 08:49 Go to previous messageGo to next message
Ilja Kraval is currently offline Ilja KravalFriend
Messages: 34
Registered: October 2021
Member
Hi Carsten,

thanks for the answer.

You are right about constructing terms in UML, but I think the given condition oclIsKindOf () examines a given UML specific for "leaf concrete metaclass".
To check , here is a listing of the XML file (.uml) of the given example, one element has type = Class and the second has type = Activity

<packagedElement xmi:type="uml:Package" xmi:id="_c-REwE4HEeystpVXwKmYWg" name="Package3">
<packagedElement xmi:type="uml:InstanceSpecification" xmi:id="_g79CUE4HEeystpVXwKmYWg" name="InstanceSpecification1"/>
<packagedElement xmi:type="uml:Class" xmi:id="_kUtG0E4HEeystpVXwKmYWg" name="Class1"/>
<packagedElement xmi:type="uml:Activity" xmi:id="_pN1Y8E4HEeystpVXwKmYWg" name="Activity1"/>
<packagedElement xmi:type="uml:Dependency" xmi:id="_wedG4E4HEeystpVXwKmYWg" name="Dep1" client="_c-REwE4HEeystpVXwKmYWg _g79CUE4HEeystpVXwKmYWg" supplier="_kUtG0E4HEeystpVXwKmYWg"/>
<packagedElement xmi:type="uml:Dependency" xmi:id="_40pVwE4HEeystpVXwKmYWg" name="Dep2" client="_g79CUE4HEeystpVXwKmYWg" supplier="_pN1Y8E4HEeystpVXwKmYWg"/>
</packagedElement>

Regards,
Ilya

[Updated on: Fri, 26 November 2021 09:01]

Report message to a moderator

Re: problem with oclIsKindOf() [message #1848266 is a reply to message #1848265] Fri, 26 November 2021 08:56 Go to previous messageGo to next message
Carsten Pitz is currently offline Carsten PitzFriend
Messages: 440
Registered: May 2015
Location: Germany
Senior Member
Hi Ilya,
are you sure?

Object.oclIsKindOf(Object) : Boolean

Evaluates to "true" if the type of the object o1 conforms to the type "classifier". That is, o1 is of type "classifier" or a subtype of "classifier".
Expression Result
anEPackage.oclIsKindOf(ecore::EPackage) true
anEPackage.oclIsKindOf(ecore::ENamedElement) true

Object.oclIsTypeOf(Object) : Boolean

Evaluates to "true" if the object o1 if of the type "classifier" but not a subtype of the "classifier".
Expression Result
anEPackage.oclIsKindOf(ecore::EPackage) true
anEPackage.oclIsKindOf(ecore::ENamedElement) false


index.php/fa/41378/0/

index.php/fa/41379/0/

/Carsten

[Updated on: Fri, 26 November 2021 09:05]

Report message to a moderator

Re: problem with oclIsKindOf() [message #1848267 is a reply to message #1848266] Fri, 26 November 2021 09:19 Go to previous message
Ilja Kraval is currently offline Ilja KravalFriend
Messages: 34
Registered: October 2021
Member
Carsten, thanks a lot!
That's the solution!
BTW: In another thread, I was advised to use oclIsKindOf and not oclIsTypeOf...

Thanks a lot.

Ilya

[Updated on: Fri, 26 November 2021 09:21]

Report message to a moderator

Previous Topic:correct downcast from Element to other UML types
Next Topic:problem with remove method of xpand
Goto Forum:
  


Current Time: Fri Sep 30 23:33:35 GMT 2022

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

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

Back to the top