Skip to main content



      Home
Home » Modeling » QVT-OML » Qualified name of reference
Qualified name of reference [message #1850339] Fri, 25 February 2022 08:56 Go to next message
Eclipse UserFriend
Hi all,

I am writing some transformations in QVTo, and I have the following scenario.


In target metamodel I have a concept ConceptA referencing ConceptA1 (reference is named "a2a1"), where concept A1 has attribute name.
In source metamodel I have a concept ConceptB with attribute name.
I am writing a mapping rule:

mapping ConceptA :: conceptA2conceptB : ConceptB {
// and here I want to assign the name of concept A1 to B and I write the following:
result. name := self.a2a1.name;
}

It work this way, but I want wondering if there is another way on how to write this. Maybe something where I could only write:

result. name := self.name;

And this could be contained somewhere ...

Many thanks!
Re: Qualified name of reference [message #1850344 is a reply to message #1850339] Fri, 25 February 2022 10:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The 'obvious' answer is to use a different mapping signature so that the new 'self' is the old 'self.a2a1'. For a single problem this might just make sense, but it is very unlikely to scale unless ConceptA and ConceptB are almost topologically identical.

An M2M is usually transforming models that are in some way different, and so you must expect to use computations/navigations to resolve the differences. Hiding the differences behind perverse mapping signatures will make your transformation less rather than more readable.

Regards

Ed Willink
Re: Qualified name of reference [message #1850345 is a reply to message #1850344] Fri, 25 February 2022 11:39 Go to previous message
Eclipse UserFriend
Ed Willink wrote on Fri, 25 February 2022 10:53
The 'obvious' answer is to use a different mapping signature so that the new 'self' is the old 'self.a2a1'.
Exactly. Thus you should map both A and A2 to B. Such n:1 mappings can be realized using init sections:

mapping ConceptA :: conceptA2conceptB : ConceptB {
    init {
        result := self.a2a1.map conceptA12conceptB();
    }
}

mapping ConceptA1 :: conceptA12conceptB : ConceptB {
    result.name := self.name;
}

[Updated on: Fri, 25 February 2022 12:08] by Moderator

Previous Topic:Mono and multi valued attributes
Next Topic:Conditional mappings
Goto Forum:
  


Current Time: Fri Jul 11 23:00:11 EDT 2025

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

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

Back to the top