Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem whe using "Support UML2 Stereotypes application" in the run configuration's advanc
Problem whe using "Support UML2 Stereotypes application" in the run configuration's advanc [message #1111498] Wed, 18 September 2013 09:49 Go to next message
Javier García is currently offline 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 #1111565 is a reply to message #1111498] Wed, 18 September 2013 11:51 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 166
Registered: September 2012
Senior Member

Looks like you just discovered what "Support UML2 stereotypes application" does Wink. It postpones all calls to applyStereotype() until after the transformation. This is done to work around the problem that the UML2 metamodel implementation checks that a model element is contained within a UML Model that has the corresponding Profiles applied. This condition only holds after all elements are transformed.

Cheers,
Dennis
Re: Problem whe using "Support UML2 Stereotypes application" in the run configuration's ad [message #1112123 is a reply to message #1111565] Thu, 19 September 2013 06:40 Go to previous messageGo to next message
Javier García is currently offline Javier García
Messages: 129
Registered: April 2013
Senior Member
Thanks Dennis!
I thought that without checking that option the transformation of Stereotypes would just not work or be really problematic, I really understand the use of it now as I have actually had that problem several times, it's really good to finally understand it, thanks a lot!

Also, it would be nice if there was a tooltip or something like that on the option that would let you know exactly what it does.

[Updated on: Thu, 19 September 2013 10:26]

Report message to a moderator

Re: Problem whe using "Support UML2 Stereotypes application" in the run configuration's ad [message #1229042 is a reply to message #1111498] Wed, 08 January 2014 15:40 Go to previous messageGo to next message
Chris Bailey
Messages: 11
Registered: January 2014
Junior Member
I realise this thread is old but my question is relevant to this one.

I am faced with a problem where I do need to check stereotypes at the end of a transformation, but it seems you are not able to do this, and I require the Support UML2 stereotypes application.

Is there a work-around for this, to allow me to check stereotypes at the end of the transformation? As I need to do post-changes at the end of the transformation where stereotypes will indicate the need for certain changes.

Cheers,
Chris
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 Go to previous messageGo to next message
Javier García is currently offline 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

Re: Problem whe using "Support UML2 Stereotypes application" in the run configuration's ad [message #1229471 is a reply to message #1229340] Thu, 09 January 2014 14:09 Go to previous message
Chris Bailey
Messages: 11
Registered: January 2014
Junior Member
Thanks Javier,

Creating/using a Map resolved this problem.

Cheers,
Chris
Previous Topic:Getting elements from a XSD Complex Type - ATL
Next Topic:[ATL] Error loading UML profiles programmatically
Goto Forum:
  


Current Time: Thu Oct 30 15:51:21 GMT 2014

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

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