Output model tagged values from the stereotype point to the input model [message #1104995] |
Mon, 09 September 2013 07:49 |
Javier García 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 #1107334 is a reply to message #1106639] |
Thu, 12 September 2013 08:59 |
Javier García 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 #1108007 is a reply to message #1107561] |
Fri, 13 September 2013 07:44 |
Javier García 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 #1109971 is a reply to message #1108135] |
Mon, 16 September 2013 07:35 |
Javier García 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
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09177 seconds