Author Topic: Element - set GUID method  (Read 1185 times)

naxx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Element - set GUID method
« on: August 26, 2016, 11:34:11 pm »
Hello,

How I can set my own GUID to element? Is it possible?

Thank

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 8025
  • Karma: +183/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element - set GUID method
« Reply #1 on: August 26, 2016, 11:52:23 pm »
No (unless you go through the backdoor and issue an SQL update statement).
Why would you want that?

Geert

naxx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Element - set GUID method
« Reply #2 on: August 27, 2016, 12:00:55 am »
Thanks. I want set GUID to element, because I have XML file with GUIDs (that was parsed and imported to EA) and I want same elementīs GUID.

Benny

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Element - set GUID method
« Reply #3 on: December 12, 2017, 06:05:46 am »
Hi,

I would also like to set a GUID manually.
When I Import a CSV-File with (valid) GUID inside, the GUIDs where set to the new Elements.
So I consider there musst be a Method to give Input with GUIDs.

I tried to Import it by an script because i like to add a new Connector to existing Elements.
I also tried the "SQL Backdoor" Geert implied, but I got a warning about duplicate Elements.
I also tried the "normal" way to import with the buildin Sparx CSV importer, no Porblems with the GUIDs.
Here is the import function:

Code: [Select]
function OnRowImported()
{
      rowCount++;

      // get all values for this row
      var reqName = CSVIGetColumnValueByName("Name");
      var reqType = CSVIGetColumnValueByName("Type");
      var reqGUID = CSVIGetColumnValueByName("GUID");
      var reqNotes = CSVIGetColumnValueByName("Notes");
      var reqAlias = CSVIGetColumnValueByName("Alias");
  var reqStereotype = CSVIGetColumnValueByName("Stereotype");
  var reqTagValue = CSVIGetColumnValueByName("TagValue");
  var systemGUID = CSVIGetColumnValueByName("SystemGUID");  
 
      Session.Output("  Importing: " + reqName + "." + reqGUID);

targetPackage = Repository.GetTreeSelectedPackage();
requirement = targetPackage.Elements.AddNew (reqName, reqType);
// requirement.ElementGUID = "{"+reqGUID+"}";
requirement.Notes = reqNotes;
requirement.Stereotype = reqStereotype;
requirement.Alias = reqAlias;
tag = requirement.TaggedValues.AddNew ("Funktional/NichtFunktional",reqTagValue);
tag.Update;
requirement.Update();
SQL = "UPDATE `t_object`"+
"SET     `ea_guid`='{"+reqGUID+"}'"+
"WHERE `Object_ID`="+requirement.ElementID+";"
Repository.Execute(SQL);

     
}

May someone got a hint for me

regards Benny


[edit] HAHA never Mind I really got double GUID in the CSV-file (because of a N-N dependency for the System Elements...  :o
So it work fine with the SQL Update :D
« Last Edit: December 12, 2017, 07:40:53 am by Benny »