Author Topic: How to Clear Stereotype  (Read 1893 times)

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
How to Clear Stereotype
« on: November 29, 2022, 09:34:11 pm »
I have my profile to import my stereotypes.
Now, I deleted one of my stereotypes from my profile an imported my profile again.
Unfortunately I have not reset all usages of the deleted stereotype prior to importing my profile that misses it.

I could not find a way to reset the stereotype at the using elements.

How to clear the stereotype field of an object, if the stereotype no longer exists in any profile?
Rolf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13065
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to Clear Stereotype
« Reply #1 on: November 29, 2022, 09:46:10 pm »
The idea is that you uncheck the box next tot he stereotype, but I can imagine that EA won't show the checkbox in your case.

Have you looked in the "<none>" perspective?

If that doesn't work you can

- Re-import your old profile, and remove all the stereotypes that way
- Write a script that updates the stereotype of all instances.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: How to Clear Stereotype
« Reply #2 on: November 29, 2022, 10:11:06 pm »
You could scan t_xref. They still  loiter there with the old profile name.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8559
  • Karma: +254/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to Clear Stereotype
« Reply #3 on: November 30, 2022, 12:28:19 am »
You could scan t_xref. They still loiter there with the old profile name.

q.
Indeed, they do!

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

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: How to Clear Stereotype
« Reply #4 on: December 01, 2022, 12:07:13 am »
@Geert: I am used to <none> profile. But for some reasons its not shown to be chosen. Maybe, because its a stereotype of a connection, not of an element.
@qwerty: Do you mean, I should should access the .qea file as a database?
Rolf

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13065
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to Clear Stereotype
« Reply #5 on: December 01, 2022, 12:29:05 am »
@Geert: I am used to <none> profile. But for some reasons its not shown to be chosen. Maybe, because its a stereotype of a connection, not of an element.
@qwerty: Do you mean, I should should access the .qea file as a database?
I think it's not shown in teh <none> profile because EA sees it as a fully qualified stereotype belonging to your (old) profile.
And they won't show it as part of your profile, because it doesn't exist there anymore.

You could report this as a bug, as EA should always provide a method to remove a stereotype, even if the original profile is no longer available.

In the meantime you can get by with the other workarounds I mentioned.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: How to Clear Stereotype
« Reply #6 on: December 01, 2022, 12:31:13 am »
You can read the t_xref wirh repository.sqlquery and eventually run updates with repository.execute. Works with any DB that EA supports. You just have to care about the "tiny" variants in the SQL syntax.

q.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1063
  • Karma: +28/-8
    • View Profile
Re: How to Clear Stereotype
« Reply #7 on: December 01, 2022, 01:29:47 am »
Hi Rolf,

What version of Sparx EA are you using? I noticed some strange behaviour concerning stereotypes with v16.x but I cannot articulate it because I have not explored it in depth.

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: How to Clear Stereotype
« Reply #8 on: December 01, 2022, 02:43:38 am »
@Geert: I found the xml of the former profile, imported it, unchecked the old stereotype, and re-imported the newest profile. Seems to be solved now. Sure, it is an omission in UI specification. But I guess, not many users are burdened by it. And there is a workaround, if you have good version control.

@qwerty: Using Dbeaver I had a look at t_xref (there is no t_ref) and found the used stereotype by 'Description like "*<the old stereotype>"'. Made a copy of the model and deleted those line. Works great as well. If you want to rename a stereotype that is used often, this seems to be a good method. Also the omission of renaming a stereotype looks like a point for improvement.

@Modesto: EA16.0 1605
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: How to Clear Stereotype
« Reply #9 on: December 01, 2022, 03:47:23 am »
Well, yes, there is no t_ref. I didn't mention such a table, did I? :-/

Anyhow, whenever we migrated profile versions I had a script doing the fix-/clean-up like that. This way we could also manage renaming of stereotypes. One should know what he/she is doing since such DB manupulations can be hazardous.

q.

ngong

  • EA User
  • **
  • Posts: 269
  • Karma: +1/-2
    • View Profile
Re: How to Clear Stereotype
« Reply #10 on: December 01, 2022, 10:37:33 pm »
Ok qwerty, sorry, you never mentioned t_ref, that I have looked for.

Would you mind to share your script doing the fix-/clean-up of stereotypes?
Rolf

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: How to Clear Stereotype
« Reply #11 on: December 02, 2022, 12:05:16 am »
Well, it's for a customer and so I can't. And it's always for a special migration, so not useful for others.

But basically it's a string search for the <myProfile>::<myOldStereotype> in t_xref. Python snippet using some framework you must guess:
Code: [Select]
for (xrefid, desc) in rep.query("SELECT xrefid, description FROM t_xref WHERE name = 'Stereotypes' AND description LIKE '%smyProfile::myOldStereotype%s'" % (wc, wc)):

When changing some result like
Code: [Select]
@STEREO;Name=myStereo;FQName=myProfile::myStereo;@ENDSTEREO;you have to alter the stereotype in Name and FQName. Also you need to retrieve the element itself and fix it's stereotype property.

It's always done with a number of test runs in the sandbox before running it in production. Backups are essential, though luckily we never needed them.

q.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1063
  • Karma: +28/-8
    • View Profile
Re: How to Clear Stereotype
« Reply #12 on: December 02, 2022, 04:39:03 am »
@Rolf - From memory, what I noticed in the UI is that there is no "None" option when assigning the stereotype. The only way to clear an "orphan" appears to be to deselect it (clear the checkbox), click on apply and assign it to another stereotype. I have a vague recollection that just clearing it does not work.

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: How to Clear Stereotype
« Reply #13 on: December 02, 2022, 06:26:38 am »
@Rolf - From memory, what I noticed in the UI is that there is no "None" option when assigning the stereotype. The only way to clear an "orphan" appears to be to deselect it (clear the checkbox), click on apply and assign it to another stereotype. I have a vague recollection that just clearing it does not work.
Almost. You can create a new stereotype with the New button. However, EA first searches existing profiles for the name and takes what it finds (I needed a <<singleton>> and it was miraculously an OWL::singleton then). Only then it ends up in the <none> profile. I think. But pretty sure, though.

q.