Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Simultanious loading of two collections which are brances of the same tree
Simultanious loading of two collections which are brances of the same tree [message #44946] Wed, 06 June 2007 19:21 Go to next message
Mariya Denysova is currently offline Mariya DenysovaFriend
Messages: 3
Registered: July 2009
Junior Member
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.
Re: [ATL] Simultanious loading of two collections which are brances of the same tree [message #44977 is a reply to message #44946] Wed, 06 June 2007 23:15 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,

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.
>
>
Re: Simultanious loading of two collections which are brances of the same tree [message #45115 is a reply to message #44946] Fri, 08 June 2007 09:54 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: [ATL] Simultanious loading of two collections which are brances of the same tree [message #45143 is a reply to message #45115] Fri, 08 June 2007 09:56 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: [ATL] Simultanious loading of two collections which are brances of the same [message #45359 is a reply to message #44977] Fri, 08 June 2007 14:45 Go to previous messageGo to next message
Mariya Denysova is currently offline Mariya DenysovaFriend
Messages: 3
Registered: July 2009
Junior Member
Hello Frédéric, hello Régis,

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.
Re: [ATL] Simultanious loading of two collections which are brances of the same [message #45593 is a reply to message #45359] Mon, 11 June 2007 15:06 Go to previous messageGo to next message
Mariya Denysova is currently offline Mariya DenysovaFriend
Messages: 3
Registered: July 2009
Junior Member
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?

Regards,
Mariya
Re: [ATL] Simultanious loading of two collections which are brances of the same [message #45622 is a reply to message #45593] Mon, 11 June 2007 17:13 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> 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?


Best regards,

Frédéric Jouault
Previous Topic:[ATL] conflict between metamodel and MOF
Next Topic:[ATL] One more problem in running Main.java written by Dennis
Goto Forum:
  


Current Time: Tue Apr 16 23:18:37 GMT 2024

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

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

Back to the top