Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: C. Bulach on January 26, 2010, 12:59:32 am

Title: Java API and efficient copy of elements...
Post by: C. Bulach on January 26, 2010, 12:59:32 am
I use Java API to copy a class from a package to an other one.

In my case, I can get some enumeration classes, which contain more than 5000 attributes (for 5000 distinct values...)

To do the copy, I create each element, based on the value of the original package. So in that case, I create a new class, and make a loop (5000 times) to add attributes one after the other one. This takes a long time to process...

Is there a better way to do this ?
For instance :
- use an API which allows to add several attributes at once ?
- use an API which allows to copy a class from a package to an other one  or a package to an other one ?
(I haven't found such APIs yet...)

Thanks for any information or assistance...

Christophe
Title: Re: Java API and efficient copy of elements...
Post by: Geert Bellekens on January 26, 2010, 01:57:15 am
Christophe,

One way of improving the performance is to get the data you need by a single SQL query (using Repository.SQLQuery)
Starting from that you can then create the literal values. (one by one).
That should cut the process time in half. (more or less).
Another option that presumably increases the performance is the Reposistory.EnableUIUpdates and Repository.BatchAppend, although I haven't really witnessed a real performance improvement with those. (maybe because I was not in the right circumstances)

The last option (if you are really desperate) is to insert the values in the database directly and completely bypassing the API, but I would certainly not recommend that because it can seriously screw up your model.

Geert