Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] problems with helpers
[ATL] problems with helpers [message #42291] Mon, 28 May 2007 14:05 Go to next message
Eclipse UserFriend
Originally posted by: angelsaneg.yahoo.es

hello,



We have some problems with Atl transformations.

We use this helper and rule:



helper context String def: firstToLower() : String =

self.substring(1, 1).toLower() + self.substring(2, self.size());



....



rule Route2Menu {

from

a : ExtendedSlicesMetamodel!Route_Type

to

b : ExtendedNavigationMetamodel!Menu_Type (

Forward <- a.Name_Route.firstToLower()

)

}







Name_Route is an attribute of the class Menu_Type (this attribute is
inherit from an abstract father class) . When we use this helper(
firstToLower) in the rule, this error occurs:





****** BEGIN Stack Trace

message: ERROR: could not find operation firstToLower on Sequence(OclAny)
having supertypes: [Collection(OclAny)]

A.main() : ??#24 null

local variables = {self=tres2cuatro : ASMModule}

local stack = []

A.__exec__() : ??#8 null

local variables = {e=TransientLink {rule = 'Route2Menu', sourceElements =
{a = IN!<unnamed>}, targetElements = {b = OUT!<unnamed>}, variables = {}},
self=tres2cuatro : ASMModule}

local stack = []

A.__applyRoute2Menu(1 : NTransientLink;) : ??#13 59:36-59:63

local variables = {b=OUT!<unnamed>, a=IN!<unnamed>, link=TransientLink
{rule = 'Route2Menu', sourceElements = {a = IN!<unnamed>}, targetElements
= {b = OUT!<unnamed>}, variables = {}}, self=tres2cuatro : ASMModule}

local stack = [OUT!<unnamed>, OUT!<unnamed>, tres2cuatro : ASMModule]

****** END Stack Trace

Execution terminated due to error (see launch configuration to allow
continuation after errors).





thanks.



best regards,

Angel Sanchez, David Redondo
Re: [ATL] problems with helpers [message #42328 is a reply to message #42291] Mon, 28 May 2007 14:32 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

It seems that the upper bound of the multiplicity of attribute
Name_Route is greater than 1 (i.e., that Name_Route is multi-valued),
which means that its value is a Collection of Strings.

If Forward is also multi-valued, you might want to write:

Forward <- a.Name_Route->collect(e | e.firstToLower())

If Forward is not multi-valued, you might want to:

- get the first element of the Collection (if it is ordered):

Forward <- a.Name_Route->first().firstToLower()

- get any element of the Collection:

Forward <- a.Name_Route->any(e | true).firstToLower()

- concatenate the values of the Collection:

Forward <- a.Name_Route->including('')->sum().firstToLower())

->including('') makes sure the Collection is not empty, in which case
->sum() would fail to return a String.


Best regards,

Frédéric Jouault


Angel Sanchez wrote:
> hello,
>
>
>
> We have some problems with Atl transformations.
> We use this helper and rule:
>
>
>
> helper context String def: firstToLower() : String =
>
> self.substring(1, 1).toLower() + self.substring(2, self.size());
>
>
>
> ....
>
>
>
> rule Route2Menu {
>
> from
>
> a : ExtendedSlicesMetamodel!Route_Type
> to
>
> b : ExtendedNavigationMetamodel!Menu_Type (
>
> Forward <- a.Name_Route.firstToLower()
>
> )
>
> }
>
>
>
>
>
>
>
> Name_Route is an attribute of the class Menu_Type (this attribute is
> inherit from an abstract father class) . When we use this helper(
> firstToLower) in the rule, this error occurs:
>
>
>
>
> ****** BEGIN Stack Trace
>
> message: ERROR: could not find operation firstToLower on
> Sequence(OclAny) having supertypes: [Collection(OclAny)]
>
> A.main() : ??#24 null
>
> local variables = {self=tres2cuatro : ASMModule}
>
> local stack = []
>
> A.__exec__() : ??#8 null
>
> local variables = {e=TransientLink {rule = 'Route2Menu',
> sourceElements = {a = IN!<unnamed>}, targetElements = {b =
> OUT!<unnamed>}, variables = {}}, self=tres2cuatro : ASMModule}
>
> local stack = []
>
> A.__applyRoute2Menu(1 : NTransientLink;) : ??#13 59:36-59:63
>
> local variables = {b=OUT!<unnamed>, a=IN!<unnamed>,
> link=TransientLink {rule = 'Route2Menu', sourceElements = {a =
> IN!<unnamed>}, targetElements = {b = OUT!<unnamed>}, variables = {}},
> self=tres2cuatro : ASMModule}
>
> local stack = [OUT!<unnamed>, OUT!<unnamed>, tres2cuatro : ASMModule]
>
> ****** END Stack Trace
>
> Execution terminated due to error (see launch configuration to allow
> continuation after errors).
>
>
>
>
>
> thanks.
>
>
>
> best regards,
>
> Angel Sanchez, David Redondo
>
Re: [ATL] problems with helpers [message #42400 is a reply to message #42291] Mon, 28 May 2007 14:33 Go to previous message
Ã?ric Vépa is currently offline Ã?ric VépaFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Angel,

Angel Sanchez wrote:
> hello,
>
> We have some problems with Atl transformations.
> We use this helper and rule:
>
> helper context String def: firstToLower() : String =
>
> self.substring(1, 1).toLower() + self.substring(2, self.size());
>
>
> rule Route2Menu {
>
> from
>
> a : ExtendedSlicesMetamodel!Route_Type
> to
>
> b : ExtendedNavigationMetamodel!Menu_Type (
>
> Forward <- a.Name_Route.firstToLower()
>
> )
>
> }
>
>
> Name_Route is an attribute of the class Menu_Type (this attribute is
> inherit from an abstract father class) . When we use this helper(
> firstToLower) in the rule, this error occurs:
>
>
>
>
> ****** BEGIN Stack Trace
>
> message: ERROR: could not find operation firstToLower on
> Sequence(OclAny) having supertypes: [Collection(OclAny)]
>
> ...

According to the error message, the attribute Name_Route is not a String
but a Sequence (of String ?).
What is the multiplicity of this attribute (reference ?) in your KM3
metamodel ?
If you really want a Sequence, you can applied your helper on the first
element (a.Name_Route->first().firstToLower()). You may ensure that the
sequence can not be empty (using a if statement) or the first() function
will return an error.


--
Éric Vépa

SODIUS
6, rue de Cornouaille - BP 91941
44319 Nantes, France
Email: evepa@sodius.com

www.mdworkbench.com
Draw more value from your models
Previous Topic:[ATL] How to install ANT Tasks?
Next Topic:[ATL] rules library
Goto Forum:
  


Current Time: Fri Apr 19 13:10:28 GMT 2024

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

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

Back to the top