Book a Demo

Author Topic: Automation Interface: Attribute Order  (Read 7930 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Automation Interface: Attribute Order
« on: May 11, 2009, 09:07:32 pm »
Hej allihopa!


When I use the Automation Interface (Java) to create classes, the attributes end up ordered by name, not the order specified. I'm just calling elements.AddNew() a number of times.

The thing is, while the order is not important in UML I am in fact creating classes which, in the next transformation step, will get turned into Enumeration types. In other words, I do want the order preserved.

Is there a way of doing this in the Automation Interface?

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Automation Interface: Attribute Order
« Reply #1 on: May 11, 2009, 09:21:50 pm »
Have you tried EA.Attribute.Pos?

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Automation Interface: Attribute Order
« Reply #2 on: May 12, 2009, 12:16:36 am »
I hadn't, and it works like a charm.

Thanks, Frank!

You (or anyone else) wouldn't happen to know how often it makes sense to call Update(), would you?
Right now I'm calling it after every single change I make to an element; would it be OK to call it once after I've done all the changes I need to do (such as calling it once on a class after I've added the stereotype and all the elements)?
And would that give me any sort of performance improvement?

/U
My theories are always correct, just apply them to the right reality.

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Automation Interface: Attribute Order
« Reply #3 on: May 12, 2009, 06:05:21 am »
Quote
You (or anyone else) wouldn't happen to know how often it makes sense to call Update(), would you?
Right now I'm calling it after every single change I make to an element; would it be OK to call it once after I've done all the changes I need to do (such as calling it once on a class after I've added the stereotype and all the elements)?
And would that give me any sort of performance improvement?

Uffe,

I wish I knew. Last time I experimented with the API I ended up calling update and refresh everywhere, and certainly more often than necessary, and to hell with performance. Those who are in the habit of fiddling directly with the database might know. At least I guess that you can set all properties which will be written to the same table before calling update. If this is so, you ma well gain performance this way.

Frank

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Automation Interface: Attribute Order
« Reply #4 on: May 12, 2009, 05:31:02 pm »
Update() will save the properties of an object to the database, think name, notes etc..
Refresh() will save the changes made to a collection such as element.attributes.

Usually it is enough to update or refresh after making all the changes to an element, except when creating new elements. Then you need to call update right after you created it (that will give it its ID). Only then you can continue to work with it.

... I think ... :-?

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Automation Interface: Attribute Order
« Reply #5 on: May 13, 2009, 08:27:25 am »
That's pretty much right Geert.

Update is a save.  You basically need to call it when you've finished changing something.  Also, there are some things that you can't do with a new object until it is saved.  So it is easier to save it immediately after it is created.

Refresh doesn't actually save anything.  What it does is updates the in memory representation of a collection from the database.  So if you've added an attribute, or removed one and you want to iterate over the attributes again, you will need to call it.

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Automation Interface: Attribute Order
« Reply #6 on: May 13, 2009, 03:47:44 pm »
Quote
Update is a save.  You basically need to call it when you've finished changing something.  Also, there are some things that you can't do with a new object until it is saved.  So it is easier to save it immediately after it is created.

Which still leaves the question whether you can improve perfomance by calling update only when necessary. And what exactly are the "some things" you can't do with a new object before? I suppose these are things involving a reference to the new object (like a new connector).