Home » Modeling » ATL » UM2L to UML2: don't want to transform certain Generalizations and Associations
UM2L to UML2: don't want to transform certain Generalizations and Associations [message #1043195] |
Wed, 17 April 2013 12:05 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi everyone,
I'm doing an UML2 to UML2 transformation and I'm running into a bit of trouble.
I only transform certain stereotyped classes, so then when I transform the generalizatios, associations, and other kind of relationships there are many of them that are just empty when transformed, since the objects they were referencing were not transformed.
How could I filter this?
I tried it this way:
rule generalization {
from
gen: UML2!Generalization (
not gen.oclIsUndefined() and gen.shouldBeCreated()
and not gen.general.oclIsUndefined()
)
to
trg: UML2!Generalization (
general <- gen.general -> debug('Generalization')
)
}
but it doesn't work, I'm guessing since general is actually defined, just defined on the wrong model.
So I was thinking there maybe is some way to check whether the element is still referencing another element from the Input transformation, in which case it wouldn't get transformed.
Thanks in advance, hope someone knows how to solve this,
regards,
Javier
|
|
| |
Re: UM2L to UML2: don't want to transform certain Generalizations and Associations [message #1043869 is a reply to message #1043245] |
Thu, 18 April 2013 08:05 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi Hugo,
the hasStereotype helper doesn't seem to work for me, it said that no such operation existed, so I used this instead:
not gen.refImmediateComposite().getAppliedStereotypes().isEmpty()
and not gen.general.refImmediateComposite().getAppliedStereotypes().isEmpty()
And it doesn't work as intended, if I use only the first line I get to skip a few generalizations, which is nice, but still the ones that exist inside a stereotyped class sometimes point to a class that isn't transformed, so I added that second line and what happens is that no generalizations are created, so I guess I'm probably doing something wrong but I can't seem to thin of a way to fix it.
Now I have a very similar problem but on Associations and Dependencies, I have these rules:
rule Association {
from
ua: UML2!Association (
ua.oclIsTypeOf(UML2!Association) and not ua.oclIsUndefined()
)
to
ma: UML2!Association (
name <- ua.name,
isAbstract <- ua.isAbstract,
generalization <- ua.generalization,
memberEnd <- ua.memberEnd,
ownedEnd <- ua.ownedEnd
)
}
rule Dependency {
from
ud: UML2!Dependency (
not ud.oclIsUndefined()
and ud.oclIsTypeOf(UML2!Dependency)
)
to
mi: UML2!Dependency (
supplier <- ud.supplier,
client <- ud.client,
name <- ud.name
)
}
So the thing is that when transformed, some of the memberEnd, ownedEnd, Supplier or client are not transformed, therefore the association/dependency shouldn't be transformed either, but I don' quite know how to do to filter it. Do you have any ideas? I tried some things but nothing seemed to work.
I'm checking the refining mode and it seems interesting, but it seems like though it might solve some of my problems it might cause some new ones, so I'm not completely sure that it would be a good choice to move my code to refining mode, but I'll do some further tests.
Thanks a lot for your help!
[Updated on: Thu, 18 April 2013 08:26] Report message to a moderator
|
|
| | | |
Re: UM2L to UML2: don't want to transform certain Generalizations and Associations [message #1044690 is a reply to message #1044084] |
Fri, 19 April 2013 08:02 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Ok I didn't know that about the root element.
I also don't know why I called getClass, sometimes I overcomplicate things.
This helper is used for many things, for instance for a Parameter. Now the as I see it the Parameter is contained inside of an Operation, which is itself contained inside of a Class, therefore I thought it would be necessary to use recursivity here, to check if the parameter was inside a stereotyped class. Is there an easier way to check this? As otherwise I was getting some parameters transformed that didn't have an owner (the operation wasn't transformed) so I thought of this way to solve that problem, but any help is welcome.
So I still can't seem to be able to filter these elements (Association, Dependency..), since this helper still doesn't work, I tried some other ideas but nothing seems to work properly.
Thanks a lot for your input, I still need to learn a lot about ATL and I need all the help I can get!
Regards,
Javier
|
|
|
Re: UM2L to UML2: don't want to transform certain Generalizations and Associations [message #1047468 is a reply to message #1043195] |
Tue, 23 April 2013 08:48 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
I finally got it done like this:
rule Association {
from
ua: UML2!Association (
ua.oclIsTypeOf(UML2!Association) and not ua.oclIsUndefined()
)
to
ma: UML2!Association (
name <- ua.name -> debug('Association'),
isAbstract <- ua.isAbstract,
generalization <- ua.generalization,
memberEnd <- ua.memberEnd,
ownedEnd <- ua.ownedEnd,
ownedComment <- ua.ownedComment
)
do{
if (not ma.memberEnd.testSet(2))
then ma.destroy()
else
false
endif;
}
}
I had to use the do block, which I don't really like, but it's the only possible solution I found.
Also in the if clause it forces me to write the else part, is there a way to avoid this? I just wrote "false" and it has no effect but it'd be nicer if I could delete that.
The testSet() method just tests the size of the memberEnd set, so when it's smaller than it should then it gets destroyed.
Let me know if you know of a better way to do this.
|
|
| | | | |
Goto Forum:
Current Time: Fri Apr 26 13:54:24 GMT 2024
Powered by FUDForum. Page generated in 0.04741 seconds
|