Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL .add alternative required
EOL .add alternative required [message #631431] Thu, 07 October 2010 10:32 Go to next message
James Sharp is currently offline James Sharp
Messages: 20
Registered: September 2010
Junior Member
Hi,

I am new to ETL and was wondering how on earth I could add duplicate entries of a referenced object to a class?

I am using the following EOL in my ETL rule:

if (port.hasDirection.name.toLowerCase() == "in") {
ddChannelValues.add(port.name);
var dataType := GetDataType(port);
ddParameterList.parameterTypes.add(dataType);
}

ddChannel.definesParameters := ddParameterList;

The GetDataType(port) calls an operation which returns a reference to an already exisiting dataType.

I need to create a channel dd which may contain multiple entries of the same dataType. How can I do this?

From the manual:
add(item : Any):
Adds an item to the collection. If the collection is a set, addition of duplicate items has no effect.

Is there an alternative I can use to the add method?

My reference parameterTypes in Emf is defined as:

class ChannelParameterList {
ref Type[+] parameterTypes;
}

And the ecore output shows that parameterTypes reference is both Ordered and Unique.

Any help in finding a way to add the same dataType to this reference in an ordered way with multiple copies would be greatly appreciated.

Do I need to turn the reference into an Ordered Set? If so how can i do this with Emfatic?

Many Thanks,

James
Re: EOL .add alternative required [message #631482 is a reply to message #631431] Thu, 07 October 2010 12:05 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

You'll need to add the !unique modifier before your ref:

class ChannelParameterList {
!unique ref Type[+] parameterTypes;
}

Fairly complete documentation about Emfatic is available in
http://eclipse.org/gmt/epsilon/doc/articles/emfatic/ in case you've
missed this.

Cheers,
Dimitris

On 07/10/2010 16:32, James Sharp wrote:
> Hi,
>
> I am new to ETL and was wondering how on earth I could add duplicate
> entries of a referenced object to a class?
>
> I am using the following EOL in my ETL rule:
>
> if (port.hasDirection.name.toLowerCase() == "in") {
> ddChannelValues.add(port.name);
> var dataType := GetDataType(port);
> ddParameterList.parameterTypes.add(dataType);
> }
>
> ddChannel.definesParameters := ddParameterList;
>
> The GetDataType(port) calls an operation which returns a reference to an
> already exisiting dataType.
>
> I need to create a channel dd which may contain multiple entries of the
> same dataType. How can I do this?
>
> From the manual:
> add(item : Any):
> Adds an item to the collection. If the collection is a set, addition of
> duplicate items has no effect.
>
> Is there an alternative I can use to the add method?
>
> My reference parameterTypes in Emf is defined as:
>
> class ChannelParameterList {
> ref Type[+] parameterTypes;
> }
>
> And the ecore output shows that parameterTypes reference is both Ordered
> and Unique.
>
> Any help in finding a way to add the same dataType to this reference in
> an ordered way with multiple copies would be greatly appreciated.
>
> Do I need to turn the reference into an Ordered Set? If so how can i do
> this with Emfatic?
>
> Many Thanks,
>
> James
Re: EOL .add alternative required [message #631693 is a reply to message #631482] Fri, 08 October 2010 09:38 Go to previous messageGo to next message
James Sharp is currently offline James Sharp
Messages: 20
Registered: September 2010
Junior Member
Hi Dimitris,

I have added the !unique flag and regenerated my meta-model but this does not seem to have made a difference.

I added some print lines to try and discover what is happening and the addition of the not unique flag to the emf model seems to have made no difference?

The meta-model (in ecore and genmodel formats) both show that the reference ParameterList to ParameterItems is ordered but not unique (also resolvable proxy and changable are set to true - all other feature options are false).

Your documetation suggests that the add method will not create duplicate entries on a set. From my understanding an ecore reference is stored as an EList, and appears as such in the Java source for the meta-model.

Should I still be using the add method (I have tried eSet but I receive an error that the method does not exist).

I have also performed a sanity check and all the refeences in the source model are being traversed.

Any idea's on how to fix this would be greatly appreciated, feeling a bit new and out of my depth.

Many thanks,

James
Re: EOL .add alternative required [message #631879 is a reply to message #631693] Sat, 09 October 2010 14:09 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

Unfortunately, I'm not able to reproduce this. I'm using the following
metamodel:

@namespace(uri="uniquetest", prefix="uniquetest")
package uniquetest;

class Root {
unique ref Obj[*] uniqueVal;
!unique ref Obj[*] nonUniqueVal;
}

class Obj {
attr String name;
}

and the following EOL script:

var root = new Root;

var a = new Obj;

root.uniqueVal.add(a);
root.uniqueVal.add(a);

root.uniqueVal.size().println();

var b = new Obj;

root.nonUniqueVal.add(b);
root.nonUniqueVal.add(b);

root.nonUniqueVal.size().println();

and what I'm getting in the console is

1
2

which is consistent with what I'd expect. Could you please send me your
metamodels/models/transformations etc at epsilon.devs at gmail dot com
so that I can have a look?

Cheers,
Dimitris

On 08/10/2010 14:38, James Sharp wrote:
> Hi Dimitris,
>
> I have added the !unique flag and regenerated my meta-model but this
> does not seem to have made a difference.
>
> I added some print lines to try and discover what is happening and the
> addition of the not unique flag to the emf model seems to have made no
> difference?
>
> The meta-model (in ecore and genmodel formats) both show that the
> reference ParameterList to ParameterItems is ordered but not unique
> (also resolvable proxy and changable are set to true - all other feature
> options are false).
>
> Your documetation suggests that the add method will not create duplicate
> entries on a set. From my understanding an ecore reference is stored as
> an EList, and appears as such in the Java source for the meta-model.
>
> Should I still be using the add method (I have tried eSet but I receive
> an error that the method does not exist).
>
> I have also performed a sanity check and all the refeences in the source
> model are being traversed.
>
> Any idea's on how to fix this would be greatly appreciated, feeling a
> bit new and out of my depth.
>
> Many thanks,
>
> James
>
Re: EOL .add alternative required [message #632064 is a reply to message #631879] Mon, 11 October 2010 08:38 Go to previous messageGo to next message
James Sharp is currently offline James Sharp
Messages: 20
Registered: September 2010
Junior Member
Hi dimitris,

I have been exploring the issue with Mirko from EMFText and it appears that this is actually an issue with EMF itself:

http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 6272.html

Thanks for investigating, I will have to implement a work around for this.


Many Thanks,

James
Re: EOL .add alternative required [message #632068 is a reply to message #632064] Mon, 11 October 2010 08:46 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

Thanks for the update! Hopefully, this will save the next person who
comes across the same issue a good few hours :)

Cheers,
Dimitris

James Sharp wrote:
> Hi dimitris,
>
> I have been exploring the issue with Mirko from EMFText and it appears
> that this is actually an issue with EMF itself:
>
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 6272.html
>
> Thanks for investigating, I will have to implement a work around for this.
>
>
> Many Thanks,
>
> James
Previous Topic:[EuGENia] GMF compartment nodes behaving badly
Next Topic:[ETL] ETL and launch configuration
Goto Forum:
  


Current Time: Tue Jul 22 15:52:55 EDT 2014

Powered by FUDForum. Page generated in 0.10451 seconds