Author Topic: How to change GUID?  (Read 6319 times)

paphko

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
How to change GUID?
« on: June 17, 2007, 11:41:37 pm »
I need to change the GUID of a new Element via the automation interface. The User Guide says:
Quote
Read only.  A globally unique ID for this Element - unique across all model files. If you need to set this value manually, you should only do so when the element is first created - and make sure you format the GUID exactly as EA expects.

At least, it seems to be possible :-) - but how can I do this?

Patrick


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to change GUID?
« Reply #1 on: June 18, 2007, 01:43:51 am »
First, make sure you have the format correct - as the documentation suggests, there is no wiggle room here.

When you first create the element (or connector) via AddNew, it has yet to receive its GUID. EA normally gets a new GUID and assigns it when you call Update on the new item.

What you need to do is, immediately after calling AddNew, assign your own GUID. EA will notice this when you call Update, and will accept the GUID you've assigned.

Another important thing to remember is that regardless of who assigned the GUID (you or EA) from the time Update returns, the GUID is read-only.

David
No, you can't have it!

paphko

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: How to change GUID?
« Reply #2 on: June 18, 2007, 02:19:41 am »
Quote
...
What you need to do is, immediately after calling AddNew, assign your own GUID. EA will notice this when you call Update, and will accept the GUID you've assigned.
...


Sounds feasible, but I don't know how to assign my own GUID.

I'm using the Java API shipped with EA v6.5 but it does not provide a setter for the GUID. So how can I assign the GUID?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to change GUID?
« Reply #3 on: June 18, 2007, 02:33:40 am »
Don't know...

But look into whether you can access the Windows API, either through .Net libraries or good old WMF. Both have calls that return a new GUID, but I cannot tell you off hand where they are.

Surely there is such a call someplace within the Java libraries as well. After all, the GUID (or UUID in the Unix world) is a widely-used identifier paradigm.

David
No, you can't have it!

paphko

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: How to change GUID?
« Reply #4 on: June 18, 2007, 03:20:45 am »
Let me explain the whole setting..

Lets assume we have a model M and we want to branch it. To do so, we copy the eap-file, lets call this model M'. Both versions are modified independently of each other.

Now, we want to copy an element from M' to M. So we create such a new element in M and all relevant attributes can be set - except for the GUID because it is readonly.

The Java API only provides a getter for the GUID field. But the User Guide says it should be possible to set it - but I don't know how...
Perhaps via SQL if the Java API is not capable of changing it?!

Patrick

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to change GUID?
« Reply #5 on: June 18, 2007, 10:07:21 am »
No, whatever you do, don't tweak the database to reset the GUID. There can be several other references to an element's GUID, and they are not all controlled by foreign keys, so changes will not get propagated.

If you want to copy a package (and contents) to another location within the same model, you've got to set new GUID values for everything. Otherwise EA will not know which item is being referred to with a given GUID, the original or the copy.

If you want top copy to another model you can reuse the same GUID values. As long as you realize that you are referring to the same item as you were in the original model (and don't get confused and cross-copy something) you should be OK. A way to do that is to write out the package as an XMI file, then import it into the target model.

Otherwise, look into some Windows documentation - try on-line via the MS site - for Windows routines to get a new GUID. Then see if you can get a Java interface to make the call for you.

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: How to change GUID?
« Reply #6 on: June 18, 2007, 01:18:41 pm »
It looks to me that the help file is wrong.

Quote
Read only
and
Quote
If you need to set this value manually, you should only do so when the element is first created - and make sure you format the GUID exactly as EA expects.
are clearly contradictory.  I'm certain that there is no method for setting an element GUID in the automation interface.

If you want to copy an element, call AddNew on the Elements collection for the package you want to add to.  Then copy each of the properties you can.  When you save that element it will get a new guid.