Two methods provide an identifier of an com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element. Either method can be used depending on the situation. This section explains the difference between the two:

  1. com.nomagic.uml2.ext.magicdraw.base.ModelObject.getLocalID()
  2. com.nomagic.magicdraw.foundation.MDObject.getID()

The meaning of the returned identifiers depends on the project type.

Local (.mdzip) and Teamwork Server projects

Both methods return the same identifier, which is permanent and unique in the scope of the project. In most cases, this ID is unique among different projects, unless you create a copy of the project by copying the file or using the Save As command.

Examples

  1. If a project A is used in projects B and C, then the elements of the project A have the same identifiers in both projects B and C.
  2. If a project A is copied as a project A1, and a project B uses the project A, using the project A1 additionally will not be allowed since IDs must remain unique in the scope of the project B.


Teamwork Cloud (TWC) projects

If a local project is added to the Teamwork Cloud (or vice versa), getLocalID() consistently returns the same identifier value. Note that several elements with the same local ID may exist in the scope of a single TWC project.

getID() returns UUID, which is unique both in the project and in the scope of the whole TWC server repository.

The Teamwork Cloud imports (clones) the contents of used projects. This means copies of the elements are created inside the project. While getLocalID() returns the same value for different copies, getID() will return a unique value for each copy (project usage).

Example

If a project A is copied as a project A1, and a TWC project B uses both A and A1getLocalID() returns the same value for corresponding elements of A and A1, but getID() returns different identifiers for the same elements.



Tip

Both identifiers can be used to retrieve the element using the method com.nomagic.magicdraw.core.Project.getElementByID(java.lang.String). Be aware that if several elements exist in the project by the provided local ID, only a single one of them is returned.

Related pages