Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Output model tagged values from the stereotype point to the input model
icon4.gif  Output model tagged values from the stereotype point to the input model [message #1104995] Mon, 09 September 2013 07:49 Go to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi all,
so I have a transformation chain where in the first transformation I add a profile and stereotypes to the input model, also adding values to the attributes of the stereotypes I apply.
Then I keep working with that generated model and I use the following code to keep the attributes of the stereotypes:
for (property in s.getAppliedStereotypes().first().getAllAttributes())
		{
		if(s.hasValue(s.getAppliedStereotypes().first(), property.name) and (not property.name.
				startsWith('base_')) and not property.isReadOnly())
		{
		t.setValue(s.getAppliedStereotypes().first(), property.name, s.getValue(s.
				getAppliedStereotypes().first(), property.name));
		}	
		}

It works and I can keep copying them over the transformation chain without a single problem.

The thing is though that when I checked the model with an xml editor I saw this:

<RCP:ViewAction xmi:id="__Z7FTRkiEeOe3dUGDsIL1Q" base_Class="__Z7E8hkiEeOe3dUGDsIL1Q">
    <actions href="PIM-Second.uml#_JAmy8hkgEeOe3dUGDsIL1Q"/>
  </RCP:ViewAction>
  <RCP:Perspective xmi:id="__Z7FThkiEeOe3dUGDsIL1Q" name="Message Composition" icon="icons/letter.gif" base_Class="__Z7E2RkiEeOe3dUGDsIL1Q">
    <views href="PIM-Second.uml#_JAmy7BkgEeOe3dUGDsIL1Q"/>
    <views href="PIM-Second.uml#_JAmy7RkgEeOe3dUGDsIL1Q"/>
    <views href="PIM-Second.uml#_JAmy7hkgEeOe3dUGDsIL1Q"/>
  </RCP:Perspective>

That happens with all the other models that use the above code, they get this reference to the first model. This is a problem when I want to move my final model to some other project, because then I need to move along the PIM-Second.uml model so I was wondering why does it work like this and if you know how could I fix it.
So far I tried mantaining the XMI ID of the classes I copy but that didn't work so I guess the problem must be in the code I copied here where I use set/getValue, but I'm not sure if there's any other way I could do this.

Thanks in advance,
regards,
Javier

[Updated on: Mon, 09 September 2013 07:50]

Report message to a moderator

Re: Output model tagged values from the stereotype point to the input model [message #1105023 is a reply to message #1104995] Mon, 09 September 2013 08:34 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
Registered: July 2009
Senior Member
Hello,

In order to avoid this, you should not copy as is the values of the stereotype attributes using imperative code.
If your input model is a stereotyped UML model and your output model too, then you should try to perform the "copy" of the elements via regular matched rules:
rule A2B {
   from
      a : UML!Class
   to   
      b : UML!Class(
         -- apply stereotype S here
      ),
      s : UML!Stereotype (
         -- initialize the value of the attributes by refering to the input model
         -- if you point to an input model element, ATL should resolve it to the corresponding output model element 
      )
}

Best regards,


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Output model tagged values from the stereotype point to the input model [message #1105707 is a reply to message #1105023] Tue, 10 September 2013 07:29 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Ok that makes sense, but I have an external profile an stereotypes that I really want to keep, so if I understand this correctly I would be creating a new Stereotype and that is not really what I want as I need to keep using the same profile for the whole transformation chain, so how do I do this then? or am I wrong and if I name it the same the Stereotype would be the same?

Thanks Hugo!
Re: Output model tagged values from the stereotype point to the input model [message #1105951 is a reply to message #1105707] Tue, 10 September 2013 13:37 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
Registered: July 2009
Senior Member
The profile and stereotype definitions are usually stored as a separate UML model (i.e., it conforms to the UML metamodel) that you have to pass as input of your transformations.
Actually, what you have to "copy" are the stereotype applications to the different elements (and not the profile nor the stereotypes themselves).

Probably I was not using the right term (cf. the stereotype part of the UML metamodel) in my previous example. Sorry for the confusion.

Best regards,


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Output model tagged values from the stereotype point to the input model [message #1106532 is a reply to message #1105951] Wed, 11 September 2013 08:17 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Hugo, thanks for your answer.
I have as input the main model and the profile as you just said, so I would need to "transform" the stereotype applications but I don't know how to do this because when you use "getStereotypeApplications()" what you get is an object of the type EObject so it's not like I can do a rule to transform all EObjects.
The only choice I thought of is again on the do section do the same thing I did in the previous transformation to get the StereotypeApplications of all the elements that I'd need but this would increase my transformations' execution time and size a lot and I'd have to import the same models I used in the first transformation so this solution would be really annoying for me.

I was thinking of maybe somehow getting the tagged values and searching for the element they are referencing in the output model(using an endpoint rule), but I don't really like this solution either and I'm not sure about how to implement it since for some reason even at my endpoint rule the classes from my output model have no stereotype applied (they do have it in the finished output model).

So as you can see I'm a bit lost here and any help is welcome, thanks Hugo for your help Smile
Re: Output model tagged values from the stereotype point to the input model [message #1106639 is a reply to message #1106532] Wed, 11 September 2013 10:59 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
Registered: July 2009
Senior Member
Hello,

Well, in EMF all elements are (sub-types of) EObjects.
I've checked again with other profiled UML models and what I have seen is the following: when you have a stereotype XXX declared in a profile, the applications of this stereotype to concrete UML model elements are elements of type XXX (having as attributes the declared tagged values).
Thus you should be able to handle a stereotype application as any model element.

Best regards,


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Output model tagged values from the stereotype point to the input model [message #1107334 is a reply to message #1106639] Thu, 12 September 2013 08:59 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Hugo, thanks for your answer but I can't seem to solve this.
I thought that I should be able to make a rule that copied elements of the kind UML2!StereotypeApplication but no such type exists, another choice would be to make a rule that copied EObjects, which I tried but it didn't solve my problem.

So after reading you I don't understand exactly what kind of element should I be transforming, you say that these elements are of the type of the stereotype name so this got me thinking and I did a test:
s.getAppliedStereotypes().first()->debug('Stereotype');
s.getStereotypeApplications().first()->debug('StereotypeApps.first()'); ---TEST

And here you can see a small part of the result:
Stereotype: Profile!Action
StereotypeApps.first(): IN!<unnamed>
Stereotype: Profile!BusinessObject
StereotypeApps.first(): IN!<unnamed>
Stereotype: Profile!View
StereotypeApps.first(): IN!Map Elements

Those are just a few examples, as you can see most elements show as IN!<unnamed> and some others are shown as IN!name (I found out that that name shows only when the stereotype has an attribute called 'name' so it has sometimes that blank space!).

So I just don't understand how should I copy them, I mean what rule should I use, for instance should I do something like:
rule StereotypeApplication{
	from
		s: UML2!StereotypeApplication
	to
		t:UML2!StereotypeApplication(
		ownedAttributes<-s.ownedAttributes
		)
}

And if so, how could I do it?

I'm sorry if this is getting too long but I am having problems understanding this issue, so thank you for your patience Hugo.

Regards,
Javier
Re: Output model tagged values from the stereotype point to the input model [message #1107561 is a reply to message #1107334] Thu, 12 September 2013 15:42 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
Registered: July 2009
Senior Member
Hello,

No problem Smile
To illustrate what I was saying, I've taken the screenshot below:

http://docatlanmod.emn.fr/Temp/UMLProfiledModel.png

The ServicePerformance elements are actually applications of the ServicePerformance stereotype that is defined in a given profile.
Have you tried to handle your stereotype applications as regular model elements following this pattern?

I hope this helps.


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Output model tagged values from the stereotype point to the input model [message #1108007 is a reply to message #1107561] Fri, 13 September 2013 07:44 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Hugo,
so should I just try to do something like a rule for UML2!Perspective in my case? because this is what I just tried:
rule Perspective{
	from
		s: UML2!Perspective in IN
	to
		t: UML2!Perspective (
			name <-s.name,
			views <- s.views
		)
}

But of course I get an error saying that the element Perspective doesn't exist in the UML2 metamodel, so how do I do it then?
To make things clearer here is the header of my transformation:
-- @nsURI UML2=http://www.eclipse.org/uml2/3.0.0/UML
-- @nsURI pdm=http://www.eclipse.org/uml2/3.0.0/UML
-- @nsURI profile=http://www.eclipse.org/uml2/3.0.0/UML


module RcpPIMPDM2PSM;
create OUT: UML2 from IN: UML2, PDM: UML2, Profile: profile;

So I tried using everything I could think of: UML2!Perspective, IN!Perspective, PDM!Perspective, Profile!Perspective, profile!Perspective and none of them works but when I look at my model I can see the elements the same way you do in that image you posted so I'm still lost about how to reference them in the transformation.
Let me know if there's something else you need to see about my transformation and hopefully we can come up with a solution.

Thanks a lot for your help,
regards,
Javier
Re: Output model tagged values from the stereotype point to the input model [message #1108135 is a reply to message #1108007] Fri, 13 September 2013 11:41 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 612
Registered: July 2009
Senior Member
Hello,

The way the UML2 API is implemented is quite specific and ATL is based on standard EMF, that's probably why you're getting such problems.
I've been doing a quick search over the forum and I found this post (and previous discussion) that could hopefully help you.

Best regards,


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Output model tagged values from the stereotype point to the input model [message #1109971 is a reply to message #1108135] Mon, 16 September 2013 07:35 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Thanks Hugo, I've been checking that thread and that last post in particular, but it doesn't seem to solve my problem.
The one thing that seems different from my code is that he uses a lazy rule to set the stereotype, but when I tried to use it I got an exception (the exception was only when I used the 'using{...}' part of his code) and besides that code seems mostly like the one I use too so I'm not sure that it would change much.
I will keep trying to find a workaround and I'll let you know if I find something.
Thanks a lot for your help!

Regards,
Javier

[Updated on: Mon, 16 September 2013 10:14]

Report message to a moderator

Re: Output model tagged values from the stereotype point to the input model [message #1110645 is a reply to message #1109971] Tue, 17 September 2013 06:24 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 167
Registered: September 2012
Senior Member

N.B. The thread mentioned
(http://www.eclipse.org/forums/index.php/mv/msg/452702/1010024/#msg_1010024)
describes a solution with EMFTVM! It will not work with the standard ATL VM!


Cheers,
Dennis
Re: Output model tagged values from the stereotype point to the input model [message #1110667 is a reply to message #1110645] Tue, 17 September 2013 06:48 Go to previous messageGo to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Thanks Dennis! I didn't notice that, you think this would work with EMFTVM?
I have no experience with EMFTVM but I will try it and I will let you know my results.

[Updated on: Tue, 17 September 2013 06:53]

Report message to a moderator

Re: Output model tagged values from the stereotype point to the input model [message #1112856 is a reply to message #1110667] Fri, 20 September 2013 09:14 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 167
Registered: September 2012
Senior Member

Javier García wrote on Tue, 17 September 2013 08:48
Thanks Dennis! I didn't notice that, you think this would work with EMFTVM?
I have no experience with EMFTVM but I will try it and I will let you know my results.


Did you manage to make it work with EMFTVM? If not, I'm always happy to learn about any bugs Wink.


Cheers,
Dennis
Re: Output model tagged values from the stereotype point to the input model [message #1112872 is a reply to message #1112856] Fri, 20 September 2013 09:41 Go to previous message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Dennis,
EMFTVM was giving me some problems so for a quick fix I just copied the code that created the stereotypes in the first transformation to all the others and it works as I want it to, but it's not ideal, so now I will try it with EMFTVM and see how to avoid the exceptions I was getting, I'll probably come back here for help and I'll be sure to let you know if it works!
Thanks for all your help.
Previous Topic:Problem assigning in a target the source element of an emftvm rule
Next Topic:How to create a call to a helper in a HOT?
Goto Forum:
  


Current Time: Wed Nov 26 06:59:08 GMT 2014

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

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