Output model tagged values from the stereotype point to the input model [message #1104995] |
Mon, 09 September 2013 03:49  |
Javier García Messages: 112 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 03: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 04:34   |
Hugo Bruneliere Messages: 560 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 #1105951 is a reply to message #1105707] |
Tue, 10 September 2013 09:37   |
Hugo Bruneliere Messages: 560 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 #1106639 is a reply to message #1106532] |
Wed, 11 September 2013 06:59   |
Hugo Bruneliere Messages: 560 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 04:59   |
Javier García Messages: 112 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 03:44   |
Javier García Messages: 112 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 07:41   |
Hugo Bruneliere Messages: 560 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 03:35   |
Javier García Messages: 112 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 06:14] Report message to a moderator
|
|
|
|
|
|
| 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 05:41  |
Javier García Messages: 112 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.
|
|
|
Powered by
FUDForum. Page generated in 0.01974 seconds