|Re: [QVTO] creating recursive instances [message #500697 is a reply to message #500679]
||Fri, 27 November 2009 14:39
Originally posted by: dvorak.radek.gmail.com|
You have to options to solve your problem.
1) do not care if the the other referenced A instance has been
created or not and just call a mapping which should produce it.
If not yet created, it will be done by the mapping body execution,
if already created, it will just fetch the result from the previous
execution and return to the caller.
For detail understanding see the QVT OMC spec,
22.214.171.124 MappingOperation (sub-section "Execution Semantics")
2) you can use late resolve for the referenced target A-instance.
It's sort of forward relation to the target, where you say:
"I do not care if the result exist yet, but when it's ready
assign it here" ;)
See OMG spec,
8.1.10 Updating Objects and Resolving Object References
Why do we have 1) and 2) ?
As for case 1) you should not get a stack overflow as long as
you call the mapping recursively after the init section (may be implicit),
at which point the relation already holds and trace record exists.
If so, the mapping can't be reentered but the result is already
available. Do not be surprised that the caller gets an object which
changes later. But mainly, you get the result reference ;).
Wit 2) the result is not available at the time of the calling late resolve,
as the returned value is null when called. So it's primarily a reference
based mechanism used in conjunction with reference assignments.
The transformation engine can guarantee that the late resolution actual
result will be assigned to a target reference in the end of the
This approach is good if you really want to reflect the source objects
ordering in the target objects order.
Also, you can design your transf in multiple passes,
first create all A target instances and next connect its
references. With traces you can figure out which source has been mapped
to which target.
See OMG spec, "A.2.3 Uml to Rdbms" for inspiration.
All that is essential is to understand the mapping execution semantics
and how traces can be consulted using resolve. The rest is up to you
On Fri, 27 Nov 2009 14:45:03 +0100, Paul Klingelhuber <firstname.lastname@example.org>
> i'm trying to write a qvto transformation that creates an
> ecore-model-instance from another xml-based serialization.
> so i have a main ecore model (with which i want to work) and another one
> created from an xsd-file which represents the alternative serialization.
> my problem is that in the main ecore model there is a class 'A' which
> has references to other 'A's.
> in the alternative xml-serialization it might look like this:
> <A id="instance1" following="instance2" />
> <A id="instance5" following="instance2" />
> <A id="instance2" following="instance5" />
> i managed to write a transformation from the ecore model to this
> serialization form.
> my problem is that when i want to get from this xml model to the real
> ecore model i have to set references to the other A-instances...
> so when i create an instance for A with id "instance1" i need to set a
> reference to the A with id "instance2" but at this point i don't know if
> an A with instance2 has already been created.
> how do i find this out? and how do i then set the reference to it?
> my first idea was that i first create all A instances without their
> following-references set and then update them, but i'm also not really
> sure how to do that (the updating part, not the initial-creating)
> i hope you can see my problem and my explanations weren't too confusing
> :) if someone could help me, i would really appreciate it! thanks!
Powered by FUDForum
. Page generated in 0.02078 seconds