Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Problems with resolve and update
[QVTO] Problems with resolve and update [message #86392] Fri, 11 July 2008 14:16 Go to next message
Eclipse UserFriend
Originally posted by: stenzel.informatik.uni-augsburg.de

Hi,

I seem to 'loose' elements if I modify them after I retrieved them with
resolve.
In the following program I would expect that mp.packagedElement contains a
class, but that is not the case.

Is this a bug or a feature?

Thanks for any help,

Kurt

modeltype UML uses 'http://www.eclipse.org/uml2/2.1.0/UML';

transformation updateTest();

mapping main() {
init {
this.runTest();
}}

query OclAny::runTest() : OclVoid {
var o := object UML::Class { name := 'myClass'; };
var p := object UML::Package { packagedElement += o; };
p.map copyPackage();
o.map copyClass();
var mp := p.updatePackage();
o.name := 'yourClass';
log('package', mp.packagedElement.name);
return null;
}

mapping UML::Package::copyPackage() : Package { }
mapping UML::Class::copyClass() : Class { }

query UML::Package::updatePackage() : Package {
var x := self.resolveone(Package);
x.packagedElement :=
self.packagedElement.resolveone(PackageableElement)->asSet();
return x;
}
Re: [QVTO] Problems with resolve and update [message #86576 is a reply to message #86392] Wed, 16 July 2008 16:06 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi Kurt,

No, there're no bugs in execution of script you posted.

Actually code
log('package', mp.packagedElement.name);
outputs the name of uml::Class instance created by "o.map copyClass();"
expression. So latter modification of original object by calling "o.name
:= 'yourClass';" has no effect.

You can archive that by modifying
mapping UML::Class::copyClass() : Class { }
to the following
mapping UML::Class::copyClass() : Class { name := self.name + '_copy'}


Regards,
Sergey.


Kurt Stenzel wrote:
> Hi,
>
> I seem to 'loose' elements if I modify them after I retrieved them with
> resolve.
> In the following program I would expect that mp.packagedElement contains
> a class, but that is not the case.
>
> Is this a bug or a feature?
>
> Thanks for any help,
>
> Kurt
>
> modeltype UML uses 'http://www.eclipse.org/uml2/2.1.0/UML';
>
> transformation updateTest();
>
> mapping main() {
> init {
> this.runTest();
> }}
>
> query OclAny::runTest() : OclVoid {
> var o := object UML::Class { name := 'myClass'; };
> var p := object UML::Package { packagedElement += o; };
> p.map copyPackage();
> o.map copyClass();
> var mp := p.updatePackage();
> o.name := 'yourClass';
> log('package', mp.packagedElement.name);
> return null;
> }
>
> mapping UML::Package::copyPackage() : Package { }
> mapping UML::Class::copyClass() : Class { }
>
> query UML::Package::updatePackage() : Package {
> var x := self.resolveone(Package);
> x.packagedElement :=
> self.packagedElement.resolveone(PackageableElement)->asSet();
> return x;
> }
>
>
Re: [QVTO] Problems with resolve and update [message #86712 is a reply to message #86576] Fri, 18 July 2008 12:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stenzel.informatik.uni-augsburg.de

Hi Sergey,

sorry, my fault. My program does not create the effect I wanted.

Still I have strange effects. I try to copy a UML model by creating
the result objects, and then updating them with the help of resolve.
It turns out that the order in which the elements are updated seems
to be important: If I update all UML::Class objects before I update
the UML::Properties, the properties are no longer contained in the
Class objects, but appear on the toplevel as siblings of UML::Model.
If I do it the other way round they are contained in the Class (I
view the result with the EML model editor).

But probably it's a bug in my copy transformation ...

Thanks for your help,

Kurt
Re: [QVTO] Problems with resolve and update [message #86857 is a reply to message #86712] Tue, 22 July 2008 12:43 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Kurt,

Just a tip for creating a copy of existing object with easy custom =

modifications.

mapping UML::Class::copyClass() : UML::Class {
init {
-- create a deep copy of the source object
-- and assign to the result explicitly
result :=3D self.deepclone().oclAsType(UML::Class);
}
-- decorate the original name
name :=3D result.name + '_aSuffix';
}



Also, I would recommend to you using the transformation signature and =

signatureless main(),
which is actually the standard way. It is our fault that the compiler do=
es =

not complain
(this is a legacy construct still supported).
Then you will get access to model parameters and can query then for =

objects, etc.
See the example bellow:

/*
* Two modeltypes are declared. The http NS URIs correspond to those us=
ed =

to register the
* Ecore models in the environment. Alternatively, a workspace metamode=
l =

may be used
* in conjunction with mappings defined in the project properties.
*/
modeltype UML uses =

' http://www.eclipse.org/qvt/1.0.0/Operational/examples/simple uml';
modeltype RDB uses =

'http://www.eclipse.org/qvt/1.0.0/Operational/examples/rdb';

/*
* The transformation signature declares that a UML modeltype is requir=
ed =

as input, while an RDB
* modeltype is produced as an output. The UML modeltype is referenced=
as =

'uml' throughout the
* transformation definition, while no name is needed for the output RD=
B =

modeltype. Note that OCL
* type and namespace notation are used in operational QVT (: and :: =

respectively).
*/
transformation Simpleuml_To_Rdb(in uml : UML, out rdb : RDB);

/*
* The main entry point of the transformation. The 'uml' reference to =
the =

input UML modeltype
* instance is used to collect all rootObjects() of type Model. The =

rootObjects() operation
* is available on all QVT Model objects (extents) and returns those =

objects found at the
* root of the input model. The [UML::Model] statement following the c=
all =

to rootObjects()
* is shorthand notation for the imperative select (xselect) construct =
=

where the condition is
* a type expression, which effectively performs a oclIsKindOf(UML::Mod=
el) =

with type recasting
* as a sequence.
*
* The invocation of the model2RDBModel() mapping is done using an -> =

operator, which is a
* shorthand notation for the imperative collect (xcollect) construct. =
=

Alternatively, it could
* be written as uml.rootObjects()[UML::Model]->xcollect(a | a.map =

model2RDBModel());
*/
main() {
uml.rootObjects()[UML::Model]->map model2RDBModel();
}


You can describe the desired behavior and I could try to help you.

Regards,
/Radek




On Fri, 18 Jul 2008 14:49:51 +0200, Kurt Stenzel =

<stenzel@informatik.uni-augsburg.de> wrote:

> Hi Sergey,
>
> sorry, my fault. My program does not create the effect I wanted.
>
> Still I have strange effects. I try to copy a UML model by creating
> the result objects, and then updating them with the help of resolve.
> It turns out that the order in which the elements are updated seems
> to be important: If I update all UML::Class objects before I update
> the UML::Properties, the properties are no longer contained in the
> Class objects, but appear on the toplevel as siblings of UML::Model.
> If I do it the other way round they are contained in the Class (I
> view the result with the EML model editor).
>
> But probably it's a bug in my copy transformation ...
>
> Thanks for your help,
>
> Kurt
>
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Previous Topic:Ask again about three problems about ATL transfromer
Next Topic:[ATL] Questions about using ATL compiler programmatically
Goto Forum:
  


Current Time: Fri Mar 29 15:59:43 GMT 2024

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

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

Back to the top