Book a Demo

Author Topic: HOw to change the FQStereotype attribute?  (Read 13490 times)

roman104

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
  • Right Information - In Right Time - for Right Role
    • View Profile
    • Right Information - In Right Time - for Right Role
HOw to change the FQStereotype attribute?
« on: May 04, 2017, 07:32:48 pm »
Hi all,
During the lifecycle of MDG I was forced to change the name of Profile. The names of stereotype are still the same.
Side effect of this is, that all instances has lost references to correct stereotype in modified MDG in production model.
I can correct it in 2 clocks on every element impacted by this change.
Problem is , there is approximately 1000 affected elements.
I am looking for the way, how to automate this issue.
I have found element attribute FQStereotype, but it is R/O.
I could change the attribute in database directly, but I am afraid of side effects.
Do You have some ideas, how to automate this ?
Thank You very much
Roman

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #1 on: May 04, 2017, 07:52:52 pm »
Vaguely remember having the same problem about  6 or 7 years ago. Might be able to do it via jscript/vbscript and the API. Some things to try;
a) Re-synch the stereotypes or
b) Set the stereotype value using stereotypeex using jscript/vbscript and the API.
c) Export to CSV then import guid, name, object_type and stereotype fields preserving the hierarchy.
d) Try making copy of respository and change the column(s) via SQL.  Usually I create a new object to see what the columns are populated so I have a half decent chance  of making mods to the DB correctly.

Sorry can't remember the details of how I fixed it- too long ago. Hope that provides some ideas you can try.
« Last Edit: May 04, 2017, 08:02:25 pm by Sunshine »
Happy to help
:)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: HOw to change the FQStereotype attribute?
« Reply #2 on: May 04, 2017, 09:02:03 pm »
Roman,

I had a client with a similar issue and used this script to fix it.
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/Project%20K/KING%20Scripts/Rename%20Stereotypes.vbs
I'm not saying that it will work exactly as written to solve your problem, but it might help finding the solution.

Geert

roman104

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
  • Right Information - In Right Time - for Right Role
    • View Profile
    • Right Information - In Right Time - for Right Role
Re: HOw to change the FQStereotype attribute?
« Reply #3 on: May 05, 2017, 03:46:24 pm »
Hi Sunshine,
Thank You very much for Your answer.
I appreciate this.
Unfortunatelly, I cannot make use most of them.
a) Re-synch the stereotypes or
In moment I do re-synch stereotypes (via toolbox after importing modified MDG), all existing instances (about 800) will lost its element script shape.
The user will be afraid that something is wrong. remedy is very simply.
Click on element, select stereotype, select profile, select stereotype. OK. It works.
But it take approximately 10-15 seconds per element...
b) Set the stereotype value using stereotypeex using jscript/vbscript and the API.
I need to verify, if this attribute is R/W and if it will accept stereotype defined in MDG.
c) Export to CSV then import guid, name, object_type and stereotype fields preserving the hierarchy.
This approach seems to me very complicated and time consuming. It shold be less than 5 hours. This is expected time for routine remedy. :o
d) Try making copy of respository and change the column(s) via SQL.  Usually I create a new object to see what the columns are populated so I have a half decent chance  of making mods to the DB correctl

This approach it seems to me straightforward, but with respect that could be side effects.
Not technically, but via possible accidentally human error.
Playing on production data in SQL. But it could be done in 2 steps.
1st in test environment, and after success tests into production.
I have another constrain. The repository is in MS SQL and I have no direct access to it.
We are accessing repository via cloud services.
e) Brute force
Simple, secure,  "stupid" routine work... but predictable time, predictable results...

Currently I will try to test the script which mentioned Geert, and sent feedback to YOu.
Thank You very much.
Have a nice day
Roman

roman104

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
  • Right Information - In Right Time - for Right Role
    • View Profile
    • Right Information - In Right Time - for Right Role
Re: HOw to change the FQStereotype attribute?
« Reply #4 on: May 05, 2017, 03:55:48 pm »
Hi Geert,
Thank You for Your reaction,
I am trying this code and give You feedback.
Roman

roman104

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
  • Right Information - In Right Time - for Right Role
    • View Profile
    • Right Information - In Right Time - for Right Role
Re: HOw to change the FQStereotype attribute?
« Reply #5 on: May 05, 2017, 04:39:49 pm »
Hi Geert,
I have tried the script. It looks very comprehensive.
It seems to me it doesn't work for me in this moment.
Probably due to fact, it works directly with element attribute 'stereotype'.
I have found that I have to impact the   Attribute 'FQStereotype'.
I haven't found the method in element class to change this attribute directly.
That means it could be managable via method to change/rename stereotype, but argument have to contain reference to profile.
Example:
My stereotype name is 'AMT_DT_GDT_GenericDiagramTable_Object'
in both profiles is the same.
Full Qualified name are:

Old FQstereotypePath: 'Profiles for ATM-KPI-3.1::AMT_DT_GDT_GenericDiagramTable_Object'
New FQstereotypePath: 'Profiles for ATM-KPI::AMT_DT_GDT_GenericDiagramTable_Object'

When I have used Your script, with arguments above it didn't change the FQstereotypePath.
Maybe due to :: in the arguments.
API function for working with stereotype it could work. I need to try.
Thank You very much
Roman

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #6 on: May 05, 2017, 04:46:01 pm »
Hey Roman,

If you have only ONE Stereotype per item (in our MDG and Repository, we enforce that), then you'll find the FQStereotype in the t_xref table.

You can then safely use SQL to fix the stereotype.

We have actually automated the process so that we can define the FQStereotype against the metatype in an external file and then automagically fix it in the repository.  We can change both the base type and the stereotype and the FQ Stereotype of an item.  Makes it very useful for evolving MDGs.   WE've bene doing it for over a year and we no longer think about it - "just do it"!  ;D

HTH,
Paolo
« Last Edit: May 05, 2017, 04:50:05 pm by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: HOw to change the FQStereotype attribute?
« Reply #7 on: May 05, 2017, 04:52:13 pm »
Hi Geert,
I have tried the script. It looks very comprehensive.
It seems to me it doesn't work for me in this moment.
Probably due to fact, it works directly with element attribute 'stereotype'.
I have found that I have to impact the   Attribute 'FQStereotype'.
I haven't found the method in element class to change this attribute directly.
That means it could be managable via method to change/rename stereotype, but argument have to contain reference to profile.
Example:
My stereotype name is 'AMT_DT_GDT_GenericDiagramTable_Object'
in both profiles is the same.
Full Qualified name are:

Old FQstereotypePath: 'Profiles for ATM-KPI-3.1::AMT_DT_GDT_GenericDiagramTable_Object'
New FQstereotypePath: 'Profiles for ATM-KPI::AMT_DT_GDT_GenericDiagramTable_Object'

When I have used Your script, with arguments above it didn't change the FQstereotypePath.
Maybe due to :: in the arguments.
API function for working with stereotype it could work. I need to try.
Thank You very much
Roman
Roman,

My script was written for a similar but different issue, but it does show you how to manipulate the t_xref table (as Paolo suggests) to fix the problems.

Another option you might want to try is to use Element.StereotypeEx. Using that field in the API often fixes everything by itself (including the t_xref) so you don't have to mess with that anymore.

Geert

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #8 on: May 05, 2017, 04:54:04 pm »
I haven't looked at Geert's script, but what you may need to do is set the .Stereotype value to blank, then set the .Stereotype value to "AMT_DT_GDT_GenericDiagramTable_Object". Otherwise EA might assume the stereotype hasn't changed (because it has the same name) so won't go looking for a new profile ID.
The Sparx Team
[email protected]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: HOw to change the FQStereotype attribute?
« Reply #9 on: May 05, 2017, 04:58:02 pm »
I haven't looked at Geert's script, but what you may need to do is set the .Stereotype value to blank, then set the .Stereotype value to "AMT_DT_GDT_GenericDiagramTable_Object". Otherwise EA might assume the stereotype hasn't changed (because it has the same name) so won't go looking for a new profile ID.
Good suggestion, but I think he better uses the StereotypeEx field instead of the Stereotype field.

Geert

BruceTOGAF2

  • EA User
  • **
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #10 on: August 18, 2020, 09:03:38 pm »
I have 2 MDG Technologies "Data Architecture" and "Defra Data Architecture MVP".  Both MDGs contain a stereotye "Conceptual Data Entity" that are different from each other.


I have an element with FQStereotype "Data Architecture::Conceptual Data Entity" because it was created from a stereotype "Conceptual Data Entity" defined in a MDG Technology "Data Architecture"

StereotypeEx does not differentiate "Conceptual Data Entity" ("Data Architecture") from "Conceptual Data Entity" ("Defra Data Architecture MVP").


I want to change the stereotype of this element so that it has the stereotype "Conceptual Data Entity" defined in MDG Technology "Defra Data Architecture MVP".


The following code tries to change the FQStereotype to "Defra Data Architecture MVP::Conceptual Data Entity"


currentElement.FQStereotype = "Defra Data Architecture MVP::Conceptual Data Entity";


EA responds with "Unable to write read-only property"


How can I change the stereotype of the same element so that it has the stereotype "Conceptual Data Entity" defined in MDG Technology "Defra Data Architecture MVP"?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #11 on: August 18, 2020, 09:43:02 pm »
You need to stuff that into StereotypeEx. (It's EA, you know)

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: HOw to change the FQStereotype attribute?
« Reply #12 on: August 18, 2020, 11:05:59 pm »
Code: [Select]
currentElement.StereotypeEx = "Defra Data Architecture MVP::Conceptual Data Entity";
currentElement.Update();

Should work. (as q suggested)

Geert

BruceTOGAF2

  • EA User
  • **
  • Posts: 74
  • Karma: +0/-0
    • View Profile
Re: HOw to change the FQStereotype attribute?
« Reply #13 on: August 21, 2020, 11:01:30 pm »
Thank you querty and Geert. Your solution woks well.