Book a Demo

Author Topic: Changes in Automation interface ?  (Read 3911 times)

Ced

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Changes in Automation interface ?
« on: January 26, 2011, 11:36:16 pm »
Hello,

I have a program written in Java that uses the automation interface of EA. The program was working fine until I had to reinstall my computer and reinstalled a new version of Enterprise Architect. I noticed difference in behavior between the two versions. Initial version was 7.x (I don't remember the minor version) and the new version is 8.0.

The changes I discovered are:
1) When retrieving elements of a package, you could just call the GetElements method of the package handle. This would retrieve all elements in the package, even those which were children of other elements in the package. In version 8.0 however, you only retrieve the "root" elements and have to call GetElements on those root elements to retrieve their children elements (and so recursively until all elements of a package have been retrieved). This can be fixed quite easily by simply using recursion has said before, but was this change intended ? Because it seems like a rather important change in behavior.
2) Because of that change, my code to remove an element from a package is broken too (earlier, I simply had to retrieve all elements from the package, iterate over them to find my element and then simply call DeleteAt with the correct index). How does it react when you try to delete elements having child elements ?

Thanks,
Cédric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Changes in Automation interface ?
« Reply #1 on: January 27, 2011, 12:40:44 am »
Cedric,

The change in behavior package.Elements was indeed intended.
You can see it as a bug fix with major repercussions. (I had to rewrite parts of my addins as well).
I don't know about the deleteAt() function. I think it should delete the element with all its subelements, but I haven't tested that yet.

Geert

Ced

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Changes in Automation interface ?
« Reply #2 on: January 27, 2011, 12:57:28 am »
Geert,

Thanks for your reply. I've changed my code to remove element to take that into account and now it works fine.

I also encountered another change in behavior, but which seems very strange: setting a stereotype on an element which is a child of another element modifies the stereotype name. I'll take an example to make things clear:
Suppose that I want to apply the stereotype "Goal" to all requirements that I create programmatically. I set the stereotype by calling the SetStereotype method on the Element. This works fine when the element is not a child from another element. As soon as the element is a child of another element, the stereotype name is changed to "goal" (so, the first upper case letter is replaced by a lower case).
This seems really akward to me and I do not find a logical reason for such a change in behavior. I really debugged to verify if the problem was not in my code but I really pass "Goal" and not "goal" to the SetStereotype method (and I don't call it anywhere else). Furthermore, before the change of EA version I didn't have that problem.

Thanks,
Cédric

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Changes in Automation interface ?
« Reply #3 on: January 27, 2011, 01:08:49 am »
Cédric,

I haven't noticed that issue yet, it might have something to do with existing stereotypes in the database.
Anyway, I tend to always have my stereotypes in small caps. I feel it looks nicer that way.

Geert

Ced

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Changes in Automation interface ?
« Reply #4 on: January 27, 2011, 01:51:34 am »
Geert,

Indeed, it seems that it is linked to stereotypes that exist in the EA database (it was defined with a lower case 'g'). If I change it to "Goal", then everything works fine.

Anyway, it is a bit strange that this is not consistent: I would agree if all elements would use the name defined in the database. But if only elements which are children of other elements use the name defined in the database, it is not really consistent.
Furthermore, it is also strange that this behavior didn't occur in the previous version of EA.

Anyway, my problem is solved, so thank you.

Cédric