Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] How to extend a model
[QVTo] How to extend a model [message #697089] Fri, 15 July 2011 13:52 Go to next message
--alex--  is currently offline --alex-- Friend
Messages: 26
Registered: October 2009
Junior Member
Hi all,
I'm new to m2m transformations,
Is there a way to transform a model A to a model B (conforming to the same metamodel, UML in my case) in which, for example, the model elements of B are the same model elements of A except for the addition of some properties (like a stereotype, or and extended name)?

Is there a way to "clone" elements and then add or change some of their properties?

Since I didn't find a way to do this, I just tried to change the name of the UML::Model element with the following in-place transformation:


modeltype UML uses "http://www.eclipse.org/uml2/2.0.0/UML";

transformation NewTransformation(inout source:UML);
main() {
 var m := source.rootObjects()![Model];
 m.map toNewModel();
}

mapping inout Model::toNewModel(): Model{
   name := self.name + 'newName';
}



Unfortunately the output is the same model with the actual UML::Model element (which I meant to change) with the name correctly set to the new one BUT with an additional UML::Model element which is void.

I managed to change the name of the model without introducing a new UML::Model by using a helper function, but this does not generate a .trace file which I need.

Anyway this is not what I want, I did it just for practice.
What I really need is a transformation with a input UML model and an output UML model, in which the output file is the same of the input except for additional properties.
Is there a way to achieve this?
Re: [QVTo] How to extend a model [message #697095 is a reply to message #697089] Fri, 15 July 2011 14:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Alex

The lack of a 'clone' or 'copy' is a significant language omission.

Regards

Ed Willink

On 15/07/2011 14:52, --alex-- wrote:
> Hi all,
> I'm new to m2m transformations,
> Is there a way to transform a model A to a model B (conforming to the
> same metamodel, UML in my case) in which, for example, the model
> elements of B are the same model elements of A except for the addition
> of some properties (like a stereotype, or and extended name)?
>
> Is there a way to "clone" elements and then add or change some of
> their properties?
>
> Since I didn't find a way to do this, I just tried to change the name
> of the UML::Model element with the following in-place transformation:
>
>
>
> modeltype UML uses "http://www.eclipse.org/uml2/2.0.0/UML";
>
> transformation NewTransformation(inout source:UML);
> main() {
> var m := source.rootObjects()![Model];
> m.map toNewModel();
> }
>
> mapping inout Model::toNewModel(): Model{
> name := self.name + 'newName';
> }
>
>
> Unfortunately the output is the same model with the actual UML::Model
> element (which I meant to change) with the name correctly set to the
> new one BUT with an additional UML::Model element which is void.
>
> I managed to change the name of the model without introducing a new
> UML::Model by using a helper function, but this does not generate a
> .trace file which I need.
>
> Anyway this is not what I want, I did it just for practice. What I
> really need is a transformation with a input UML model and an output
> UML model, in which the output file is the same of the input except
> for additional properties.
> Is there a way to achieve this?
Re: [QVTo] How to extend a model [message #718617 is a reply to message #697089] Wed, 24 August 2011 20:55 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi Alex,

Consider using .clone() and .deepclone() methods. First creates shallow copy of the object, second creates deep copy.

For example:

var m := source.rootObjects()![Model].deepclone().oclAsType(Model);

Regards,
Sergey
Re: [QVTo] How to extend a model [message #724021 is a reply to message #718617] Sat, 10 September 2011 11:22 Go to previous message
--alex--  is currently offline --alex-- Friend
Messages: 26
Registered: October 2009
Junior Member
Thanks for your replies.

I finally end up by creating a, successful, INOUT mapping.

I did not try .clone and .deepclone since I read they cause problems with Stereotypes and my models depend heavily on Profiles!
Previous Topic:[QVTo] UML Stereotypes application not set when launching transformation from Java
Next Topic:[QVTo] factoryEntries in class EclipseRegistry/ interface UnitResolverFactory are empty
Goto Forum:
  


Current Time: Sat Apr 20 00:27:12 GMT 2024

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

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

Back to the top