Author Topic: Is it a good idea to store the UUID from another tool in the Keyword attribute?  (Read 9760 times)

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
I know it works, technically, but is it a good idea?

I need to refresh a reference copy of model elements created in a different tool and I intend to do so with a script. The script will need the external UUID to match what’s in the import file with what is already in the Sparx model. I don’t feel ready to start changing the metamodel and add an External UUID attribute, so I thought – We aren’t using the Keywords attribute for anything. Maybe that's a decent place to store the external UUID? Then it occurred to me that I really don’t know what the Keywords attribute is intended for and how to use it. I was unable to find guidance in the help files, so now I turn to the Forum. Will storing UUID in the Keywords attribute for some elements come back to bite me down the road, because I won’t be able to use some Sparx feature I’m not even aware of yet?

Thanks,
Håkan Lidström

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
I'm pretty sure the keyword is just a text field available on all elements, and that you can use it just fine.

That being said, I still would opt to store it in a tagged value, if only because it seems like the cleaner solution.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
I'm pretty sure the keyword is just a text field available on all elements, and that you can use it just fine.

That being said, I still would opt to store it in a tagged value, if only because it seems like the cleaner solution.

Geert
According to Qwerty's excellent book, Inside EA (shameless plug).  They're held in the t_object.PDATA5 column in the DB.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Yes, keywords in EA are just some text stored along with elements. UML also has keywords which sadly look like stereotypes. Same name, different meaning, big confusion. In short: you can store it in the keywords. However, I'd use a tagged value and name it Foreign UUID (or whatever fits best).

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Hej!

I know it works, technically, but is it a good idea?

Short answer: no. It's a Bad IdeaTM.

Quote
Will storing UUID in the Keywords attribute for some elements come back to bite me down the road, because I won’t be able to use some Sparx feature I’m not even aware of yet?

In the case of Keywords I'm not aware of any built-in features which use it as of now. But that might change.
Sparx Systems do not publish any roadmaps and don't let anyone know what's in the pipeline, so a currently unused built-in property may well get worked into some new feature at some point.

A couple of releases ago, if someone had asked whether the Version property could be used to store custom data, the answer (according to the same reasoning) would have been Sure, go ahead -- but since then, new functionality has come in that actually uses the Version property. Which you don't have to use, but it puts you in the position of having to choose.

So it's a hard no. Use a tagged value instead, that is precisely what those are for: to extend the built-in metamodel with your own stuff.

If you want to keep it light, you don't have to design a profile or even define a tagged value type. You can just add tagged values on the fly in your script.
I do recommend that you define it all properly, but you don't actually have to.

Out of curiosity, have you looked at the DataMiner API? Or writing a cloud server custom plugin?
Both are new, both undoubtedly have useability issues, but they are both intended to address tool-to-tool integration.


/Uffe
My theories are always correct, just apply them to the right reality.

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Thank you all for your insights. I will try the tagged value route. and in reply to Uffe. I did look at Data Miner, but I would still need to keep track of external UUID and still have to define the import logic, so encouraged by Geert I opted for just plain scripting.
I can add that I found the Sparx-provided XML helper functions in EAScriptLib.VBScript-XML useful. (Though I found a little bug and had to make my own copy for now. I did report it.)

However, I would like to nag Sparx some. It should not be hard to find out your thoughts behind a construct, such as, an element attribute. I tried, I really did, but could not find any hint on the purpose of the 'Keywords' attribute.

Thank you all!
Håkan

timoc

  • EA User
  • **
  • Posts: 201
  • Karma: +14/-0
    • View Profile
When i poked around in the EA database definition, It's a VARCHAR(50), i was under the assumption that the UUID just needs to be unique. You could probably use that out of the box, if your key is unique, and not have to jump through hoops....

Do you know about Alias? I cannot find any reasonable documentation on it, but i always thought of it as the out of the box support for external Unique IDs. Using alias you can have an element name and unique name, and it is supported in the element view.

In the case of Keywords I'm not aware of any built-in features which use it as of now. But that might change.

I have been wondering what it was for, as we have tags. I always assumed it was for use with aliases to make them unique.

« Last Edit: April 08, 2020, 12:26:19 am by timoc »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
I have been wondering what it was for, as we have tags. I always assumed it was for use with aliases to make them unique.
Well, EA has quite a number of bells and whistles which someone thought to be useful (like this root/view/package construct and much more).

It's there. Use it or not. But don't ask why it's there.

q.

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
I use alias as an alternative name, where appropriate. A short name or acronym. This is something I have "always" done. Long before i heard of Sparx.
I would think this is what Sparx developers also had in mind, as there is a diagram option to show alias instead of name on shapes. (If an alias is defined.)

But now for a follow up question to my original ask.
How does one set a tagged value for a datatype, in a script?
I can do it manually. No problem! I tried on a datatype that was imported with the Sparx built in XML import. Just went to the Tags tab and created a new one.
But no matter how much I search I can't figure out how to do it in a script. There is no TaggedValues collection for class Datatype. How is it done?

Thanks,
Håkan Lidström

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Could it be that my imported datatype isn't a "Sparx datatype", but something else in terms of the Sparx object model? But if so, what?
Whatever it is, it is a child of a package. On a diagram it shows as a plain box with <<dataType>> above the name. Like a stereotype would be displayed, but the Stereotype property is blank and the Type property shows "DataType". As i write this I realize that the diagram shape shows a lower case 'd' while the Type property shows upper case 'D'. Whatever significance that may have.

(I would include a screenshot of my imported datatype if I could just figure out how.)

/Håkan


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
What do you mean by setting a tag as datatype?

q.

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
I am importing from an xmi file, exported from erwin. It has a uml:model node and under it ore other nodes such as:
Code: [Select]
<uml:Model xmi:type="uml:Model" xmi:id="{799A0437-D91A-4CC5-998A-7C23E2130F39}+00000001" name="Integrated Review">
<packagedElement xmi:type="uml:DataType" xmi:id="{D1F75789-86EE-4187-BF2D-5F05AB9963EF}+00000001" name="char[18]" visibility="public"/>

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
A datatype is an EA.Element as has a TaggedValues collection that you can use.

Geert

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Fumbled the keyboard. Dang!

When I run the built in XML Import it creates a package for the uml:model node and then items under it.
the xmi nodes of type xmi:type="uml:DataType" will become items in Sparx that show property Type = DataType.
I want to assign a tagged value to those items. (Whatever they are in terms of the Sparx object model.)
The tagged value will store the UUID exported from erwin, so that I can determine if in the next erwin export a node is new or has already been imported to Sparx. (The erwin modeler may change the name of something. In taht case I want to update the name in Sparx and not create a new item.)

I can't use the built in Sparx XML import because e it just creates new items every time I run it. Thus the need for my own script.

As I mentioned earlier I can create tags manually on items imported by the Sparx built in import  but I don't now how to do it with a script.

HLidstrom

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Aha!

So what I import is an element, an item in the elements collection for a package. Not part of the Repository.Datatypes collection.
I'll try that.