Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] when condition in abstract mapping
[QVTo] when condition in abstract mapping [message #794563] Thu, 09 February 2012 12:52 Go to next message
Bart Theelen is currently offline Bart Theelen
Messages: 20
Registered: February 2012
Junior Member
Being new to QVTo, I was creating a MTM transformation using the following concept:

abstract mapping InModel::InType::Transformation() : OutModel::OutType
   when { Condition } {
       DoSomethingUsefull
}

mapping InModel::InInheritedType1::Transformation1() : OutModel::OutInheritedType1
   inherits InModel::InType::Transformation() {
      DoSomeExtraThings1
}

mapping InModel::InInheritedType2::Transformation2() : OutModel::OutInheritedType2
   inherits InModel::InType::Transformation() {
      DoSomeExtraThings2
}


My expectation was that objects of OutModel::OutInheritedType1
and OutModel::OutInheritedType2 would not be created in case the Condition for the respective input objects does not hold. Instead, the objects are created but none of the DoSome... pieces are executed. Is this what I should be expecting?

To resolve the situation into what I wanted, I had to move&copy the Condition to the non-abstract mappings as follows:

abstract mapping InModel::InType::Transformation() : OutModel::OutType {
       DoSomethingUsefull
}

mapping InModel::InInheritedType1::Transformation1() : OutModel::OutInheritedType1
   inherits InModel::InType::Transformation()
   when { Condition } {
      DoSomeExtraThings1
}

mapping InModel::InInheritedType2::Transformation2() : OutModel::OutInheritedType2
   inherits InModel::InType::Transformation()
   when { Condition } {
      DoSomeExtraThings2
}


I am actually looking for a good reference that explains the syntax and semantics of all QVTo primitives. Any suggestions?
Re: [QVTo] when condition in abstract mapping [message #794816 is a reply to message #794563] Thu, 09 February 2012 18:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi Bart

I am not aware of any better source than the QVT specification which is
far from clear in many places.

QVTo provides a very helpful example project with comments.

Have you tried "disjuncts"?

Regards

Ed Willink


On 09/02/2012 12:52, Bart Theelen wrote:
> Being new to QVTo, I was creating a MTM transformation using the
> following concept:
>
>
> abstract mapping InModel::InType::Transformation() : OutModel::OutType
> when { Condition } {
> DoSomethingUsefull
> }
>
> mapping InModel::InInheritedType1::Transformation1() :
> OutModel::OutInheritedType1
> inherits InModel::InType::Transformation() {
> DoSomeExtraThings1
> }
>
> mapping InModel::InInheritedType2::Transformation2() :
> OutModel::OutInheritedType2
> inherits InModel::InType::Transformation() {
> DoSomeExtraThings2
> }
>
>
> My expectation was that objects of OutModel::OutInheritedType1
> and OutModel::OutInheritedType2 would not be created in case the
> Condition for the respective input objects does not hold. Instead, the
> objects are created but none of the DoSome... pieces are executed. Is
> this what I should be expecting?
>
> To resolve the situation into what I wanted, I had to move&copy the
> Condition to the non-abstract mappings as follows:
>
>
> abstract mapping InModel::InType::Transformation() : OutModel::OutType {
> DoSomethingUsefull
> }
>
> mapping InModel::InInheritedType1::Transformation1() :
> OutModel::OutInheritedType1
> inherits InModel::InType::Transformation()
> when { Condition } {
> DoSomeExtraThings1
> }
>
> mapping InModel::InInheritedType2::Transformation2() :
> OutModel::OutInheritedType2
> inherits InModel::InType::Transformation()
> when { Condition } {
> DoSomeExtraThings2
> }
>
>
> I am actually looking for a good reference that explains the syntax
> and semantics of all QVTo primitives. Any suggestions?
Re: [QVTo] when condition in abstract mapping [message #795302 is a reply to message #794816] Fri, 10 February 2012 10:00 Go to previous messageGo to next message
Bart Theelen is currently offline Bart Theelen
Messages: 20
Registered: February 2012
Junior Member
Thanks for the pointer to the specification, but unfortunately it does not seem to explain the sketched case. I did find something about using xmap instead of map when calling the mapping functions, but that makes no difference.

I would however like to understand why my intuition is wrong. I think that I basically expected that the following piece of code:

abstract mapping InModel::InType::Transformation() : OutModel::OutType
   when { Condition1 } {
      DoSomethingUsefull
}

mapping InModel::InInheritedType::TransformationX() : OutModel::OutInheritedType
   inherits InModel::InType::Transformation()
   when { Condition2 } {
      DoSomeExtraThings
}


is semantically equivalent to this piece of code:

mapping InModel::InInheritedType::TransformationY() : OutModel::OutInheritedType
   when { Condition1 and Condition2 } {
      DoSomethingUsefull;
      DoSomeExtraThings
}


But apparently I am wrong or I used the wrong constructs? Any ideas?

[Updated on: Fri, 10 February 2012 11:45]

Report message to a moderator

Re: [QVTo] when condition in abstract mapping [message #795370 is a reply to message #795302] Fri, 10 February 2012 11:42 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi Bart

With QVT, you are rather at the cutting edge and so you always need to
consider

is the programmer's expectation wrong
is the programmer's exposition wrong
is the QVTo tool wrong
is the QVTo specification wrong

I've certainly found areas that I find suspect in the tool and vague at
best in the specification. I therefore use a subset of the capabilities
that I'm comfortable with.

Where you think that the specification is inadequate you can submit an
issue to issues@omg.org, prefixing the messages with e.g. QVT 1.1 8.2
..... to identify that clause 8.2 is the target of your comment.

I hope that some progress will be made in the next few years so that
QVTo and r and c all start to improve. Perhaps you would like to join
the effort...

Regards

Ed Willink

On 10/02/2012 10:00, Bart Theelen wrote:
> Thanks for the pointer to the specification, but unfortunately it does
> not seem to explain the sketched case. I did find something about
> using xmap instead of map when calling the mapping functions, but that
> makes no difference.
>
> I would however like to understand why my intuition is wrong. I think
> that I basically expected that the following piece of code:
>
>
> abstract mapping InModel::InType::Transformation() : OutModel::OutType
> when { Condition 1 } {
> DoSomethingUsefull
> }
>
> mapping InModel::InInheritedType::TransformationX() :
> OutModel::OutInheritedType
> inherits InModel::InType::Transformation()
> when { Condition 2 } {
> DoSomeExtraThings
> }
>
>
> is semantically equivalent to this piece of code:
>
>
> mapping InModel::InInheritedType::TransformationY() :
> OutModel::OutInheritedType
> when { Condition1 and Condition2 } {
> DoSomethingUsefull;
> DoSomeExtraThings
> }
>
>
> But apparently I am wrong or I used the wrong constructs? Any ideas?
Previous Topic:[QVTrelational] How to use Keys to preserve graph structure
Next Topic:Bidirectional transformation
Goto Forum:
  


Current Time: Fri Sep 19 19:58:33 GMT 2014

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

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