Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Mappings with non-model type context
[QVTO] Mappings with non-model type context [message #662617] Thu, 31 March 2011 10:03 Go to next message
Tassilo Horn is currently offline Tassilo Horn
Messages: 93
Registered: July 2009
Member
Hi all,

I've just found out that QVTo supports using OCL types as the context of
mappings, like:

--8<---------------cut here---------------start------------->8---
transformation Nix2Genealogy(out dst:Persons);
main() {
Set{1,2,3} -> map int2Genealogy();
Set{Set{"foo", "bar"},
Set{"foo", "foo"},
Set{"bar", "bar", "baz"},
Set{"foo"},
Set{"bar", "foo"}} -> map set2Male();
}

mapping Integer::int2Genealogy() : Persons::Genealogy {}
mapping Set(String)::set2Male() : Persons::Male {}
--8<---------------cut here---------------end--------------->8---

I think it's a nice feature. But is that conforming to the QVT spec?
Since that defines mappings in terms of relations, I somehow don't see
how that should match. For example, the second mapping operation above
would correspond to a relation:

--8<---------------cut here---------------start------------->8---
relation REL_set2Male {
checkonly domain:??? (self:Set(String))[]
enforce domain:dst (result:Persons::Male)[]
}
--8<---------------cut here---------------end--------------->8---

But I don't grasp the meaning of that relation. How can a relation hold
between a value (integer, set, whatsoever) and a model element?

Aside from the spec, I have another question. If I extend the example
above to this

--8<---------------cut here---------------start------------->8---
// add this to main():
// Set{1,2,3} -> map int2Female();

mapping Set(String)::set2Male() : Persons::Male {
// That does work
wife := 1.late resolveone(Female);
}
mapping Integer::int2Female() : Persons::Female {
// That does NOT work
// husband := Set{"foo", "foo"}.resolveone(Male);
}
--8<---------------cut here---------------end--------------->8---

why does the late resolve on 1 work indeed, but the other way round,
resolving a Male from a set for which a Male was created, does not work?

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: [QVTO] Mappings with non-model type context [message #663443 is a reply to message #662617] Tue, 05 April 2011 06:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4061
Registered: July 2009
Senior Member
Hi Tassilo

Since no one else is answering, I'll try.

I find the use of 'relations' in the QVTo spec very unhelpful; more of
an aspiration towards QVT commonality than a practice. The examples I've
looked at just make no sense at all.

So I think kooking for a consistency with relations is inappropriate.

"map" is a useful functionality between well-defined model types and
that is what you've discovered.

I've found it very difficult to get useful results from "resolve" so I
tend to maintain my own mapping Dict. So I'm afraid that I can't suggest
whether you problem is with your understanding, the QVTo implementation
or the QVTo specification.

Regards

Ed Willink


On 31/03/2011 11:03, Tassilo Horn wrote:
> Hi all,
>
> I've just found out that QVTo supports using OCL types as the context of
> mappings, like:
>
> --8<---------------cut here---------------start------------->8---
> transformation Nix2Genealogy(out dst:Persons);
> main() {
> Set{1,2,3} -> map int2Genealogy();
> Set{Set{"foo", "bar"},
> Set{"foo", "foo"},
> Set{"bar", "bar", "baz"},
> Set{"foo"},
> Set{"bar", "foo"}} -> map set2Male();
> }
>
> mapping Integer::int2Genealogy() : Persons::Genealogy {}
> mapping Set(String)::set2Male() : Persons::Male {}
> --8<---------------cut here---------------end--------------->8---
>
> I think it's a nice feature. But is that conforming to the QVT spec?
> Since that defines mappings in terms of relations, I somehow don't see
> how that should match. For example, the second mapping operation above
> would correspond to a relation:
>
> --8<---------------cut here---------------start------------->8---
> relation REL_set2Male {
> checkonly domain:??? (self:Set(String))[]
> enforce domain:dst (result:Persons::Male)[]
> }
> --8<---------------cut here---------------end--------------->8---
>
> But I don't grasp the meaning of that relation. How can a relation hold
> between a value (integer, set, whatsoever) and a model element?
>
> Aside from the spec, I have another question. If I extend the example
> above to this
>
> --8<---------------cut here---------------start------------->8---
> // add this to main():
> // Set{1,2,3} -> map int2Female();
>
> mapping Set(String)::set2Male() : Persons::Male {
> // That does work
> wife := 1.late resolveone(Female);
> }
> mapping Integer::int2Female() : Persons::Female {
> // That does NOT work
> // husband := Set{"foo", "foo"}.resolveone(Male);
> }
> --8<---------------cut here---------------end--------------->8---
>
> why does the late resolve on 1 work indeed, but the other way round,
> resolving a Male from a set for which a Male was created, does not work?
>
> Bye,
> Tassilo
Re: [QVTO] Mappings with non-model type context [message #663516 is a reply to message #663443] Tue, 05 April 2011 13:03 Go to previous message
Tassilo Horn is currently offline Tassilo Horn
Messages: 93
Registered: July 2009
Member
Ed Willink <ed@willink.me.uk> writes:

Hi Ed,

> I find the use of 'relations' in the QVTo spec very unhelpful; more of
> an aspiration towards QVT commonality than a practice. The examples
> I've looked at just make no sense at all.

Yes, I have the same impression. But if they had been consequent, they
would have specified QVTo with Relations, Relations with Core, and Core
with QVTo, in order to get a nice, mutually recursive specification.
;-)

> So I think kooking for a consistency with relations is inappropriate.

Agreed.

> "map" is a useful functionality between well-defined model types and
> that is what you've discovered.

Yeah, but then, why is Integer well-defined, but Set(String) is not?

> I've found it very difficult to get useful results from "resolve" so I
> tend to maintain my own mapping Dict.

Really? IMO, automatic source <-> target mappings with resolving
functionality is one of the most important concepts of model
transformations. I mean, if I have to maintain those myself, I could
stick to plain Java (or whatsoever) and Map<Object, Object>.

> So I'm afraid that I can't suggest whether you problem is with your
> understanding, the QVTo implementation or the QVTo specification.

Ok, thanks anyway.

What I am really looking for is a statement from a QVTo dev, like

a) It's not really backed by the spec. That it works for Integers is
a coincidence you should not rely on.

b) It's not really backed by the spec, but we think it's useful. The
failing resolution for Sets is a bug.

c) ...

Bye,
Tassilo

> On 31/03/2011 11:03, Tassilo Horn wrote:
>> Hi all,
>>
>> I've just found out that QVTo supports using OCL types as the context of
>> mappings, like:
>>
>> --8<---------------cut here---------------start------------->8---
>> transformation Nix2Genealogy(out dst:Persons);
>> main() {
>> Set{1,2,3} -> map int2Genealogy();
>> Set{Set{"foo", "bar"},
>> Set{"foo", "foo"},
>> Set{"bar", "bar", "baz"},
>> Set{"foo"},
>> Set{"bar", "foo"}} -> map set2Male();
>> }
>>
>> mapping Integer::int2Genealogy() : Persons::Genealogy {}
>> mapping Set(String)::set2Male() : Persons::Male {}
>> --8<---------------cut here---------------end--------------->8---
>>
>> I think it's a nice feature. But is that conforming to the QVT spec?
>> Since that defines mappings in terms of relations, I somehow don't see
>> how that should match. For example, the second mapping operation above
>> would correspond to a relation:
>>
>> --8<---------------cut here---------------start------------->8---
>> relation REL_set2Male {
>> checkonly domain:??? (self:Set(String))[]
>> enforce domain:dst (result:Persons::Male)[]
>> }
>> --8<---------------cut here---------------end--------------->8---
>>
>> But I don't grasp the meaning of that relation. How can a relation hold
>> between a value (integer, set, whatsoever) and a model element?
>>
>> Aside from the spec, I have another question. If I extend the example
>> above to this
>>
>> --8<---------------cut here---------------start------------->8---
>> // add this to main():
>> // Set{1,2,3} -> map int2Female();
>>
>> mapping Set(String)::set2Male() : Persons::Male {
>> // That does work
>> wife := 1.late resolveone(Female);
>> }
>> mapping Integer::int2Female() : Persons::Female {
>> // That does NOT work
>> // husband := Set{"foo", "foo"}.resolveone(Male);
>> }
>> --8<---------------cut here---------------end--------------->8---
>>
>> why does the late resolve on 1 work indeed, but the other way round,
>> resolving a Male from a set for which a Male was created, does not work?
>>
>> 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 |
Previous Topic:[ATL] EsuperTypes and references
Next Topic:M2M gmftools
Goto Forum:
  


Current Time: Thu Oct 02 10:45:47 GMT 2014

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

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