[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [QVTO] Problems with resolve and update

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;
}