Posts

Showing posts with the label java

Creating Items in Sparx EA via Java

Introduction This short post provides guidance on how to create "things" in a Sparx EA model via the Java API. Theory Creating "things" in EA via Java is driven by the Add New method and the Collection class. The first example in the code is adding a "view" to an existing root node. The code below will retrieve the root GUID if the "i" variable is set to 0; rootPackageID = rep . GetModels (). GetAt ( i ). GetPackageGUID (); After obtaining the root GUID it is possible to create a view under the root node. Note the process of retrieving the packages under the root and placing them in a collection. The Add New process is driven from the Collection. Importantly, for a view, the code needs to set a flag which indicates a particular icon. This process is only required for views. org . sparx . Package root = rep . GetPackageByGuid ( rootPackageID ); // get the root Collection < org . sparx . Package > subPackages = r...

Traversing a EA Model via Java

Traversing an Enterprise Architect model from Sparx Systems is relatively simple. This blog introduces the concept of model traversal via the Java API. For information on Java Set-Up see this blog entry . The first step is to obtain the repository object as it provides the anchor from which all other operations are derived. In the example below, a repository is held on the file system. The variable "repoLocation" holds the file system location of the "eap" file.   rep = new Repository();  // get a repository   rep.OpenFile(repoLocation);  //open the repository file At the top of a model is a root node and it is typically where you want to start when traversing a model. From the root node you can then obtain a collection of packages. At this point, it is easy to traverse the collection pulling in the packages via a loop and in this example printing out their names. To see the complete example, go to GitHub .   org.sparx.Package my...

Java and Enterprise Architect from Sparx Systems – Getting Started

Image
This is the first in a series of blogs relating to the use of Java with  Enterprise Architect (EA)  from Sparx Systems. The purpose of the blogs is to provide a starting point for Java programmers in their use of the language with EA. The  official post  from Sparx Systems is to use Java as a scripting language within EA. While this is useful, I have a preference to create Java applications outside of EA. The diagram below describes how a Java application can be created which interfaces into the  Sparx Object Model . The  connection  between the Java application and EA is a COM object (SSJavaCOM.dll) provided by EA. This  page  from EA provides information on how to install the COM object within your windows environment. The Java application’s “view” of the Object Model is via a JAR file ( eaapi) which provides the  linkage  between the COM object and the Java software. I use  Netbeans  for Java Develop...