Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] How to obtain all the subclasses of a class?  () 1 Vote
[ATL] How to obtain all the subclasses of a class? [message #540925] Thu, 17 June 2010 16:02 Go to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi there,

I'm new in the ATL, someone could say to me, how I can obtain the list of the subclasses of a class, please ?

Thank you so much,

With regards,

[Updated on: Thu, 17 June 2010 16:04]

Report message to a moderator

Re: [ATL] How to obtain all the subclasses of a class? [message #540928 is a reply to message #540925] Thu, 17 June 2010 16:06 Go to previous messageGo to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Bler wrote on Thu, 17 June 2010 12:02
Hi there,

I'm new in the ATL, someone could say to me, how I can obtain the list of the subclasses of a class, please ?

Thank you so much,

With regards,

Re: [ATL] How to obtain all the subclasses of a class? [message #541302 is a reply to message #540928] Sat, 19 June 2010 18:34 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hi bler

I do no know too much about your case
you can create similar helper and call it when needed



helper context UML!Class def: getSUperClass () : Sequence(UML!Class) =

UML!Class.allInstances()->select( p | p.superClass =self);

Re: [ATL] How to obtain all the subclasses of a class? [message #541306 is a reply to message #541302] Sat, 19 June 2010 19:07 Go to previous messageGo to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi wafaa,

Thank you so much for your helps Smile.

In fact, I have a class diagram as entry model, and I have to move a given operation from a super- class to all its sub-classes, and deleting this operation from the super-class. If you have any suggestions about, it'll help me a lot...

Regards,
Re: [ATL] How to obtain all the subclasses of a class? [message #541308 is a reply to message #541306] Sat, 19 June 2010 19:21 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hi Bler

let me explain something

when transforming the parent , transform only its name and the attributes you want

you do not need to delet actually operations will be created if you transformed them too.
like this

rule parentClass {
from uc : UML!Class ( uc.hasChild())
to c : UML!Class (
name <- uc.name,
ownedAttribute <- uc.ownedAttribute )

}


and when transforming children create operation for each like this

rule child{
from uc : UML!CLass
( not uc.hasChild() )

to c: UML!Class (


name <- uc.name ,
ownedAttribute <- uc.ownedAttribute,
ownedOperation <- uc.ownedOperation ,

ownedOperation <- uc.superClass.ownedOperation
}

and let hasChild

helper context UML!Class def: hasChild () : Boolean =
if thisModule.getAllSupers ->exists(self)
then
true
else
false;

helper def : getAllSupers () : Sequence(UML!Class) =
UML!CLass.allInstances() ->select(p | p.superClass) ->asSet();




[Updated on: Sat, 19 June 2010 19:28]

Report message to a moderator

Re: [ATL] How to obtain all the subclasses of a class? [message #541310 is a reply to message #541308] Sat, 19 June 2010 19:48 Go to previous messageGo to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi wafaa,

A lot of thanks four your explications, it's precious for me.., I didn't see it like this, I will do/try it right-now...

With regards Smile
Re: [ATL] How to obtain all the subclasses of a class? [message #541374 is a reply to message #541310] Sun, 20 June 2010 14:55 Go to previous messageGo to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi wafaa,

I had an error with the helper
helper def : getAllSupers() : Sequence(UML!Class) =
UML!Class.allInstances() ->select(p | p.superClass) ->asSet();

Error looks like this : "Operation not found: Sequence {}.not()"

I could not correct it, so I modified the helper "hasChild()" as below, since I have:
- a super-class "A" with 2 properties (pro1 and pro2) and 3 operations (oper1,oper2 and oper3), and
- 3 sub-classes "B" "C" and "D"
The code is :

helper context UML!Class def: hasChild () : Boolean =
if self.name = 'A' then
true
else
false
endif;

rule parentClass {
from uc : UML!Class ( uc.hasChild())
to c : UML!Class (
name <- uc.name,
ownedAttribute <- uc.ownedAttribute
)
}

rule child {
from uc : UML!Class( not uc.hasChild() )
to c: UML!Class (
name <- uc.name,
ownedAttribute <- uc.ownedAttribute,
ownedOperation <- uc.ownedOperation,
ownedOperation <- uc.superClass.first().ownedOperation.at(2)
)
}
I would like to move « oper2 » form A to B, C, and « D », after the transformations I have:
- the super class "A", with 2 properties (pro1 and pro2) and 2 operations (oper1, oper3),it's good, but
- the "oper2" appears only in the sub-class "D"

Could you tell me way please?

Regards,
Re: [ATL] How to obtain all the subclasses of a class? [message #541524 is a reply to message #541374] Mon, 21 June 2010 13:17 Go to previous messageGo to next message
wafaa is currently offline wafaaFriend
Messages: 163
Registered: January 2010
Location: Egypt
Senior Member
hi again:

let me explain some thing, class B and C are created but it seems that some condition or binding did not success, so they are left
while in D the condition is true;

but I understood that in all your cases you used the second operation to be inherited and the rest no!!!

the last question how did the operation 1 and 3 transformed for the parent class and we did not use the binding for operation and why only no 1 and 3 were transformed??!!


hope I did not make you confused Evil or Very Mad

I was just trying>>

you can debug your code to see how does it pass condition and so on.

in debug check classes names, owned attribute and owned Operation

good luck Bler
Re: [ATL] How to obtain all the subclasses of a class? [message #541605 is a reply to message #541524] Mon, 21 June 2010 18:21 Go to previous message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi wafaa,

Thank you so much for your help,

Yes I used only the operation 2 to be inherited, I just started to learn ATL..., I suppose that the operations 1 and 3 were transformed because only the operation 2 has been inherited. Like a kind of swap...I'm not sure, if I use only one sub-class it is ok, but for more than one class, the operation 2 is created only on the last one, so maybe I have to duplicated it (clone or something like that...), for the moment I added a third rule to add the operation for the sub-classes without it... I debug it, it same to be good, anyway I have to check, read/learn...

Thanks again Smile,

Regards
Previous Topic:[ATL] symboles
Next Topic:Graphical Development of ATL
Goto Forum:
  


Current Time: Fri Apr 19 21:55:45 GMT 2024

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

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

Back to the top