Home » Archived » M2M (model-to-model transformation) » [QVT Relations] Set-valued references
[QVT Relations] Set-valued references [message #643820] |
Wed, 08 December 2010 11:57 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
Hi again,
after solving my former problem, now I'm stuck when trying to set
Set-valued references. My target abstract Person class has an ordered
set of parents (a Female and a Male).
Again, I have a query that returns the 2 source Members that are that
are the parents in the source model, but I have no idea how to resolve
them to their target Person objects...
--8<---------------cut here---------------start------------->8---
top relation Member2Female {
hb : persons::Male;
checkonly domain fam member: families::Member {};
enforce domain per female: persons::Female {
husband = hb,
-- How do I set the parents? I have parents(member) that returns
-- the 2 source Members, but what then?
parents = ???
};
when {
isFemale(member);
-- If that member has a spouse, then set the bidirectional
-- reference husband.
spouse(member).oclIsUndefined() or Member2Male(spouse(member), hb);
}
where {
Member2Person(member, female);
}
}
--8<---------------cut here---------------end--------------->8---
What I basically want to say is:
when {
parents(member)->forAll(p | Member2Person(p, parent))
^^^^^^
}
and when combining the underlined variable values, that would be my set
of target parents. But how do I express that syntactically correct?
Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
|
|
|
[QVT Relations] Criticize my Families to Genealogy transformation (was: [QVT Relations] Set-valued r [message #643918 is a reply to message #643820] |
Wed, 08 December 2010 16:46 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
Hi again,
I finally managed to set the references properly, and now the
transformation works.
I've posted the complete transformation including images of source and
target metamodels at http://projects.ikv.de/qvt/discussion/1/122
If someone wants to do me a favour, I'd be very happy to receive some
criticisms and improvement suggestions, either here, per mail, or in the
forum above. Especially, I've bended over backwards when trying to
encode target objects corresponding to source objects by using
when/where clauses, while setting the husband and parents references.
I guess, I'm just not used to thinking in Relations right now. But is
there some mental model that guides one when writing a Relations
transformation? For example, with QVTO I somehow align my mappings
according to the containment hierarchy, do dispatching with disjunction,
abstract away setting inherited properties with mapping inheritance, and
freely refer to elements created by other mappings by means of [late]
resolve[one](). With Relations, I just fiddle around until it works...
Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
|
|
|
Re: [QVT Relations] Criticize my Families to Genealogy transformation [message #643919 is a reply to message #643918] |
Wed, 08 December 2010 16:57 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Tassilo
QVTr certainly needs a different way of thinking.
I don't find QVTo very natural for non-trivial transformations.
I found the only way I could get a grip of a non-trivial pattern was to
express it graphically using my UMLX notation (don't ask when that will
be released). This could then be transliterated to QVTo relatively
easily, and I suspect to QVTr even more easily.
The correct approach will depend on the problem. Once you have a
complicated pattern, graphics wins.
Regards
Ed Willink
On 08/12/2010 16:46, Tassilo Horn wrote:
> Hi again,
>
> I finally managed to set the references properly, and now the
> transformation works.
>
> I've posted the complete transformation including images of source and
> target metamodels at http://projects.ikv.de/qvt/discussion/1/122
>
> If someone wants to do me a favour, I'd be very happy to receive some
> criticisms and improvement suggestions, either here, per mail, or in the
> forum above. Especially, I've bended over backwards when trying to
> encode target objects corresponding to source objects by using
> when/where clauses, while setting the husband and parents references.
>
> I guess, I'm just not used to thinking in Relations right now. But is
> there some mental model that guides one when writing a Relations
> transformation? For example, with QVTO I somehow align my mappings
> according to the containment hierarchy, do dispatching with disjunction,
> abstract away setting inherited properties with mapping inheritance, and
> freely refer to elements created by other mappings by means of [late]
> resolve[one](). With Relations, I just fiddle around until it works...
>
> Bye,
> Tassilo
|
|
|
Re: [QVT Relations] Criticize my Families to Genealogy transformation [message #643945 is a reply to message #643919] |
Wed, 08 December 2010 19:07 |
Fabio L. S. Messages: 15 Registered: July 2010 Location: Brazil |
Junior Member |
|
|
Hi Ed;
It's strange... I have the opposite impression of QVTr and QVTo. As an OO programmer, creating a QVTo code seemed to be much easier than a QVTr code. I recently created a 1600 lines of QVTr code, using Medini QVT, and then ported (with some modifications) to QVTo, using M2M Operational QVT. QVTo has some elements that allowed to use my "OO way of thinking", while I struggled for some time until I finally got (or think I got) the "relations way of thinking". Maybe this happened because I am an occasional QVT user...
Finally, I will take this opportunity to say that if someone is in doubt to use QVTr or QVTo, I highly recommend using QVTo. Besides the language difference, Medini QVT, which is a fantastic tool, is nowadays not as good as M2M Operational QVT. For instance, the debug function in Operational QVT goes inside queries, and it is possible to declare variables inside queries. This makes a *huge* difference in bigger transformations.
Regards;
Fábio L. S.
|
|
| |
Re: [QVT Relations] Criticize my Families to Genealogy transformation [message #643958 is a reply to message #643919] |
Wed, 08 December 2010 19:50 |
Tassilo Horn Messages: 93 Registered: July 2009 |
Member |
|
|
Ed Willink <ed@willink.me.uk> writes:
Hi Ed,
> QVTr certainly needs a different way of thinking.
Yes, but which?
> I don't find QVTo very natural for non-trivial transformations.
Correct, but on the other hand, I don't find QVTr very natural even for
trivial transformations. ;-)
> I found the only way I could get a grip of a non-trivial pattern was
> to express it graphically using my UMLX notation (don't ask when that
> will be released). This could then be transliterated to QVTo
> relatively easily, and I suspect to QVTr even more easily.
>
> The correct approach will depend on the problem. Once you have a
> complicated pattern, graphics wins.
Well, I guess here I disagree. It might be good to use pen and paper to
think about a problem, but once you've gotten it there should be no
hindrance to formulate it textually, too.
IMO, visual (programming, transformation,...) languages will never
really fly, even if it's only cause Emacs can't tackle them (yet). ;-)
Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
|
|
|
Goto Forum:
Current Time: Fri Apr 26 08:58:14 GMT 2024
Powered by FUDForum. Page generated in 0.03422 seconds
|