How to work with circular references? [message #85549] |
Tue, 01 July 2008 08:20  |
Eclipse User |
|
|
|
Hello,
I'm having some trouble with circular references lately. How do I cope
with the situation, that two output elements have references to the same
third element?
In one case it was like that:
Input model:
A
|-B
|-B
Mappings:
A to X
B to Y,Z
Output model:
X
|-Y--Z
|-Y-/
So that both Y-model elements have a reference to the same Z.
Is there declarative way to express that?
My only idea is to create a helper-method, which is called in Mapping B to
Y that checks if Z already exists. If Z exists, it returns it, if not, it
calls a lazy rule creating Z. Is this the way to go, or is there a better
way?
|
|
|
Re: How to work with circular references? [message #85614 is a reply to message #85549] |
Wed, 02 July 2008 03:39  |
Eclipse User |
|
|
|
Ok, I could write one B to Y,Z with the precondition, that the Z does not
exists and one B to Y rule with the precondition that Z does exists and
set the reference from B to the existing Z in the body of the rule. This
is a bit lengthy, because the B to Y rule does a lot. Maybe I can use
abstract rules and inheritance to eliminate the duplicate parts of the
rules.
> Hello,
> I'm having some trouble with circular references lately. How do I cope
> with the situation, that two output elements have references to the same
> third element?
> In one case it was like that:
> Input model:
> A
> |-B
> |-B
> Mappings:
> A to X
> B to Y,Z
> Output model:
> X
> |-Y--Z
> |-Y-/
> So that both Y-model elements have a reference to the same Z.
> Is there declarative way to express that?
> My only idea is to create a helper-method, which is called in Mapping B to
> Y that checks if Z already exists. If Z exists, it returns it, if not, it
> calls a lazy rule creating Z. Is this the way to go, or is there a better
> way?
|
|
|
Powered by
FUDForum. Page generated in 0.06280 seconds