One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/911862/#msg_911862
I have a scenario which a target model should create a sequence of classes due to the list of Strings another class holds.

The code snippet below illustrates the problem. I have FindClause which has bindingObjects whichs holds a list of aliases (EStrings).
For each Aliases I have to create a ObjectSource class which alias will be each FindClause.bindingObject.Alias of the list and className will be an String according to the type attribute of BindingObject.

I started a rule Find2From and created a helper to return the className based on FindClause.bindingObject.type, however how to fill alias attribute based on the FindClause.bindingObject.alias list ?

]]>Cristiano De Faveri2012-09-12T13:16:02-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/911904/#msg_911904
Multi-valued attributes of type X are considered by ATL as being of type Sequence(X).
So you can navigate BindingObject.alias as of type Sequence(String), in order to obtain the single String value you want to put as the value for the Object.alias (single-valued) String attribute.
Cf. http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Sequence_data_type_operations

Best regards,

Hugo
]]>Hugo Bruneliere2012-09-12T14:59:17-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/913109/#msg_913109
Still stuck with this problem. I've trying different ways to implement using the declarative way of ATL.

]]>Cristiano De Faveri2012-09-14T19:52:29-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/915514/#msg_915514
By using two consecutive "collect" operations, you're obtaining a Sequence(Sequence(ObjectSource)).
To get a Sequence(ObjectSource), you have to explicitly call the "flatten" operation (cf. ATL user guide).
The error may come from this.

Best regards,

Hugo
]]>Hugo Bruneliere2012-09-17T12:53:08-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/915761/#msg_915761
Thanks for your tips.

I tried to insert flatten() into the statement, but without any success.
In order to understand what is going on, I just break down the structure into imperative statements to collect more information about it. I tried some debug statements and even debug environment, but it does not help me a lot.

This approach leads to a java.lang.ArrayIndexOutOfBoundsException exception

The iteration is working fine, I could see every information when traversing the model, even getSourceObject helper. The issue has been raised when trying to fill out the list property (

I'm trying different paths in order to solve this problem, unfortunately without success. Do you have any another advise or some debug tip I could use ?

Many thanks Hugo for your assistance.

]]>Cristiano De Faveri2012-09-17T23:02:59-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/915933/#msg_915933
The second error comes from the fact that you're using a variable (_fromClause.ObjectList) which has not be initialized yet.
Something like the following may work better:

Anyway I would not try to solve your problem by using an imperative "do" section, because it seems that you're introducing another error that is different from the original one.

Considering your real error (cf. your initial post), it seems that you're doing an illegal call to the "including" operation on a given sequence: have you checked that this is not coming from the "getSourceObject" rule or from the "getObjectName" helper?

Best regards,

Hugo

]]>Hugo Bruneliere2012-09-18T08:38:41-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/916099/#msg_916099
I'll keep the original declarative issue per your recommendation. The imperative code was just to try to break down the problem.

OK, according to your previous message, since collect over collect will generate a sequence over a sequence.
Debug(), in this case, is running before trying to insert ObjectSource object into the sequence. The problem seems the Sequence expects a Sequence and not a single object returned by getSourceObject(..). Even though, I believe that the message Operation not found ASMModule.including(java.util.ArrayList) would not be appropriate in this situation since it is a Sequence anyway. But I'm not sure if this would be the problem.

I tried to flat the sequence before inserting but without success as well.

I shared a small project focused on this problem containing ecore metamodel, a simple model and atl files. This is the project I'm currently working on to try to solve the issue. If you can take a look Hugo, I'd be very very grateful.

www.defavari.com.br/public/ATLProject/

Thank you again.

]]>Cristiano De Faveri2012-09-18T14:22:57-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/916135/#msg_916135
The "flatten" operation should be applied onto the nesting collection:

]]>Cristiano De Faveri2012-09-18T15:53:39-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/916362/#msg_916362
Just to register a change I made for testing purposes, I created a helper which returns an oclUndefined instead of call getSourceObject(..). Just to check if the problem is located on "including" to sequence or if the message is a consequence of another problem. The weird part is that using an oclUndefined any error is raised. Using debug() after flatten() it shows {oclUndefined, oclUndefined}. I do not know if the ASMModule just skip any part of the code when the object is of type oclUndefined or if the rule getSourceObject (..) is not working properly. All debug clauses inserted into getSourceObject shows the data properly. It seems the "to" clause is not creating the object properly raising an issue that is not clear on the current exceptional message. Maybe this information is valuable.

]]>Cristiano De Faveri2012-09-18T23:49:15-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/916624/#msg_916624
Thanks for the complementary information.
Right now, I cannot really see where the error is coming from.
Have you already tried to use the ATL Debugger on this transformation?
Maybe this could help to better trace what actually happens during the transformation execution...

Hugo]]>Hugo Bruneliere2012-09-19T08:39:34-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/916757/#msg_916757
I'm really under pressure on this point because this is just the tip of the iceberg of the entire transformation. Without solving this issue, I can't move forward, unless I have some alternative for now.

Thank you again.]]>Cristiano De Faveri2012-09-19T12:19:40-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/918212/#msg_918212
Help me to understand why it works now !

which error come from. In my mind, ATL built two sequences from collect over collect Sequence{Sequence{hqlModel!ObjectSource}} which flattened yields in a perfect Sequence{hqlModel!ObjectSource} which is what the property ObjectList expects. However the error we saw about incluing operation missing seems not be about these two sequences (what makes sense since Sequences owns including operation). What I do is to "cast" the return of called rule getSourceObject to Sequence of hqlModel!ObjectSource in the imperative portion of the code. Look :

Returning a sequence instead of a single object works, however it does not make sense for me yet. Do you have any idea about it ?

thanks.

]]>Cristiano De Faveri2012-09-20T21:14:43-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/918671/#msg_918671
What happens if you just let the original nested "collects" (with the correct call to "flatten") and write your called rule like this:

I was wrong when thinking "to" section leaves available the object for further computation. I was thinking "to" clause like a return of a function and it seems this is not the case. Guess this part of the manual clarify this point. It was not clear for me when I read this in the past... my apologizes.

Called Rules
...
"The code specified within the imperative block makes a variable (metamodel) defined in the context of the ATL module pointing to this model element. By this mean, the generated Metamodel remains accessible for further computation during the transformation.
... "

Am I right ?]]>Cristiano De Faveri2012-09-21T16:00:48-00:00Re: One to many transformationhttps://www.eclipse.org/forums/index.php/mv/msg/375546/921582/#msg_921582
Hugo
]]>Hugo Bruneliere2012-09-24T08:43:35-00:00