Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsSimultanious loading of two collections which are brances of the same tree
https://www.eclipse.org/forums/index.php/mv/msg/14174/44946/#msg_44946
I have the following problem.
I have the following input model which conform to ecore.Change metamodel:
rule ChangeDescription {
from
inputModel : Change!ChangeDescription
using {
subKeys : Set (Change!EObject) = inputModel.objectChanges->select(f |
f.value->exists(k | k.featureName = 'eSubpackages'))->collect(i |
i.key);
coll : Collection(Change!EObjectToChangesMapEntry) =
inputModel.objectChanges->select(i | i.value->exists(k | k.featureName =
'eSuperPackage' and subKeys->includes(k.referenceValue)));
}
to
targetModel : distinct Changemm!PackageDelete foreach (e in coll)(
package <- e.key,
superPackage <- e.key
)
}
Unfortunately the expression subKeys->includes(k.referenceValue) always
returns 'false'. Seems that at the moment of execution of this rule
subKeys collection is always empty.
It seems to me that this is a bug in ATL, because this code works well in
the debug mode. When running the debugger I can see that this collection
contains objects.
It looks as if in the runtime mode the ATL virtual machine loads only one
branch of the input "tree" and doesn't see the other one.
Thanks in advance. Hopefully you can help me.
Regards,
Mariya.]]>Mariya Denysova2007-06-06T19:21:10-00:00Re: [ATL] Simultanious loading of two collections which are brances of the same tree
https://www.eclipse.org/forums/index.php/mv/msg/14174/44977/#msg_44977
Could you please prefix the subject of your ATL-related posts on this
newsgroup with [ATL], as I am doing in this answer? Thanks.
There should not be any difference between Run and Debug mode.
A very convenient way to see the values of expressions in Run mode is to
use the OclAny.debug(message : String) : OclAny operation.
It returns its source (i.e., using it does not change anything for the
transformation) and prints out the message followed by the source to the
console.
Could you please insert calls to the "debug" operation in your code, and
report the results here?
Regards,
Frédéric Jouault
Mariya Denysova wrote:
> Hello,
>
> I have the following problem.
>
> I have the following input model which conform to ecore.Change metamodel:
>
> <?xml version="1.0" encoding="ASCII"?>
> <change:ChangeDescription xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:change="http://www.eclipse.org/emf/2003/Change">
> <objectChanges>
> <key
> href=" platform:/resource/org.denysova.transformation/deletions/Pur chaseD.ecore#//orders/suborders "/>
>
> <value featureName="eSuperPackage">
> <referenceValue
> href=" platform:/resource/org.denysova.transformation/deletions/Pur chaseD.ecore#//orders "/>
>
> </value>
> </objectChanges>
> <objectChanges>
> <key
> href=" platform:/resource/org.denysova.transformation/deletions/Pur chaseD.ecore#//orders "/>
>
> <value featureName="eSubpackages" set="false"/>
> </objectChanges>
> </change:ChangeDescription>
>
> In my ATL file I do the following:
>
> rule ChangeDescription {
> from inputModel : Change!ChangeDescription using {
> subKeys : Set (Change!EObject) =
> inputModel.objectChanges->select(f | f.value->exists(k | k.featureName =
> 'eSubpackages'))->collect(i | i.key);
> coll : Collection(Change!EObjectToChangesMapEntry) =
> inputModel.objectChanges->select(i | i.value->exists(k | k.featureName =
> 'eSuperPackage' and subKeys->includes(k.referenceValue)));
>
> }
> to
> targetModel : distinct Changemm!PackageDelete foreach (e in coll)(
> package <- e.key, superPackage <- e.key )
> }
>
> Unfortunately the expression subKeys->includes(k.referenceValue) always
> returns 'false'. Seems that at the moment of execution of this rule
> subKeys collection is always empty.
>
> It seems to me that this is a bug in ATL, because this code works well
> in the debug mode. When running the debugger I can see that this
> collection contains objects.
> It looks as if in the runtime mode the ATL virtual machine loads only
> one branch of the input "tree" and doesn't see the other one.
>
> Thanks in advance. Hopefully you can help me.
>
> Regards,
> Mariya.
>
>]]>Frédéric Jouault2007-06-06T23:15:35-00:00Re: Simultanious loading of two collections which are brances of the same tree
https://www.eclipse.org/forums/index.php/mv/msg/14174/45115/#msg_45115
Originally posted by: rchevrel.sodius.com
This is a multi-part message in MIME format.
--------------080504010803050802090102
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi Mariya,
I have perhaps see your problem.
You do:
subKeys : Set (Change!EObject) = inputModel.objectChanges->select(f |
f.value->exists(k | k.featureName = 'eSubpackages'))->collect(i | i.key);
So "inputModel.objectChanges->select(f | f.value->exists(k |
k.featureName = 'eSubpackages'))" give you a Sequence of elements. Then
you do a collect on this sequence ("->collect(i | i.key)"), so you
obtain a Sequence of Sequence.
You have to use the flatten() operation if you want to have a Sequence.
The debug probably show you something like:
Sequence{ Sequence{elmA, elmB}, Sequence{}, ...}. After a flatten, you
will obtain Sequence{elmA, elmB...}.
I hope this will help you.
*R]]>2007-06-08T09:54:56-00:00Re: [ATL] Simultanious loading of two collections which are brances of the same tree
https://www.eclipse.org/forums/index.php/mv/msg/14174/45143/#msg_45143
Originally posted by: rchevrel.sodius.com
This is a multi-part message in MIME format.
--------------050805010704090208080306
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Oups, I did it again!
I have forgot to prefix with [ATL]
sorry :)
R]]>2007-06-08T09:56:19-00:00Re: [ATL] Simultanious loading of two collections which are brances of the same
https://www.eclipse.org/forums/index.php/mv/msg/14174/45359/#msg_45359
thank you for your answers.
Unfortunately they haven't helped yet.
Regis your suggestion was right, by mistake I submitted here in the forum
the wrong piece of code. I tried already with .flatten() and without it.
With .flatten() is right ofcours, but it doesn't help. I still have the
same problem.
Frédéric, I tried to output the sizes of my collections using ".debug"
operation.
It do outputs different results in the debug and runtime mode.
Here is the code of the transformation:
rule ChangeDescription {
from
inputModel : Change!ChangeDescription
using {
subKeys : Set (Change!EObject) = inputModel.objectChanges->select(f |
f.value->exists(k | k.featureName = 'eSubpackages'))->collect(i |
i.key)->flatten();
coll : Collection(Change!EObjectToChangesMapEntry) =
inputModel.objectChanges->select(i | i.value->exists(k | k.featureName =
'eSuperPackage' and subKeys->includes(k.referenceValue)));
}
to
targetModel : distinct Changemm!PackageDelete foreach (e in coll)(
package <- e.key,
superPackage <- e.key
)
do{
subKeys.size().debug('size of the subKeys collection');
coll.size().debug('size of the coll collection');
}
}
In the runtime mode the following is printed to the console:
size of the subKeys collection: 1
size of the coll collection: 0
And in the debug mode:
size of the subKeys collection: 1
size of the coll collection: 1
So the results are really different.
I still think smth. like a "race condition" happens when my code is
executed in the runtime mode.
Best regards,
Mariya.]]>Mariya Denysova2007-06-08T14:45:46-00:00Re: [ATL] Simultanious loading of two collections which are brances of the same
https://www.eclipse.org/forums/index.php/mv/msg/14174/45593/#msg_45593
I'm stuck with my diploma work because of this mistake. And I have strong
belives that this is the bug of the ATL virtual machine. But even if it
is, maybe someone could suggest a work around this problem?
Regards,
Mariya]]>Mariya Denysova2007-06-11T15:06:39-00:00Re: [ATL] Simultanious loading of two collections which are brances of the same
https://www.eclipse.org/forums/index.php/mv/msg/14174/45622/#msg_45622
> People, please help me... I'm stuck with my diploma work because of this
> mistake. And I have strong belives that this is the bug of the ATL
> virtual machine. But even if it is, maybe someone could suggest a work
> around this problem?
Can you please post here the simplest code excerpt exhibiting the issue?