Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » A case scenario regarding the selection of mappings based on composed model elements
A case scenario regarding the selection of mappings based on composed model elements [message #1061280] Thu, 30 May 2013 23:06 Go to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello!

Following is the situation:

Model Element A has an other model element B in it. Is is defined as a composition. And both of them are again composed by a main model element M. The B generally is optional in this situation, but might appear. So it is either M -> A -> B or only M -> A. (Please note, this isn't inheritance.)

So based on both options, in this case whether the last model element B is created in the source model instance or not, a certain corresponding mapping should be chosen. One of them eventually transforms A and B into something, and the other mapping transforms only A into something else. (Transformation of M is no matter.)

M-A-B -> Mapping 1 -> X-Y-Z-T....

M-A -> Mapping 2 -> K-L

So which mapping should be chosen depends on the existence check of source model element B. And I am guessing I can do this in the mapping definition of the first source model element M. But the question is: How?

OCL comes into my mind, but I only know some ways of checking the inheritance relation between model elements, not the composition.

I will be very thankful, if you could help me!

Best regards,
Emre

[Updated on: Thu, 30 May 2013 23:07]

Report message to a moderator

Re: A case scenario regarding the selection of mappings based composed model elements [message #1061300 is a reply to message #1061280] Fri, 31 May 2013 05:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
On 31/05/2013 00:06, Emre Taspolatoglu wrote:
> OCL comes into my mind, but I only know some ways of checking the
> inheritance relation between model elements, not the composition.

Indeed, use an OCL expression in a guard comparing the ptoperty value to
null.

Regards

Ed Willink
Re: A case scenario regarding the selection of mappings based composed model elements [message #1061326 is a reply to message #1061300] Fri, 31 May 2013 08:45 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hmm, that isn't so clear to me right know.

You mean any property value of B, right? Could you please give a little code snippet?

Thanks!

Re: A case scenario regarding the selection of mappings based composed model elements [message #1061434 is a reply to message #1061326] Fri, 31 May 2013 15:31 Go to previous messageGo to next message
Adolfo Sanchez-Barbudo Herrera is currently offline Adolfo Sanchez-Barbudo HerreraFriend
Messages: 260
Registered: July 2009
Senior Member
By some reasons, replying via newsgroup didn't update the forum.... I should have done something wrong

Replying via Web browser:

Cheers,
Adolfo.
----
Hi Emre,

Something like the following

mapping M::mappingMA () : Something
when {self.refToA.refToB.oclIsUndefined()} ...

mapping M::mappingMAB () : Something
when {not self.refToA.refToB.oclIsUndefined()} ...

Note that if M doesn't contain any A self.refToA may be invalid, then making the guard evaluate to true ( OclInvalid.oclIsUndefined() = true), so you should probably require a more elaborated guard.

Take into account that you need a joint-point mapping which diverges against those two mappings (Again, review disjunct mapping semantics in the specification). For this example, something like:

mapping M::mappingM () : Something
disjunct mappingMA, mappingMAB
when {not self.refToA.oclIsUndefined()} // A way to partially solve the note I mentioned above

Cheers,
Adolfo.
Re: A case scenario regarding the selection of mappings based composed model elements [message #1061474 is a reply to message #1061434] Fri, 31 May 2013 20:05 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hi Adolfo,

your tips were very helpful. It wasn't clear me enough, which OCL constructs I needed use for the purpose. And the disjuncts was of course no success without the correct when-logic.

Again thanks a lot!

Emre
Re: A case scenario regarding the selection of mappings based composed model elements [message #1061490 is a reply to message #1061280] Sat, 01 June 2013 00:14 Go to previous message
Alan McMorran is currently offline Alan McMorranFriend
Messages: 55
Registered: July 2009
Member
Emre,

If I understand you correctly, with QVTO you can put conditions on the
mapping so in your example, assuming the source model is SOURCE and
we're mapping to a raget model TARGET, you could have something like:

mapping SRC::M::toX() : TARGET::X
when{not self.A.B.oclIsUndefined()}{

// Then within here you can create Y, Z and T objects

}

mapping SRC::M::toK() : TARGET::K
when{self.A.B.oclIsUndefined()}{

// Then do your mapping and create L as well
}

In your main, assuming an input parameter src you can do:

main(){
src.objectsOfType(SRC::M).map toX();
src.objectsOfType(SRC::M).map toK();
}

And the when statements will mean only those instances of M that mee
the where conditions for each mapping are mapped.

Alan

On 2013-05-30 23:06:47 +0000, Emre Taspolatoglu said:

> Hello!
>
> Following is the situation:
>
> Model Element A has an other model element B in it. Is is defined as a
> composition. And both of them are again composed by a main model
> element M. The B generally is optional in this situation, but might
> appear. So it is either M -> A -> B or only M -> A. (Please note, this
> isn't inheritance.)
>
> So based on both options, in this case whether the last model element B
> is created in the source model instance or not, a certain corresponding
> mapping should be chosen. One of them eventually transforms A and B
> into something, and the other mapping transforms only A into something
> else. (Transformation of M is no matter.)
>
> M-A-B -> Mapping 1 -> X-Y-Z-T....
>
> M-A -> Mapping 2 -> K-L
>
> So which mapping should be chosen depends on the existence check of
> source model element B. And I am guessing I can do this in the mapping
> definition of the first source model element M. But the question is:
> How?
> OCL comes into my mind, but I only know some ways of checking the
> inheritance relation between model elements, not the composition.
>
> I will be very thankful, if you could help me!
>
> Best regards,
> Emre
Previous Topic:how to use two target sources?
Next Topic:Jumping over abstract model elements of source
Goto Forum:
  


Current Time: Fri Apr 19 23:13:12 GMT 2024

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

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

Back to the top