Book a Demo

Author Topic: Rules for GUID Generation  (Read 9318 times)

Brandon K.

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Rules for GUID Generation
« on: January 29, 2014, 09:04:12 am »
Hi,

I've been working on a tool which will procedurally generate associations in bulk between previously existing blocks in an EA package.  The idea is to be able to take a relationship matrix or a paired list of blocks to be associated and automatically generate all of the associations in bulk.  

This works in four steps:

1.  Export blocks using CSV export to get the GUIDs for the blocks

2.  Create a list of associations to be created with the "source" and "destination" GUIDs identified from the list in (1).

3.  Export the block package as an XMI file to get the code description for the blocks.  

4. Generate and insert code segments into the XMI file as appropriate to assign associations to their relevant blocks.

In order for this to work, I need to generate GUIDs for the associations themselves.  I've got something that does this and formats them correctly.  Each association needs three GUIDs, which look like this:

EAID_80BFD153_894C_CC50_BF21_E7DC2309C80F
EAID_srcBFD153_894C_CC50_BF21_E7DC2309C80F
EAID_dstBFD153_894C_CC50_BF21_E7DC2309C80F

Each digit is generated randomly from the possible list of hexadecimal characters.

The code works, and I'm able to import the XMI file and get most of the associations to be created in the corresponding diagrams (where the blocks are placed).  However, somewhere between 5 and 10% of the created associations randomly fail to be generated.  Occasionally, previously existing associations in other packages in the same model are also deleted when new XMI files are imported.  The problem is not that the same GUID is being used twice, either - the probability of a repeat randomly generated 32 digit hexadecimal string is exponentially low, and in actual testing, no repeats exist.


The only thing I can see that might be wrong is that some combinations of hexadecimal characters are reserved by EA and so GUIDs which randomly fall in these spans are ignored.  Can anyone explain how EA creates its GUIDs and what restrictions there may be on acceptable ones?

Separately, can anyone explain in greater detail what the "strip GUIDs" function does in the XMI import?  I haven't been using it because the idea is to update existing blocks with new associations, and I'm hoping to avoid repeating block elements, etc.  

Finally, what's up with EA not including associations in the project browser?  The associations obviously exist somewhere in the database, and it is possible to modify the properties of an association by clicking on it.  Other software I have used in the past includes these as elements in the browser which makes them dramatically more useful as well as easier to edit.  Geert, does your EA Navigator tool enable this functionality?  (Thanks, by the way, for the Excel Importer tool - it makes life sooo much easier)!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Rules for GUID Generation
« Reply #1 on: January 29, 2014, 10:13:27 am »
Unfortunately you will be lost here. In general you can use GUIDs at your wish. But some are special. IIRC (and I posted that in another thread a few hours ago) there is a link between elements and methods GUIDs. Also for tagged values from profiles there is some magic. I never had a deeper look into connector's GUID but there could be some restriction too. I'd be glad to hear more.

q.

P.S. I just browsed a model. The connector GUIDs look harmless. The format in EA is like {C8275925-6190-45fd-BFC2-B6173C567F9B} (it's converted from the XMI format). The only thing notable is the the mid hex tuple uses lower case chars (like almost all EA GUIDs). But I don't think that is mandatory.
« Last Edit: January 29, 2014, 10:18:00 am by qwerty »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Rules for GUID Generation
« Reply #2 on: January 30, 2014, 12:44:24 am »
Hi Brandon,

Strip GUID's will import all elements as being new as opposed to updating the existing elements if they already exist.

If you select an association in a diagram it will show it in the EA Navigator window, but there isn't much you can do with it. I haven't been able to figure out how to show the properties dialog for an association.

Geert

Brandon K.

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Rules for GUID Generation
« Reply #3 on: January 31, 2014, 06:24:25 am »
@qwerty: The lower case characters appear not to be mandatory (I've successfully created connectors without using lower case).  Still don't know about any other restrictions.  

---------------

So I think I've identified my issue with connectors being deleted.  Apparently, in addition to the GUID for connectors, there is a separate "link id" which appears to exist for connectors within a particular project.  When I import an XMI package, it has some chance of deciding the new connectors from the package have the same link ID as existing connectors somewhere else in the project (specifically, in other packages which are not being directly modified by the import).  When EA identified the "conflict", the result is the old existing connectors are deleted.  

This is extremely stupid and frankly poorly implemented.  Why are there GUIDs for connectors if those GUIDs aren't being used to keep track of which things are which in the model?  To be clear, all connectors have unique GUIDs, but apparently this is insufficient for EA to be able to keep track of what belongs where.  

If anyone has any ideas as to how link IDs are assigned to connectors, and how one might modify them, i'd be deeply appreciative.

-----

@Geert:  I think the problem with associations in general is that they aren't actually being stored in the database as separate entities, and EA is basically cheating and assigning them as properties of other blocks/classes (or some similar situation).  This would explain the relatively limited functionality associated with these elements.
« Last Edit: January 31, 2014, 06:25:27 am by bjk4061 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Rules for GUID Generation
« Reply #4 on: January 31, 2014, 09:32:52 am »
Quote
@Geert:  I think the problem with associations in general is that they aren't actually being stored in the database as separate entities, and EA is basically cheating and assigning them as properties of other blocks/classes (or some similar situation).  This would explain the relatively limited functionality associated with these elements.
They are stored in t_connectors. But you're right that connectors are 2nd class citizens in EA.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Rules for GUID Generation
« Reply #5 on: January 31, 2014, 09:38:11 am »
Quote
So I think I've identified my issue with connectors being deleted.  Apparently, in addition to the GUID for connectors, there is a separate "link id" which appears to exist for connectors within a particular project.  .
Actually the import checks for identical GUIDs only. The internal link id is just for optimizing the SQL (a numerical primary is usually faster than an alpha-num). So if the connector withe the GUID already exists it is replaced. The same goes for elements.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Rules for GUID Generation
« Reply #6 on: January 31, 2014, 05:44:43 pm »
Yes, that is to make it difficult. :-X
Each (no not correct, should be "most") thing in EA has both a numerical id, which is only unique within the same table, and a GUID which is really unique.
Both identifications are used throughout the API.
Sometimes you need the ID, sometimes the ea_guid.

its a consistency thing  ::)

Geert

Brandon K.

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Rules for GUID Generation
« Reply #7 on: February 12, 2014, 10:03:25 am »
Sorry to resurrect this thread, but I'm back at hacking at this and I've uncovered a new problem.  It appears that there are a limited number of numerical_ids permitted in a given model/package/whatever.  This means that more than a certain number of associations or connections between blocks simply don't get uploaded.  

My model has 4 groups of blocks which are associated to one another, basically modeling how a lot of small things map onto a small number of big things.  The numbers work out like so:

14 Group 1 --> 14 Group 2 -->176 Group 3 -->267 Group 4.

There are a total of 681 associations, each of which has been created in the XMI file with unique GUIDs.  For some reason, however, only the first 232 load, after which EA decides the rest aren't worth it's time or attention.  I imagine this has something to do with a hard limit on the number of associations or the number of total elements (blocks + associations + stereotypes, maybe?).  It very specifically loads the first 232 associations, in order in the XMI file - but all blocks are loaded regardless of location in the file.  (depending on how the file is read, it presumably might look for blocks before delving deeper into the XMI heirarchy).

Can anyone explain what is up with this?  I can try and find a way to upload the XMI file if it would help.

267 + 14 + 14 + 176 = 471 blocks

232/681 Associations

--Brandon
« Last Edit: February 12, 2014, 10:03:57 am by bjk4061 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Rules for GUID Generation
« Reply #8 on: February 12, 2014, 10:47:32 am »
You must be doing something wrong (I guess). There is (almost) no limitation to the number of connectors. There are repositories out there which have thousands of connectors.

I'd check the XMI if you post a link.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Rules for GUID Generation
« Reply #9 on: February 12, 2014, 11:07:10 am »
Does your XMI contain associations to elements which are not contained within this file, and are not in the model you are importing into?  By default, EA cannot import a connector if it is missing the related element at either end.

If this is the case and you need to see the relationships to these external elements, you could try enabling the "Create placeholders for missing External References" option.  See:
http://www.sparxsystems.com/enterprise_architect_user_guide/10/projects_and_teams/xmlspecifications.html

You can also see a demonstration of this feature here:
http://www.sparxsystems.com/resources/demos/xmi/xmi.htm