Book a Demo

Author Topic: XMI IDs of Model Elements  (Read 8898 times)

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
XMI IDs of Model Elements
« on: August 10, 2011, 11:22:51 pm »
Dear Sparx Systems & Community,

I am a developer and my current project deals with the conversion of Class diagrams from Magic Draw to Enterprise Architect.
One approach to this matter is the transformation of XMI files.

As I have analyzed the XMI file of Enterprise Architect Projects, I stumbled upon the IDs of the model elements, for example:
Code: [Select]
xmi:id="EAID_91A51FD1_8552_42a3_B8B6_8FEB5438B94F"
I have noticed that the pattern is always the same: EAID (or EAPK for packages), followed by 32 Hex digits - the format is also the same.
8 digits _ 4 digits _ 4 digits _ 4 digits _ 12 digits
This makes it a total of 32 Hex digits. (A random guess might be some code made out of 128 Bit? (32 * 4))

My question now is: Is it possible to randomly create such an ID according to that pattern and will the program work with it? Or is there a special checksum involved or something similar? Maybe a Sparx developer could help me out by providing an algorithm even?

I hope that somebody can help me with this :)

Cheers and kind regards,

Dave

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #1 on: August 11, 2011, 04:42:19 am »
It's probably derived from a GUID.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XMI IDs of Model Elements
« Reply #2 on: August 11, 2011, 05:17:27 pm »
Dave,

EA uses standard GUID's to uniquely identify elements.
If you are transferring from another tool with xmi then you don't need those GUID's. They are only used to be able to synchronize an element being imported by xmi with an element already existing in the model.
If there's no GUID present then EA will consider it a new element and assign it a new GUID.

Geert

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #3 on: August 12, 2011, 05:09:13 pm »
Thank you for your replies.
My guess is however, that EA will only consider them a new element, if I use the OLE API for creating these elements (I have yet to find out, whether that might be the only way to do so..).

I am currently considering simply transforming XMI file to XMI file and then importing the final XMI file to Enterprise Architect.
This means that I need the GUID, since they are an essential part of the XMI file.
I might change my plan, when I find out that this might be connected to too much hassle or something - then I will have to look into the OLE API..

Thank you so far - I'm pretty sure that this won't be my last post :D

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XMI IDs of Model Elements
« Reply #4 on: August 12, 2011, 05:20:00 pm »
Dave,

If you XMI is valid then EA will import it, regardless of whether the GUID's are there or not.
If it doesn't find an GUID in the xmi then it will create a new one.
So I really wouldn't worry about the GUID's.

Geert

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #5 on: August 12, 2011, 05:39:58 pm »
Hello Geert,

so you're saying that I can just use id="1" or any other simple identifier?
Let me bring a very simple Model example to the table.

Code: [Select]
<uml:Model xmi:type="uml:Model" name="EA_Model" visibility="public">
            <packagedElement xmi:type="uml:Package" xmi:id="EAPK_D403E274_EB78_4fa5_B77F_20BDD26EE95A" name="Package1" visibility="public">
                  <packagedElement xmi:type="uml:Class" xmi:id="EAID_91A51FD1_8552_42a3_B8B6_8FEB5438B94F" name="Class2" visibility="public"/>
                  <packagedElement xmi:type="uml:Class" xmi:id="EAID_3741039C_2B60_4024_A90D_6C1E0E333FB2" name="Customer" visibility="public"/>
                  <packagedElement xmi:type="uml:Association" xmi:id="EAID_5D844905_8D8E_4fa1_B5A4_E085CF16D759" name="owns" visibility="public">
                        <memberEnd xmi:idref="EAID_dst844905_8D8E_4fa1_B5A4_E085CF16D759"/>
                        <memberEnd xmi:idref="EAID_src844905_8D8E_4fa1_B5A4_E085CF16D759"/>
                        <ownedEnd xmi:type="uml:Property" xmi:id="EAID_src844905_8D8E_4fa1_B5A4_E085CF16D759" visibility="public" association="EAID_5D844905_8D8E_4fa1_B5A4_E085CF16D759" isStatic="false" isReadOnly="false" isDerived="false" isOrdered="false" isUnique="true" isDerivedUnion="false" aggregation="none">
                              <type xmi:idref="EAID_A0FA4512_3729_497e_9CC7_E90CCEF5945A"/>
                        </ownedEnd>
                        <ownedEnd xmi:type="uml:Property" xmi:id="EAID_dst844905_8D8E_4fa1_B5A4_E085CF16D759" visibility="public" association="EAID_5D844905_8D8E_4fa1_B5A4_E085CF16D759" isStatic="false" isReadOnly="false" isDerived="false" isOrdered="false" isUnique="true" isDerivedUnion="false" aggregation="none">
                              <type xmi:idref="EAID_3741039C_2B60_4024_A90D_6C1E0E333FB2"/>
                        </ownedEnd>
                  </packagedElement>
                  <packagedElement xmi:type="uml:Class" xmi:id="EAID_A0FA4512_3729_497e_9CC7_E90CCEF5945A" name="Ticket" visibility="public"/>
            </packagedElement>
      </uml:Model>

Regardless of what this model shows (2 classes with an association), you can see (and I'm sure you know this because you seem to be very fund of how EA works ;-)) that the model elements are refered to as the GUIDs.
What you are suggesting is to leave those GUIDs away and maybe replace them with a something simple - like an integer value.
So, EA has an in-built XMI Validator and will just replace those identifiers with GUIDs?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XMI IDs of Model Elements
« Reply #6 on: August 12, 2011, 05:46:02 pm »
Dave,

If the XMI created by magicdraw is valid XMI then EA will import it, regardless of the format of the id's. I'm not even sure the xmi needs id's at all..
While importing EA will create GUID's for those elements that don't supply an EA_GUID in the XMI.

Geert

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #7 on: August 12, 2011, 06:00:20 pm »
Thanks for your replay Geert,

what I'm trying to accomplish however, is not simply manually importing a MagicDraw XMI file within EA, but I will write a tool, which converts a MD repository to an EA repository.
So there won't be any manually performed import (or anything else), but it should (in theory) create it all automatically.
Maybe now you understand my point regarding the GUID ;-)

The process will be:
- Open MagicDraw XMI file
- Generate UML Object Representation from XMI file
- Generate Enterprise Architect XMI of previously created UML Object Representation OR use OLE API to create Model within EA

All of this happens without ever opening either MagicDraw or Enterprise Architect

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XMI IDs of Model Elements
« Reply #8 on: August 12, 2011, 06:31:34 pm »
Dave,

Creating an EA xmi file won't do any good.
EA doesn't work of xmi files. The content is stored in a repository. So you you will have to use the xmi import function to get an EA model.
You can however use the API to import the XMI file.
So the process could be
- create (or copy) empty EA repository
- Import MagicDraw XMI file into repository using EA API
- done

Geert

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #9 on: August 12, 2011, 06:40:54 pm »
Hello Geert,

thank you very much for this useful information!
Is there an extensive documentation for the API, which I can use?
All I find are small snippets on the sparx systems website (creating repositories and classes and so on..)
If there is an Import API, this might be really easy!
Otherwise I would write a MagicDraw-XMI-Parser, which would then create the UML Objects using the code snippets at hand..

Again, thank you so much for your help!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: XMI IDs of Model Elements
« Reply #10 on: August 12, 2011, 06:45:31 pm »
Dave,

The help file contains the full documentation of the API
I suggest you start here: http://www.sparxsystems.com/enterprise_architect_user_guide/9.0/automation/reference.html

Geert

PHPDave

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: XMI IDs of Model Elements
« Reply #11 on: August 12, 2011, 07:47:03 pm »
Thank you very much Geert.
I'm pretty sure that this wasn't the last time I searched this forum for help :-)
This matter now is resolved (for now :-D)