Book a Demo

Author Topic: Converting Class to Table with scripting  (Read 4952 times)

davidn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Converting Class to Table with scripting
« on: November 21, 2018, 05:58:39 am »
I'm trying to convert a Class to a Table using Javascript.
When I execute the following code (assuming currentElement is an Element), the Stereotype of the Class updates to "table", in which it takes on a blue-purplish colour. But, the Type does not update.

Code: [Select]
currentElement.Stereotype = "table"
currentElement.Type = "Table"
currentElement.Update();

However, when I select the updated element in the project browser, I still see that it is Class : <name>.

How can I convert perform a Type conversion Class to Table using scripting (specifically Javascript)?

Thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Class to Table with scripting
« Reply #1 on: November 21, 2018, 06:10:54 am »
Try to also set the stereotype to "table" since in the DB it appears to have that besides type="Table" to be set.

q.

davidn

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Converting Class to Table with scripting
« Reply #2 on: November 21, 2018, 07:20:57 am »
Hey qwerty,

I'm already updating the Stereotype to be "table" as seen in the code.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Class to Table with scripting
« Reply #3 on: November 21, 2018, 08:58:07 am »
Uh. I always forget to read before I reply. :-(

Try StereotypeEx instead.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Converting Class to Table with scripting
« Reply #4 on: November 21, 2018, 09:03:56 am »
Try EAUML::table
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Class to Table with scripting
« Reply #5 on: November 21, 2018, 11:25:18 am »
Aaaaah. That was in my head too. And now I remember that just recently there was a similar question.

q.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Converting Class to Table with scripting
« Reply #6 on: November 21, 2018, 11:44:54 am »
Here is a trick. When translating an object type from one to another try creating that target object type first, then retrieving those values so get to know what values you need. Write the code to put those values you've retrieved into your code to translate the object types. Saves a guess work along with a lot of time and energy.
:)
Happy to help
:)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Class to Table with scripting
« Reply #7 on: November 21, 2018, 11:03:06 pm »
Though, in that case the db table columns shows "table" while you actually need to supply "EAUML::table". So not obvious here. But generally that's the way to go :-)

q.