Home » Archived » M2M (model-to-model transformation) » [ATL] How to obtain all the subclasses of a class?
( ) 1 Vote
| | | | | |
Re: [ATL] How to obtain all the subclasses of a class? [message #541374 is a reply to message #541310] |
Sun, 20 June 2010 10:55   |
Eclipse User |
|
|
|
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 #541605 is a reply to message #541524] |
Mon, 21 June 2010 14:21  |
Eclipse User |
|
|
|
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 ,
Regards
|
|
|
Goto Forum:
Current Time: Sun Jun 15 02:52:58 EDT 2025
Powered by FUDForum. Page generated in 0.03493 seconds
|