View source for Deepclone From MDrivenWiki ← Deepclone DeepcloneYou do not have permission to edit this page, for the following reason: The action you have requested is limited to users in the group: Users. You can view and copy the source of this page. Pretty often you have user scenarios that require you to copy an existing object structure. Like when handling revisions of things and the user wants a new revision but want to start with the old and just tweak a few values. In cases like these it would be neat with a clone mechanism of your modeled objects. And once you have a clone mechanism you pretty soon will discover that cloning just one object will not suffice – you want to follow associations and clone owned child objects – but only in some cases – in other cases you don’t want to clone the child objects but rather reference the same ones from the clone. Given this model; [[File:Simpleclassstructure.png|none|thumb|549x549px]] We let a viewmodel act as a definition for what the clone should do,, like this for example; [[File:Deepclonedefinition.png|none|thumb|815x815px]] Then in OCL you do; self.deepclone('ViewModel_Person_DeepClone') The deepclone operator returns the new Person object, complete with copies of OwnedBuildings and the Home links. A good place to use this operator is in a method on a class, for example CreateClone() : Person. That way you just call self.CreateClone from a class action using the returned object as the root of the viewmodel the action opens. [[Category:OCL]] [[Category:Operators]] Return to Deepclone. Retrieved from "https://wiki.mdriven.net/index.php/Deepclone"