Copy one Model form a Instance to another Instance

View: New views
2 Messages — Rating Filter:   Alert me  

Copy one Model form a Instance to another Instance

by Alexander Stenzer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Copy one Model form a Instance to another Instance

Hello,

Is there a way to copy a ModelElement form one instance to another instance?

I want to do the following thing.

1. Read an UML Model form XMI into a instance.
2. Read a second UML Model form XMI into a instance.
3. Copy/Clone the second UML Model and instert it into the first instance.
4. Saving the file.


Thanks for helping.

Alexander


Re: Copy one Model form a Instance to another Instance

by Pieter Van Gorp-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 3. Copy/Clone the second UML Model and instert it into the first instance.
I guess this should be realized by explicitly adding the outer
UmlModel element from the second model as an ownedElement of a
UmlPackage in your first model (you could just use the outer UmlModel
element of the first model since that's a UmlPackage too).  That
should only take about 10 lines of JMI code.

See
http://galaxy.andromda.org/docs-3.1/jmi-uml1.4/org/omg/uml/modelmanagement/Model.html
http://galaxy.andromda.org/docs-3.1/jmi-uml1.4/org/omg/uml/modelmanagement/UmlPackage.html

The XMI loading/saving shouldn't be a problem either.

Kind regards,
Pieter Van Gorp
University of Antwerp
http://www.fots.ua.ac.be/~pvgorp/
LightInTheBox - Buy quality products at wholesale price