Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Map one object into two models
Map one object into two models [message #1699554] Thu, 25 June 2015 06:14 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Hi

For example I have ModelA, which contains ObjectA.
I need to map ObjectA into ObjectB. But the ObjectB must be contained in two output models ModelB1 and ModelB2.

For example the input model is UML class diagram. And the output models are several XML Schemas generated from one UML model.

The problem is that actually ObjectB is contained only in ModelB1, and the object is missing in ModelB2. I understand the cause of this behavior.
My mapping is executed only once for ModelB1:
mapping ObjectA::map() : ObjectB { }

And the copy ObjectB isn't created for ModelB2. Instead, the transformation gets the same ObjectB from the cache.

But I don't understand how to fix it. Could you guide me?

Thanks!
Re: Map one object into two models [message #1699555 is a reply to message #1699554] Thu, 25 June 2015 06:19 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
One solution is to replace all mappings by queries. But it seems too ugly.
Re: Map one object into two models [message #1699562 is a reply to message #1699555] Thu, 25 June 2015 07:05 Go to previous messageGo to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
The second solution is to execute transformation once for each output model. I think this is a preferred one...
Re: Map one object into two models [message #1699564 is a reply to message #1699562] Thu, 25 June 2015 07:29 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 260
Registered: April 2012
Senior Member
Indeed, running the transformation multiple times is a solution.

Instead of using queries, I think constructors would be the better solution. Constructors are there to construct unique objects.

Another option would be to add a dummy variable to the mapping, to make each call to the mapping unique.
Re: Map one object into two models [message #1699567 is a reply to message #1699554] Thu, 25 June 2015 07:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

Each output object must have a distinct identify where the identity is a
tuple of {Mapping, Input1, Input2, ...} so if you want multiple objects
you must ensure multiple identities, possibly just by adding a counter
as an input. I sometimes just add an additional 'disambiguator' object
input to make sure that each call is independent.

Regards

Ed Willink

On 25/06/2015 07:14, Denis Nikiforov wrote:
> Hi
>
> For example I have ModelA, which contains ObjectA.
> I need to map ObjectA into ObjectB. But the ObjectB must be contained
> in two output models ModelB1 and ModelB2.
>
> For example the input model is UML class diagram. And the output
> models are several XML Schemas generated from one UML model.
>
> The problem is that actually ObjectB is contained only in ModelB1, and
> the object is missing in ModelB2. I understand the cause of this
> behavior.
> My mapping is executed only once for ModelB1:
> mapping ObjectA::map() : ObjectB { }
> And the copy ObjectB isn't created for ModelB2. Instead, the
> transformation gets the same ObjectB from the cache.
>
> But I don't understand how to fix it. Could you guide me?
>
> Thanks!
Re: Map one object into two models [message #1699570 is a reply to message #1699567] Thu, 25 June 2015 08:11 Go to previous message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Great idea! Thanks!

I'm passing root object of the ouput model as additional input argument.
Previous Topic:Blackbox library in a standalone QVTo transformation
Next Topic:Run qvto transformation
Goto Forum:
  


Current Time: Fri Apr 19 23:07:55 GMT 2024

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

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

Back to the top