[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,

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 := self.deepclone().oclAsType(UML::Class);
	}
	-- decorate the original name
	name := 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 does 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 used to register the
* Ecore models in the environment. Alternatively, a workspace metamodel 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/simpleuml';
modeltype RDB uses 'http://www.eclipse.org/qvt/1.0.0/Operational/examples/rdb';


/*
* The transformation signature declares that a UML modeltype is required 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 RDB 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 call to rootObjects()
* is shorthand notation for the imperative select (xselect) construct where the condition is
* a type expression, which effectively performs a oclIsKindOf(UML::Model) 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@xxxxxxxxxxxxxxxxxxxxxxxxxx> 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/