EOL .add alternative required [message #631431] |
Thu, 07 October 2010 10:32  |
Eclipse User |
|
|
|
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 #631879 is a reply to message #631693] |
Sat, 09 October 2010 14:09   |
Eclipse User |
|
|
|
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
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10209 seconds