1
votes

In the Reference of the Enterprise Architect Object Model I found the class Element: http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/element2.html

The class Element contains the attribute IsComposite. I use the Java API (eaapi.jar) of Sparx Systems and can't find the Setter for this attribute (myElement.SetIsComposite(true) isn't possible).

Does anybody know a solution for this problem? For example an updated lib of eaapi.jar or a workaround?

Regards, Phil

1
If the attribute is public (it is also marked as read/write), just use it straight away: myElement.IsComposite = true; - sybear
Getter and setter methods are just a general approach of using OOP, but in some cases they are not necessary. - sybear
Hello Jari, thank you for your fast comment. I had already try to set this attribute in this way. But it seems, that the attribute isn't public. For other boolean attributes of the class Element are Getter&Setter available:/ I guess that the author of the library forget this:( - phil

1 Answers

1
votes

EA's Java API is a wrapper for the underlying COM API, which is what's documented in the help file. The Java version is generally a step or two behind the COM version.

It would appear that this method has been left out of the Java API. Other properties in the COM classes have getters/setters in the Java API, but this one doesn't. The same is true in version 10.0.1009.

In EA 11.0.1105 (the first general release of EA 11), Element.SetCompositeDiagram() was added, but this too seems to be limited to the COM API: reverse-engineering eaapi.jar reveals no corresponding method.

From here there would appear to be three alternatives open to you:

  1. Report the issue to Sparx Systems and ask them to add the relevant methods to the Java API.
  2. Rewrite your code in C# to make use of the full API.
  3. Use the undocumented Repository.Execute() method to manipulate the underlying database directly.

An element's "compositeness" is represented by the value 8 in the t_object.NType column, but this column is overloaded, that is to say the interpretation of its value depends on other columns as well, and furthermore is undocumented. So this is not a good solution if you want maintainability.

If you want to go this way, first add the diagram and then do something like this:

repository.Execute("update t_object set NType = 8 where Object_ID = " +
                   element.ElementID);

I think that would work, but I haven't tested it. If there are more than one diagrams in the element, I think the first one gets picked. But all this is essentially guesswork, so if you want to build something that you know will work, switch to C#.