Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] disjunct and inherits problems
[QVTO] disjunct and inherits problems [message #93570] Wed, 29 October 2008 03:08 Go to next message
Matthew Watson is currently offline Matthew WatsonFriend
Messages: 24
Registered: July 2009
Junior Member
Hi,

I am trying to implement a transformation. We have a reference to an
abstract base type but need to resolve it to a mapping to a concrete
instance.

To do this, I was trying to use a disjunct mapping (from 8.1.3 of the QVT
spec) but this results in the error: 'Result and out parameters of
abstract types must be explicitly instantiated in the init-section!' on
the mapping itself and '"Tuple" expected instead of "toC"' on the final
mapping of the disjuncts list (which is toC).

Are disjuncts implemented in QVTO (Ganymede)?

The mappings themselves I was trying to write with a base class mapping
for the A->B mapping and sepecific mappings for the A->C, and A->D
mappings (where C & D are the conrete types extending the abstract B).
When I try this, I get the 'Result and out parameters of abstract types
must be explicitly instantiated in the init-section!' error on the base
mapping (A->B) and the concrete type mappings get the error "Unresolved
mapping operation reference 'toB'".

Are inheritance of mappings supported and how can I implement a reusable
mapping to a base type which is only ever extended by concrete type
mappings?

Thanks,
Matt
Re: [QVTO] disjunct and inherits problems [message #93597 is a reply to message #93570] Wed, 29 October 2008 09:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mahdider.students.uni-mainz.de

Hi Matt,

did you actually try to start with something like

init {
result := instanceType;
}

in your mapping? I assume you define the return type using the abstract
type? In this case, result really needs to point to a valid instantiable
type, as far as I know.

I don't exactly know the code and I did not try disjuncts in QVT up to
now. Just an idea... :)

Regards,
Mahdi D-Manesh


Matthew Watson schrieb:
> Hi,
>
> I am trying to implement a transformation. We have a reference to an
> abstract base type but need to resolve it to a mapping to a concrete
> instance.
>
> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
> QVT spec) but this results in the error: 'Result and out parameters of
> abstract types must be explicitly instantiated in the init-section!' on
> the mapping itself and '"Tuple" expected instead of "toC"' on the final
> mapping of the disjuncts list (which is toC).
>
> Are disjuncts implemented in QVTO (Ganymede)?
>
> The mappings themselves I was trying to write with a base class mapping
> for the A->B mapping and sepecific mappings for the A->C, and A->D
> mappings (where C & D are the conrete types extending the abstract B).
> When I try this, I get the 'Result and out parameters of abstract types
> must be explicitly instantiated in the init-section!' error on the base
> mapping (A->B) and the concrete type mappings get the error "Unresolved
> mapping operation reference 'toB'".
>
> Are inheritance of mappings supported and how can I implement a reusable
> mapping to a base type which is only ever extended by concrete type
> mappings?
>
> Thanks,
> Matt
>
Re: [QVTO] disjunct and inherits problems [message #93610 is a reply to message #93597] Wed, 29 October 2008 09:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Alexander.Igdalov.borland.com

Thanks Mahdi! That's the first thing that comes in to my mind too.
Matt, could you please post your script?

Best,
Alex.

Mahdi D-Manesh wrote:
> Hi Matt,
>
> did you actually try to start with something like
>
> init {
> result := instanceType;
> }
>
> in your mapping? I assume you define the return type using the abstract
> type? In this case, result really needs to point to a valid instantiable
> type, as far as I know.
>
> I don't exactly know the code and I did not try disjuncts in QVT up to
> now. Just an idea... :)
>
> Regards,
> Mahdi D-Manesh
>
>
> Matthew Watson schrieb:
>> Hi,
>>
>> I am trying to implement a transformation. We have a reference to an
>> abstract base type but need to resolve it to a mapping to a concrete
>> instance.
>>
>> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
>> QVT spec) but this results in the error: 'Result and out parameters of
>> abstract types must be explicitly instantiated in the init-section!'
>> on the mapping itself and '"Tuple" expected instead of "toC"' on the
>> final mapping of the disjuncts list (which is toC).
>>
>> Are disjuncts implemented in QVTO (Ganymede)?
>>
>> The mappings themselves I was trying to write with a base class
>> mapping for the A->B mapping and sepecific mappings for the A->C, and
>> A->D mappings (where C & D are the conrete types extending the
>> abstract B). When I try this, I get the 'Result and out parameters of
>> abstract types must be explicitly instantiated in the init-section!'
>> error on the base mapping (A->B) and the concrete type mappings get
>> the error "Unresolved mapping operation reference 'toB'".
>>
>> Are inheritance of mappings supported and how can I implement a
>> reusable mapping to a base type which is only ever extended by
>> concrete type mappings?
>>
>> Thanks,
>> Matt
>>
Re: [QVTO] disjunct and inherits problems [message #93674 is a reply to message #93570] Wed, 29 October 2008 10:18 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Matt,

Yes, we do implement disjuncts.

Those mappings that return an abstract class but are rather defined for
extension then
for its own execution should be defined as 'abstract'.

See the 'UML::UseCase::createCommonWorkDefinition' mapping operation in
the spec example
A2.4 SPEM UML Profile to SPEM metamodel
(Note: there is a typo in the spec, 'mapping abstract ...' => 'abstract
mapping ...')

Once defined as abstract, other mappings may 'inherit' from this mapping,
but it can not be call directly as we can not implicitly instantiate an
abstract class.
However, you can do so explicitly in the init {} section, as suggested.


Regards,
/Radek



On Wed, 29 Oct 2008 04:08:23 +0100, Matthew Watson
<matthew-j.watson@db.com> wrote:

> Hi,
>
> I am trying to implement a transformation. We have a reference to an
> abstract base type but need to resolve it to a mapping to a concrete
> instance.
>
> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
> QVT spec) but this results in the error: 'Result and out parameters of
> abstract types must be explicitly instantiated in the init-section!' on
> the mapping itself and '"Tuple" expected instead of "toC"' on the final
> mapping of the disjuncts list (which is toC).
>
> Are disjuncts implemented in QVTO (Ganymede)?
>
> The mappings themselves I was trying to write with a base class mapping
> for the A->B mapping and sepecific mappings for the A->C, and A->D
> mappings (where C & D are the conrete types extending the abstract B).
> When I try this, I get the 'Result and out parameters of abstract types
> must be explicitly instantiated in the init-section!' error on the base
> mapping (A->B) and the concrete type mappings get the error "Unresolved
> mapping operation reference 'toB'".
>
> Are inheritance of mappings supported and how can I implement a reusable
> mapping to a base type which is only ever extended by concrete type
> mappings?
>
> Thanks,
> Matt
>
Re: [QVTO] disjunct and inherits problems [message #93939 is a reply to message #93674] Thu, 30 October 2008 04:37 Go to previous messageGo to next message
Matthew Watson is currently offline Matthew WatsonFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks, that was what I needed - I see some of the examples are not the
same as the impl - I finally got my disjuncts and inherits to work by
fully qualifying the name - in the examples in the OMG spec, they are not
fully qualified.

I downloaded 3.5M2 and QVTO 2.0.0M2 and found some changes to what I
expected.

To get around my EBigDecimal (impl class BigDecimal) -> PositiveDecimal
(impl class BigDecimal) conversion problem, I had been using

posDecField := ebigDecimalField.oclAsType(X::Y::PositiveDecimal)

which was doing the trick in stock eclipse 3.4.1 release.

This no longer works in the dev builds of 2.0.0M2, instead I get the error:

The type 'X::Y::PositiveDecimal' does not conform to the type
'oclstdlib::Real' of the property 'posDecField'

I can however simply assign one from the other and it runs just fine. Did
you fix that bug for M2?

Thanks,
Matt

Radek Dvorak wrote:

> Hi Matt,

> Yes, we do implement disjuncts.

> Those mappings that return an abstract class but are rather defined for
> extension then
> for its own execution should be defined as 'abstract'.

> See the 'UML::UseCase::createCommonWorkDefinition' mapping operation in
> the spec example
> A2.4 SPEM UML Profile to SPEM metamodel
> (Note: there is a typo in the spec, 'mapping abstract ...' => 'abstract
> mapping ...')

> Once defined as abstract, other mappings may 'inherit' from this mapping,
> but it can not be call directly as we can not implicitly instantiate an
> abstract class.
> However, you can do so explicitly in the init {} section, as suggested.


> Regards,
> /Radek



> On Wed, 29 Oct 2008 04:08:23 +0100, Matthew Watson
> <matthew-j.watson@db.com> wrote:

>> Hi,
>>
>> I am trying to implement a transformation. We have a reference to an
>> abstract base type but need to resolve it to a mapping to a concrete
>> instance.
>>
>> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
>> QVT spec) but this results in the error: 'Result and out parameters of
>> abstract types must be explicitly instantiated in the init-section!' on
>> the mapping itself and '"Tuple" expected instead of "toC"' on the final
>> mapping of the disjuncts list (which is toC).
>>
>> Are disjuncts implemented in QVTO (Ganymede)?
>>
>> The mappings themselves I was trying to write with a base class mapping
>> for the A->B mapping and sepecific mappings for the A->C, and A->D
>> mappings (where C & D are the conrete types extending the abstract B).
>> When I try this, I get the 'Result and out parameters of abstract types
>> must be explicitly instantiated in the init-section!' error on the base
>> mapping (A->B) and the concrete type mappings get the error "Unresolved
>> mapping operation reference 'toB'".
>>
>> Are inheritance of mappings supported and how can I implement a reusable
>> mapping to a base type which is only ever extended by concrete type
>> mappings?
>>
>> Thanks,
>> Matt
>>
Re: [QVTO] disjunct and inherits problems [message #93954 is a reply to message #93610] Thu, 30 October 2008 04:41 Go to previous messageGo to next message
Matthew Watson is currently offline Matthew WatsonFriend
Messages: 24
Registered: July 2009
Junior Member
Thanks Guys,

I solved the problem. I had to make the mapping abstract so it won't try
to create a result, since its converting to an abstract base type and the
disjuncts mapping will call the correct top-level mapping.

The other problem I had was in not fully qualifying the name of the
mappings - the OMG examples in the spec are not fully quilified, but the
impl requires it.


All works now.

My script (Where Y&Z extend X and X is abstract):


modeltype IN uses 'platform:/resource/qvtTest/IN.ecore';
modeltype OUT uses 'platform:/resource/qvtTest/OUT.ecore';

transformation In2OUT(in i : IN, out o : OUT);

main() {
i.rootObjects()[A]->map toX();
}

abstract mapping A::toBase() : X
{
name := self.name;
}

mapping A::toY() : Y
inherits A::toBase
when { self.name.match('Y') }
{
count := self.count;
owner := self.owner;
}

mapping A::toZ() : Z
inherits A::toBase
{
type := self.type;
}

mapping A::toX() : X
disjuncts A::toY,A::toZ {}




Alexander Igdalov wrote:

> Thanks Mahdi! That's the first thing that comes in to my mind too.
> Matt, could you please post your script?

> Best,
> Alex.

> Mahdi D-Manesh wrote:
>> Hi Matt,
>>
>> did you actually try to start with something like
>>
>> init {
>> result := instanceType;
>> }
>>
>> in your mapping? I assume you define the return type using the abstract
>> type? In this case, result really needs to point to a valid instantiable
>> type, as far as I know.
>>
>> I don't exactly know the code and I did not try disjuncts in QVT up to
>> now. Just an idea... :)
>>
>> Regards,
>> Mahdi D-Manesh
>>
>>
>> Matthew Watson schrieb:
>>> Hi,
>>>
>>> I am trying to implement a transformation. We have a reference to an
>>> abstract base type but need to resolve it to a mapping to a concrete
>>> instance.
>>>
>>> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
>>> QVT spec) but this results in the error: 'Result and out parameters of
>>> abstract types must be explicitly instantiated in the init-section!'
>>> on the mapping itself and '"Tuple" expected instead of "toC"' on the
>>> final mapping of the disjuncts list (which is toC).
>>>
>>> Are disjuncts implemented in QVTO (Ganymede)?
>>>
>>> The mappings themselves I was trying to write with a base class
>>> mapping for the A->B mapping and sepecific mappings for the A->C, and
>>> A->D mappings (where C & D are the conrete types extending the
>>> abstract B). When I try this, I get the 'Result and out parameters of
>>> abstract types must be explicitly instantiated in the init-section!'
>>> error on the base mapping (A->B) and the concrete type mappings get
>>> the error "Unresolved mapping operation reference 'toB'".
>>>
>>> Are inheritance of mappings supported and how can I implement a
>>> reusable mapping to a base type which is only ever extended by
>>> concrete type mappings?
>>>
>>> Thanks,
>>> Matt
>>>
Re: [QVTO] disjunct and inherits problems [message #94485 is a reply to message #93939] Tue, 04 November 2008 17:08 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Matt,

The conversion problem in assignments has been solved.
Your statement bellow will compile, however in runtime would result in
OclInvalid.
ebigDecimalField.oclAsType(X::Y::PositiveDecimal)

The actual problem seems to come from MDT OCL, I have to investigate that
and eventually raise a bugzilla.

FYI, you can use the latest QVTO integration build
http://www.eclipse.org/modeling/download.php?file=/modeling/ m2m/qvtoml/downloads/drops/2.0.0/I200811031800/m2m-qvtoml-SD K-I200811031800.zip.

It should work fine for your use-case, IMO, except for the
'oclAsType(X::Y::PositiveDecimal)' evaluation,
which you should not need anymore.

Also, you can define a blackbox library in Java if you need some specific
number handling not
available in QVT. The documentation is part of the integration build.

Regards,
/Radek



On Thu, 30 Oct 2008 05:37:31 +0100, Matthew Watson
<matthew-j.watson@db.com> wrote:

> Thanks, that was what I needed - I see some of the examples are not the
> same as the impl - I finally got my disjuncts and inherits to work by
> fully qualifying the name - in the examples in the OMG spec, they are
> not fully qualified.
>
> I downloaded 3.5M2 and QVTO 2.0.0M2 and found some changes to what I
> expected.
>
> To get around my EBigDecimal (impl class BigDecimal) -> PositiveDecimal
> (impl class BigDecimal) conversion problem, I had been using
>
> posDecField := ebigDecimalField.oclAsType(X::Y::PositiveDecimal)
>
> which was doing the trick in stock eclipse 3.4.1 release.
>
> This no longer works in the dev builds of 2.0.0M2, instead I get the
> error:
>
> The type 'X::Y::PositiveDecimal' does not conform to the type
> 'oclstdlib::Real' of the property 'posDecField'
>
> I can however simply assign one from the other and it runs just fine.
> Did you fix that bug for M2?
>
> Thanks,
> Matt
>
> Radek Dvorak wrote:
>
>> Hi Matt,
>
>> Yes, we do implement disjuncts.
>
>> Those mappings that return an abstract class but are rather defined
>> for extension then
>> for its own execution should be defined as 'abstract'.
>
>> See the 'UML::UseCase::createCommonWorkDefinition' mapping operation
>> in the spec example
>> A2.4 SPEM UML Profile to SPEM metamodel
>> (Note: there is a typo in the spec, 'mapping abstract ...' =>
>> 'abstract mapping ...')
>
>> Once defined as abstract, other mappings may 'inherit' from this
>> mapping,
>> but it can not be call directly as we can not implicitly instantiate
>> an abstract class.
>> However, you can do so explicitly in the init {} section, as suggested.
>
>
>> Regards,
>> /Radek
>
>
>
>> On Wed, 29 Oct 2008 04:08:23 +0100, Matthew Watson
>> <matthew-j.watson@db.com> wrote:
>
>>> Hi,
>>>
>>> I am trying to implement a transformation. We have a reference to an
>>> abstract base type but need to resolve it to a mapping to a concrete
>>> instance.
>>>
>>> To do this, I was trying to use a disjunct mapping (from 8.1.3 of the
>>> QVT spec) but this results in the error: 'Result and out parameters
>>> of abstract types must be explicitly instantiated in the
>>> init-section!' on the mapping itself and '"Tuple" expected instead of
>>> "toC"' on the final mapping of the disjuncts list (which is toC).
>>>
>>> Are disjuncts implemented in QVTO (Ganymede)?
>>>
>>> The mappings themselves I was trying to write with a base class
>>> mapping for the A->B mapping and sepecific mappings for the A->C, and
>>> A->D mappings (where C & D are the conrete types extending the
>>> abstract B). When I try this, I get the 'Result and out parameters of
>>> abstract types must be explicitly instantiated in the init-section!'
>>> error on the base mapping (A->B) and the concrete type mappings get
>>> the error "Unresolved mapping operation reference 'toB'".
>>>
>>> Are inheritance of mappings supported and how can I implement a
>>> reusable mapping to a base type which is only ever extended by
>>> concrete type mappings?
>>>
>>> Thanks,
>>> Matt
>>>
>
Previous Topic:[ATL ]Generating an EReference (containment = false)
Next Topic:how to use KM3 generate a graphical editor for DSL?
Goto Forum:
  


Current Time: Thu Mar 28 15:27:17 GMT 2024

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

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

Back to the top