Book a Demo

Author Topic: Adding Database Datatypes  (Read 2849 times)

Volker Wegert

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Adding Database Datatypes
« on: May 15, 2015, 08:32:37 pm »
Hi all,

I am currently trying to add a database product and its associated datatypes  programmatically (since I haven't found a way to do this via a MDG file - or did I miss something there?). Anyway, the code mostly works: I use Repository.Datatypes.AddNew("name", "DDL"), then adjust the datatype properties, call dt.Update() followed by Repository.Datatypes.Refresh(). At the moment, I have two issues left to be solved:

  • I can't see the database product in the dialog (Project > Settings > Database Datatypes) right away - it's simply missing from the drop-down listbox. If I add the product manually, all of the data types I inserted programmatically immediately show up. Also, if I close and re-open the project, the product is immediately visible. Is there some kind of buffer-refreshing method that I could call instead of forcing the user to close and re-open the project?
  • I need to check whether the database product is present before inserting the datatypes in order to avoid duplicates. Right now, the only solution I've come up with is to check the entire list of datatypes, which takes up to 2 seconds. Can I speed this up somehow? If not, is there a way to store custom information on a project level, like a flag "custom database setup completed"?

Thanks in advance
  Volker

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding Database Datatypes
« Reply #1 on: May 18, 2015, 04:25:28 pm »
Volker,

1) You can try Repository.RefreshModelView(0) to reload the whole model, in the hope that will re-initialise the datatypes.
If not you'll have to close and re-open the project (which can be done from the add-in as well.
2) Use
Code: [Select]
Repository.SQLQuery("select dt.ProductName, dt.DataType from t_datatypes dt " +
" where dt.Type = 'DDL' and dt.ProductName = '[my product]'")
to figure out which datatype of your product are already present.

Geert

« Last Edit: May 18, 2015, 04:26:07 pm by Geert.Bellekens »