[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: How to work with circular references?

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?