Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Stereotypes tag values: setValue to copy tag value(setValue to copy tag value)
Stereotypes tag values: setValue to copy tag value [message #931388] Wed, 03 October 2012 06:32 Go to next message
iker zeziaga is currently offline iker zeziagaFriend
Messages: 2
Registered: October 2012
Junior Member
Hi,


I'm new with ATL. I'm trying to copy some UML diagrams depending on the stereotypes that have the elements in the model. Everything is fine until I try to copy all the tag values the element may have. I don't find why the target model has no value on its tags. Any idea would be helpful.


helper context UML2!Element def:setTagValue(stereotype:String, tag:String, value:UML2!EObject):UML2!Element=
if(self.getAppliedStereotypes()->select(e|e.name=stereotype)->notEmpty())
then self.setValue(self.getAppliedStereotypes()->select(f|f.name=stereotype)->first(),tag,value)
else OclUndefined
endif;


rule copy{
...

do{
for(st in s.getAppliedStereotypes()){
t.applyStereotype(st);
thisModule.inStereotype<-st;
for(tag in st.getOwnedAttributes()){
thisModule.inTag<-tag;
t.setTagValue(thisModule.inStereotype.name,thisModule.inTag.name,s.getTagValue(thisModule.inStereotype.name,thisModule.inTag.name))
}
}
}
}

if I use setTagValue with concrete or specific values, it works fine.

iker

Re: Stereotypes tag values: setValue to copy tag value [message #937046 is a reply to message #931388] Mon, 08 October 2012 15:58 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi Iker,
I'm not sure what is wrong there. You can try my version which I have been using for a few years. It is quite similar but a little more robust. The check for the base_ property could be improved though. Anyway it works!

do
{
--apply all the profile's stereotype values to the target model. they don't get copied by ATL automatically
thisModule.applyStereoTypesValue(false,s,t);
}

--apply all the profile's stereotype values to the target model. they don't get copied by ATL automatically
rule applyStereoTypesValue(required : Boolean, s : UML!Element, t : UML!Element)
{
do
{
--loop over all the stereotypes on an element
for (stereotype in s.getAppliedStereotypes())
{
--if the UML!Element does not get its stereotype automically applied (i.e. UML not required) then we must apply it manually
--note:surprisingly the "required" property doesn't seem to be exposed by UML2. maybe look into this more
if (not required)
{
t.applyStereotype(stereotype);
}

--loop over all the stereotype's properties
for (property in stereotype.getAllAttributes())
{
--apply the value if there is one. don't apply the base type property as ATL cannot handle this. also don't touch read-only properties.
if(s.hasValue(stereotype,property.name) and (not property.name.startsWith('base_')) and not property.isReadOnly())
{
t.setValue(stereotype,property.name,s.getValue(stereotype,property.name));
}
}
}
}
}

The comments come for free Smile
Regards,
Ronan
Re: Stereotypes tag values: setValue to copy tag value [message #938727 is a reply to message #937046] Wed, 10 October 2012 05:21 Go to previous message
iker zeziaga is currently offline iker zeziagaFriend
Messages: 2
Registered: October 2012
Junior Member
Thanks Ronan.

I tried it and it works fine now.I think my version does not work because of the base_property. I didn't realize on that.
Thanks again,
iker.
Previous Topic:ATL ignores elements inside a UML PackageImport
Next Topic:semantic error
Goto Forum:
  


Current Time: Sat Apr 20 04:00:24 GMT 2024

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

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

Back to the top