Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Qualified name of reference
Qualified name of reference [message #1850339] Fri, 25 February 2022 13:56 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
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 15:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 16:39 Go to previous message
Christopher Gerking is currently offline Christopher GerkingFriend
Messages: 115
Registered: April 2011
Senior Member
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 17:08]

Report message to a moderator

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


Current Time: Wed Apr 24 15:05:31 GMT 2024

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

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

Back to the top