Sometimes you need to use EA module as a template for multiple similar models. So you strip GUIDs and you are fine. Problem appears when you need to share some of elements in shared module and when you care to keep reference to that shared elements in new module from template. We use EA together with SVN for packages (xmi). In one project we have several of them. Whole solution is made of many projects.
We have library (package) of known UML elements (like components or systems), which are shared across all projects and are used/instantiated in packages of models. Quite often we need to use one of packages as a template for another one in same model. Specifically, my use-case is that template package is containing instances of components, which are defined in shared package. But there are also other components (in template module) which are templates and which need separate identity after used as template.
Because EA doesn't support such use-case we were forced to redraw it over and over again. I really hate repeating what was already done. I'm also lazy to do that. So I implemented tool which does the work for me.
Inside of XMI entities have it's identity referenced using GUIDs. So we need to strip GUIDs in template module, but only some of them. Those which link to common package should remain linked. And those elements which are template need to be striped.
Simple explanation how tools works is that I parse out all GUIDs from template module. Then I parse GUIDs from shared modules and match them. If I have found GUID in shared module, I should keep it in new copy of templated module. Otherwise I replace it with newly generated GUID. Whole thing is just quick and dirty solution. I don't parse XMI properly and don't care about this piece of code too much.
Usage: Export your shared modules to XMI. Export your template module to XMI. Use tool.
StripSomeGUIDs.exe [shared-xmi-file-1] {[... shared1-xmi-file-N]} [xmi-file-to-strip]
Import result from [xmi-file-to-strip].new following way. You shouldn't strip GUIDs again, because it was already done.
Code is there.
Enjoy!
No comments:
Post a Comment