Book a Demo

Author Topic: Updating element Tags  (Read 9330 times)

davidson

  • EA User
  • **
  • Posts: 36
  • Karma: +0/-0
    • View Profile
Updating element Tags
« on: September 11, 2016, 01:03:39 pm »
An interesting problem I am faced with.

I have a well used model in place with a set of elements, all created by an MDG profile.
I have recently added some new tags to one of the element, within the MDG profile.

Obviously they only appear in new elements, not in existing. I was going to write to SQL to update all of the tags (just absolute values but it determines a shape).

I just thought I'd check though to see if there is easy way of doing this?
Assigning a new tag to an existing element retrospectively?

Thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Updating element Tags
« Reply #1 on: September 11, 2016, 03:54:50 pm »
You do it manually by right clicking on your toolbox element and choose synchronize stereotype, or you can use a script.
I once made one for a client: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/UML%20Profile/Synchronize%20Steretoypes.vbs

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Updating element Tags
« Reply #2 on: September 12, 2016, 08:35:36 am »
Right click on your stereotype in the toolbox and select Synchronize Stereotype.

The function is also available globally and for individual elements via the API.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1405
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Updating element Tags
« Reply #3 on: October 06, 2016, 08:54:10 pm »
Whilst synchronising a stereotype that has the same name is possible, it's more complicated when one has renamed a stereotype.
In version 1, I have a simple StereotypeA on UML classes.
In version 2, I've renamed it to StereotypeB and added a property (tagged value in stereotyped classes).

Shouldn't EA find that the stereotype has the same guid and should rename the stereotyped elements accordingly?
Since this is not the case, has anyone carried a script to achieve this? I'll give it a try for a script that should achieve the following:
- purpose: rename and sync stereotypes
- create 2 arrays, one with the stereotype name in the previous version, and one with the stereotype name in the new version
- for each entry in array 1,
    retrieve all elements which stereotype = stereotype name in the array
    rename the elements stereotype with the new stereotype name
- run the sync command on the new stereotype name


Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Updating element Tags
« Reply #4 on: October 06, 2016, 09:06:25 pm »
A stereotype has no GUID.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Updating element Tags
« Reply #5 on: October 07, 2016, 10:39:14 am »
A stereotype has no GUID.

q.
A local stereotype (non-MDG related) is assigned a local GUID, which is a problem if you have more than one repository interchanging information.

The t_stereotypes tale has a GUID column and that value is used in the t_xref table for Stereotypes rows to differentiate MDG vs non-MDG related stereotypes.  It's causing us a lot of problems at the moment since EA insists on creating local stereotypes with the same names as MDG ones and gets mixed up.

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: +397/-301
  • I'm no guru at all
    • View Profile
Re: Updating element Tags
« Reply #6 on: October 07, 2016, 07:35:37 pm »
Paolo, the stereotype used in elements is just text and not a reference to some table. So it effectively has no GUID.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Updating element Tags
« Reply #7 on: October 10, 2016, 09:04:51 am »
Guillaume, the only time stereotypes have guids is when they are directly in the model instead of a profile. In this scenario there are no tagged values associated with the stereotype, so synchronization couldn't do anything.

As Paolo suggested, the t_xref table will reference a guid if the stereotype has been defined using the stereotypes list for the model.

For any stereotypes defined in a profile, the t_xref table will contain an FQName, which allows you to identify which profile the stereotype comes from.

If you are writing a script to convert between two stereotypes, you will need to update t_xref and t_object (or whichever type of element you are updating.) If they ever get out of synch EA will try to find the stereotype in t_object and save it to t_xref, creating a stereotype if none matches.

Paolo, it sounds like EA is deciding that the t_object and t_xref stereotype definitions are out of synch. It could be creating a new t_stereotypes record because it doesn't think that the stereotype can be applied to the element so no match is found.

You may also find it worthwhile to go into the user/group permissions and disable 'Configure Stereotypes' for all users. (Potentially leaving your admin users until cleaning up the rogue entries)

Qwerty, claiming a "fact" in presence of evidence to the contrary doesn't make you look good. Yes, t_object, t_attribute etc do not reference a stereotype by guid, but stereotypes can and often do have guids.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Updating element Tags
« Reply #8 on: October 10, 2016, 10:39:29 am »
Thanks Simon,

I'd already come to the conclusion you did, but didn't know what to do about it.  I'll try your suggestion whenI get into work...  It's becoming a real pain, but I can't blame EA for it.  As you know we're doing a a lot of bleeding edge stuff out here and so it's probable, we'd hit some potholes on the way.

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: +397/-301
  • I'm no guru at all
    • View Profile
Re: Updating element Tags
« Reply #9 on: October 10, 2016, 04:52:39 pm »
Qwerty, claiming a "fact" in presence of evidence to the contrary doesn't make you look good. Yes, t_object, t_attribute etc do not reference a stereotype by guid, but stereotypes can and often do have guids.

So what would be the stereotype-GUID of something with a stereotype? Respectively, how would I find it out?

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Updating element Tags
« Reply #10 on: October 10, 2016, 05:04:26 pm »
Qwerty, claiming a "fact" in presence of evidence to the contrary doesn't make you look good. Yes, t_object, t_attribute etc do not reference a stereotype by guid, but stereotypes can and often do have guids.

So what would be the stereotype-GUID of something with a stereotype? Respectively, how would I find it out?

q.

A good place to start is something like:

Code: [Select]
SELECT * FROM t_xref WHERE Name='Stereotypes' AND Description LIKE '#WC#GUID={#WC#'
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Updating element Tags
« Reply #11 on: October 10, 2016, 06:36:03 pm »
Actually I asked for
Code: [Select]
SELECT Description FROM t_xref WHERE Name = 'Stereotypes'  AND Description LIKE  '#WC#Name=<Search Term>#WC#'  GROUP BY Description and then pull out the GUID from the string (I know that SQL can do that, but I can't).

As a side note (since I had a DB-import in a test): I got GUIDs for the <<column>> but not for the <<table>>. So as I said: a stereotype does not have a GUID. The best I can come down to is: It MIGHT have a GUID.

q.
« Last Edit: October 10, 2016, 06:39:54 pm by qwerty »