Book a Demo

Author Topic: Changing Stereotypes  (Read 7337 times)

YogaMatt

  • EA User
  • **
  • Posts: 111
  • Karma: +8/-0
    • View Profile
Changing Stereotypes
« on: December 06, 2016, 03:31:03 am »
Several hundred model elements were stereotyped "PhysicalDataComponent" (PDC) when they should be "PhysicalApplicationComponent". (PAC)
Manually changing them is one option  ;D

Updating the value in Stereotype field in the SQL t_object table gets you some of the way there. But there seems to be some 'hangover' where the old PDC stereotype still exists as a second stereotype in the browser. It will switch off if I manually go to the element properties and disable that PDC stereotype. Again, manually changing them is one option  ;D

Back to SQL I found that the t_objectproperties table held entries for each element, which were for the tags that came with the PDC stereotype. Deleting these entries cleared the PDC stereotype from about half of my elements. But not all. And now I'm wondering if anyone out there knows the underlying schema well enough to suggest where this ghost is hiding, please?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing Stereotypes
« Reply #1 on: December 06, 2016, 03:58:41 am »
You shouldn't be doing that. t_xref also holds vital information which is not easy to change. Better use a small script to change the stereotype. That is much safer and will be fast enough too.

q.

YogaMatt

  • EA User
  • **
  • Posts: 111
  • Karma: +8/-0
    • View Profile
Re: Changing Stereotypes
« Reply #2 on: December 06, 2016, 04:04:26 am »
Thank you Qwerty
I understand the caution.
Your suggestion is to use side scripting on the Sparx client?
I've not done anything with that yet.
I looked into it on the help files but was put off by apparent complexity.
Please can you point me at some clear examples / pointers to get started?
Namaste
YM

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing Stereotypes
« Reply #3 on: December 06, 2016, 05:29:38 am »
You can run
Code: [Select]
Repository.SQLQuery("SELECT object_id FROM t_object WHERE stereotype = 'wrongstereo'") and parse the XML result. Take the single object_ids and issue
Code: [Select]
theElement = Repository.GeElementByID(<theId>)which will return the appropriate object. Now you can change the stereotype with
Code: [Select]
theElement.stereotype = "newStereo"
theElement.Update/(

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Changing Stereotypes
« Reply #4 on: December 06, 2016, 08:29:03 am »
You can run
Code: [Select]
Repository.SQLQuery("SELECT object_id FROM t_object WHERE stereotype = 'wrongstereo'") and parse the XML result.
Even better:
Code: [Select]
collection = GetElementSet("SELECT Object_ID FROM t_object WHERE Stereotype = 'wrongstereo' ",2);There's no parsing to be done for that function. You get a list of elements pre-loaded.

It's also a good idea to get in the habit of matching the case of column names from the db definition as some databases will fail and you never know if you'll need to migrate at some point.

You can also assign a fully qualified stereotype name if your stereotype comes from a profile.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Changing Stereotypes
« Reply #5 on: December 06, 2016, 09:32:45 am »
I always forget this. The help doesn't even list that option:

Quote
Collection (of type Element)

Notes: Returns a set of elements as a collection based on a comma-separated list of ElementID values. By default, if no values are provided in the IDList parameter, all objects for the entire project are returned.

Parameters

    IDList: String - a comma-separated list of ElementID values
    Options: Long - modifies default behavior of this method

               1 - Returns empty collection when empty IDList parameter is given

               2 - Use IDList string as an SQL query to populate this collection

q.