Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » one to many without using operations?
one to many without using operations? [message #635905] Thu, 28 October 2010 15:03 Go to next message
James Sharp is currently offline James Sharp
Messages: 20
Registered: September 2010
Junior Member
Hi,

I keep coming into an issue whereby my mapping requires me to generate multiple instances of the same objects in my target language from one instance in the source langauge. (A one to many as it were)

ETL will only generate the target objects once from the source objects within a rule. Is there any reason for this?

The equivalent method provides a much tidier way to generate the objects and writing these as operations is going to cause all manner of complicated loops for what I require. It seems I keep coming back to this same issue.

I have not yet looked at the ETL source (waiting for IT services to let me access the SVN), but would this fall within the scope of ETL?

Would the ETL framework allow for a new equivalent() type method to be written which could return a duplicated collections of target objects from one set of source objects?


Many Thanks,

James
Re: one to many without using operations? [message #635916 is a reply to message #635905] Thu, 28 October 2010 15:20 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

Would it help if you specified your rules as follows?

rule A2Bs
transform a : Source!A
to bs : Sequence(Target!B) {

for (...) {
var b = new B;
bs.add(b);
}

}

Cheers,
Dimitris

James Sharp wrote:
> Hi,
>
> I keep coming into an issue whereby my mapping requires me to generate
> multiple instances of the same objects in my target language from one
> instance in the source langauge. (A one to many as it were)
>
> ETL will only generate the target objects once from the source objects
> within a rule. Is there any reason for this?
> The equivalent method provides a much tidier way to generate the objects
> and writing these as operations is going to cause all manner of
> complicated loops for what I require. It seems I keep coming back to
> this same issue.
>
> I have not yet looked at the ETL source (waiting for IT services to let
> me access the SVN), but would this fall within the scope of ETL?
>
> Would the ETL framework allow for a new equivalent() type method to be
> written which could return a duplicated collections of target objects
> from one set of source objects?
>
>
> Many Thanks,
>
> James
Re: one to many without using operations? [message #635922 is a reply to message #635916] Thu, 28 October 2010 15:42 Go to previous messageGo to next message
James Sharp is currently offline James Sharp
Messages: 20
Registered: September 2010
Junior Member
Hi dimitris,

I'm afriad this won't work as I don't know how many I will need, and I simply call the equivalent() method multiple times from different points in different rules.

Basically, my problem is this:

In this instance I have an if statement in my source language with multiple assignments inside. For my target language I must specify the assignment variable and then provide the if statement with the assignment value inside the if statement.

I have written rules which deal with the complexities of mapping my predicates for the if statements (there is also a direct if statement mapping which used these predicate rules before) but as the predicates are the same for all assignments within the if statement, then the predicate objects are only generated once by the rule. Furthermore I also need to check the else clause as this may potentially contain more new assignments.
I don't see how the suggested method works unless you know how many you need before firing the rule and I am doing this on the fly.

I think the method you have suggested would simply be overwritten each time for this scenario, is that correct?

Is there a way to make ETL forget it has already fired the rules associated with these source elements perhaps?

Many Thanks,

James
Re: one to many without using operations? [message #636273 is a reply to message #635922] Sat, 30 October 2010 08:50 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi James,

I think you're right; I now see your point. I guess the simplest thing
to do would be to add support for another annotation (e.g. @nocache) to
transformation rules which would make such rules forget any previous
invokations and return fresh results every time. Could you please file
an enhancement request for this in the bugzilla?

Cheers,
Dimitris

James Sharp wrote:
> Hi dimitris,
>
> I'm afriad this won't work as I don't know how many I will need, and I
> simply call the equivalent() method multiple times from different points
> in different rules.
>
> Basically, my problem is this:
>
> In this instance I have an if statement in my source language with
> multiple assignments inside. For my target language I must specify the
> assignment variable and then provide the if statement with the
> assignment value inside the if statement.
>
> I have written rules which deal with the complexities of mapping my
> predicates for the if statements (there is also a direct if statement
> mapping which used these predicate rules before) but as the predicates
> are the same for all assignments within the if statement, then the
> predicate objects are only generated once by the rule. Furthermore I
> also need to check the else clause as this may potentially contain more
> new assignments. I don't see how the suggested method works unless you
> know how many you need before firing the rule and I am doing this on the
> fly.
>
> I think the method you have suggested would simply be overwritten each
> time for this scenario, is that correct?
> Is there a way to make ETL forget it has already fired the rules
> associated with these source elements perhaps?
>
> Many Thanks,
>
> James
Previous Topic:Implicit Collect
Next Topic:Xtext editor for the E*L languages
Goto Forum:
  


Current Time: Sun Sep 21 10:18:28 GMT 2014

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

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