Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Help with TaggedValues
Help with TaggedValues [message #52775] Tue, 17 July 2007 18:39 Go to next message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi,

I need created a new TaggedValue using many values in dataValue attribute.

I have a following rule:

lazy rule newTaggedValue {
from element : UML!Element, name: String, value: Sequence(String)
to t : UML!TaggedValue (
modelElement <- element,
name <- name,
type <- thisModule.getTagDefinition(name),
dataValue <- value->asBag()
)
}

and a call for this rule is:
....
rule Model_PSM {
from
s : UML!Model (thisModule.inElements->includes(s))
to
t : UML!Model mapsTo s(
name <- s.name,
ownedElement <- s.ownedElement
)
do {
....
if thisModule.taggedValueExists(thisModule.umlOperation, 'base') then
true
else
thisModule.newTaggedValue(thisModule.umlOperation,'base',
Sequence{'call(* Cliente+.*(..))',
'||',
'get(private String ClientePF.cpf)',
'||',
'set(private String ClientePF.cpf)'})
endif;
...
}

Well,
when I perform this rule to generate the XMI, the result is the following:

<UML:ModelElement.taggedValue>
<UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
<UML:TaggedValue.dataValue>set(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>get(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>call(*
Cliente+.*(..))</UML:TaggedValue.dataValue>
<UML:TaggedValue.type>
<UML:TagDefinition xmi.idref = 'a280'/>
</UML:TaggedValue.type>
</UML:TaggedValue>
</UML:ModelElement.taggedValue>

But I need XMI to be like this, that is, the TaggedValue.dataValue has to
contain all of the elements of Sequence and in the same order.

<UML:ModelElement.taggedValue>
<UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
<UML:TaggedValue.dataValue>call(*
Cliente+.*(..))</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>get(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>set(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.type>
<UML:TagDefinition xmi.idref = 'a280'/>
</UML:TaggedValue.type>
</UML:TaggedValue>
</UML:ModelElement.taggedValue>

Some idea to solve this problem?

Thanks in advance,
Marcelo
[ATL] Re: Help with TaggedValues [message #52802 is a reply to message #52775] Tue, 17 July 2007 18:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi,

I need created a new TaggedValue using many values in dataValue attribute.

I have a following rule:

lazy rule newTaggedValue {
from element : UML!Element, name: String, value: Sequence(String)
to t : UML!TaggedValue (
modelElement <- element,
name <- name,
type <- thisModule.getTagDefinition(name),
dataValue <- value->asBag()
)
}

and a call for this rule is:
....
rule Model_PSM {
from
s : UML!Model (thisModule.inElements->includes(s))
to
t : UML!Model mapsTo s(
name <- s.name,
ownedElement <- s.ownedElement
)
do {
....
if thisModule.taggedValueExists(thisModule.umlOperation, 'base') then
true
else
thisModule.newTaggedValue(thisModule.umlOperation,'base',
Sequence{'call(* Cliente+.*(..))',
'||',
'get(private String ClientePF.cpf)',
'||',
'set(private String ClientePF.cpf)'})
endif;
...
}

Well,
when I perform this rule to generate the XMI, the result is the following:

<UML:ModelElement.taggedValue>
<UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
<UML:TaggedValue.dataValue>set(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>get(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>call(*
Cliente+.*(..))</UML:TaggedValue.dataValue>
<UML:TaggedValue.type>
<UML:TagDefinition xmi.idref = 'a280'/>
</UML:TaggedValue.type>
</UML:TaggedValue>
</UML:ModelElement.taggedValue>

But I need XMI to be like this, that is, the TaggedValue.dataValue has to
contain all of the elements of Sequence and in the same order.

<UML:ModelElement.taggedValue>
<UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
<UML:TaggedValue.dataValue>call(*
Cliente+.*(..))</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>get(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
<UML:TaggedValue.dataValue>set(private String
ClientePF.cpf)</UML:TaggedValue.dataValue>
<UML:TaggedValue.type>
<UML:TagDefinition xmi.idref = 'a280'/>
</UML:TaggedValue.type>
</UML:TaggedValue>
</UML:ModelElement.taggedValue>

Some idea to solve this problem?

Thanks in advance,
Marcelo
Re: [ATL] Re: Help with TaggedValues [message #52932 is a reply to message #52802] Wed, 18 July 2007 06:07 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 147
Registered: July 2009
Senior Member
Marcelo Alves schreef:
> Hi,
>
> I need created a new TaggedValue using many values in dataValue attribute.
>
> I have a following rule:
>
> lazy rule newTaggedValue {
> from element : UML!Element, name: String, value: Sequence(String)
> to t : UML!TaggedValue (
> modelElement <- element,
> name <- name,
> type <- thisModule.getTagDefinition(name),
> dataValue <- value->asBag()
> )
> }
>
*snip*
>
> Well,
> when I perform this rule to generate the XMI, the result is the following:
>
> <UML:ModelElement.taggedValue>
> <UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
> <UML:TaggedValue.dataValue>set(private String
> ClientePF.cpf)</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>get(private String
> ClientePF.cpf)</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>call(*
> Cliente+.*(..))</UML:TaggedValue.dataValue>
> <UML:TaggedValue.type>
> <UML:TagDefinition xmi.idref = 'a280'/>
> </UML:TaggedValue.type>
> </UML:TaggedValue>
> </UML:ModelElement.taggedValue>
>
> But I need XMI to be like this, that is, the TaggedValue.dataValue has
> to contain all of the elements of Sequence and in the same order.
>
> <UML:ModelElement.taggedValue>
> <UML:TaggedValue xmi.id = 'a291' name = 'base' isSpecification = 'false'>
> <UML:TaggedValue.dataValue>call(*
> Cliente+.*(..))</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>get(private String
> ClientePF.cpf)</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>||</UML:TaggedValue.dataValue>
> <UML:TaggedValue.dataValue>set(private String
> ClientePF.cpf)</UML:TaggedValue.dataValue>
> <UML:TaggedValue.type>
> <UML:TagDefinition xmi.idref = 'a280'/>
> </UML:TaggedValue.type>
> </UML:TaggedValue>
> </UML:ModelElement.taggedValue>
>
> Some idea to solve this problem?
>
> Thanks in advance,
> Marcelo
>

Have you tried not doing "value->asBag()" in your newTaggedValue rule?
"value" should already be a sorted Sequence, while Bags are unsorted.

Another side effect I see, is that the duplicate '||' string was
filtered out. This should not happen with a Bag, and may be an ATL bug.

Dennis
Re: [ATL] Re: Help with TaggedValues [message #53259 is a reply to message #52932] Wed, 18 July 2007 19:13 Go to previous message
Eclipse UserFriend
Originally posted by: mpitanga.gmail.com

Hi Dennis,

Thank you for your replay.

I solved this problem by modifying the metamodel UMLDI.
In the definition of the multiplicity
(<Model:StructuralFeature.multiplicity>) I replaced the value of the
second <XMI.field> from true to false.

<Model:Class xmi.id = 'a684' name = 'TaggedValue' annotation = '' isRoot =
'false'
isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis'
isSingleton = 'false'>
<Model:Namespace.contents>
<Model:Attribute xmi.id = 'a840' name = 'dataValue' annotation
= '' scope = 'instance_level'
visibility = 'public_vis' isChangeable = 'true' isDerived =
'false'>
<Model:StructuralFeature.multiplicity>
<XMI.field>0</XMI.field>
<XMI.field>-1</XMI.field>
<XMI.field>false</XMI.field>

<XMI.field>false</XMI.field> <--- replace true by false

</Model:StructuralFeature.multiplicity>
<Model:TypedElement.type>
<Model:AliasType xmi.idref = 'a573'/>
</Model:TypedElement.type>
</Model:Attribute>

Thanks
Marcelo
Previous Topic:[ATL] How to create a model handler for UML2 in Eclipse 3.1
Next Topic:[ATL]source code issue
Goto Forum:
  


Current Time: Fri Jan 22 12:57:32 GMT 2021

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

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

Back to the top