Problem whe using "Support UML2 Stereotypes application" in the run configuration's advanc [message #1111498] |
Wed, 18 September 2013 09:49 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi all,
I'm having some problems when using the option mentioned in the title, this problems disappear when I uncheck it but anyways I wondered why does it show the error.
In my program I apply stereotypes which have tagged values, so first I apply the stereotype and then I apply the tagged values. Some of my tagged values are of the type of other stereotypes, so then before applying these tagged values I need to be sure that the stereotype has been applied, so to be sure I was applying the tagged values in an endpoint rule.
The problem is that in order to do this I was pointing to the classes from the output model (which I know is not recommended) and I used a code similar to this (simplified here to ease understanding):
for (src in UML2!Class.allInstancesFrom('OUT')) {
if (not src.getAppliedStereotype('RCP::View').oclIsUndefined()){
src.setValue(src.getAppliedStereotypes().first(), 'viewActions',
thisModule.elementSet);
}
}
So with the "Support UML2 stereotypes application" option checked this didn't work, as the transformation didn't detect any stereotyped class I checked it further and there were no stereotyped classes until the transformation was actually finished, meaning that once the transformation was finished the classes had stereotypes, but during the transformation not even in the endpoint rule the classes where stereotyped.
Then if I do this same transformation with that option unchecked it can properly see all the stereotyped classes from the output model and therefore it's able to set the values of the stereotype's properties without any problem.
So my question is: why does this happen? and is it intended to work this way?
Because I don't understand why this option changes this so much, and wondered if maybe it was a bug or if maybe as mentioned before I shouldn't be checking the output model like this.
Thanks in advance,
regards,
Javier
|
|
|
|
|
|
Re: Problem whe using "Support UML2 Stereotypes application" in the run configuration's ad [message #1229340 is a reply to message #1229042] |
Thu, 09 January 2014 08:37 |
Javier García Messages: 129 Registered: April 2013 |
Senior Member |
|
|
Hi Chris,
I don't know how your code is done, but there are some things you could try. First, you could try using a map: helper def : componentsMap : Map(UML2!Stereotype,OclAny) = Map{}; , so then on each of your rules you can add the element to the map using the stereotype, and then at the end of the transformation you can check the map and do the changes you need, I've done this in a transformation and it works fine.
Another option, maybe even easier, would be to use another transformation after the one you're using, I know this is not ideal but it would work too.
Edit to show a small example on how I use the map:
rule createPerspectiveClass {
from s : UML2!"uml::Class"
to
t: UML2!Class (
name <- s.name
)
do {
thisModule.componentsMap<-thisModule.componentsMap.including(thisModule.perspectiveStereotype, t);
}
}
--- In this endpoint rule we apply the stereotypes and their values
endpoint rule ApplyAllStereotypes() {
do {
--- Apply Stereotypes:
for (key in thisModule.componentsMap.getKeys()){
for (elem in Sequence{thisModule.componentsMap.get(key)}.flatten()){
if (not elem.oclIsUndefined()){
elem.applyStereotype(key);
}
}
}
}
}
}
So I hope this shows how easy is it to use the map to check which elements have which stereotypes, I hope this was useful to you.
[Updated on: Thu, 09 January 2014 09:10] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01604 seconds