Overview
CA Gen allows applications to access the currently opened model through a mechanism that is known as a plug-in. The application should register itself in the Windows registry, and from there the CA Gen toolset knows how to call it. Toolset adds a menu item to the CA Gen “Plug-in” menu. The developer starts plugin from the toolset after Toolset opens model for processing.
You will find more information about CA Gen Toolset Automation here.
However, there is a problem when you are willing to develop something in Java language. The problem is because the plug-in application should instantiate a pointer to the currently opened toolset using the toolset OLE automation interface. Such interface allows the application to access the functionality provided by the interface. Unfortunately, Java program cannot do it without using some software bridging those two different technologies.
Fortunately, Eclipse is using the SWT GUI framework. SWT does allow to integrated Microsoft application via OLE (Object Linking and Embedding). You can locate jar file org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar
in the subdirectory of your Eclipse installation. Subdirectory name is plugin.
It has the SWT Win32 OLE implementation classes. Classes provide the public API to the Microsoft Win32 Object Linking and Embedding mechanism that the win32 variant of SWT is capable of using. Referencing any of the classes in this package directly guarantees that the code is platform specific.
You can consult tutorial “Microsoft and Java Integration with Eclipse” written by Lars Vogel here. It helps understand the SWT Win32 OLE implementation classes and shows examples of the use.
Idea developing plugs using Java resulted in the need for some easier ways to access the Gen model and hide the complexity of the SWT Win32 OLE implementation classes. The Toolset Automation Wrapper is a package of Java classes doing just that. The Toolset Automation Wrapper does not cover all functionality offered by the Toolset Automation.
You can download Java documentation and jar file with the wrapper classes here.
You can find Eclipse project on GitHub here.
Sample Application
Sample application connects to the currently opened model in the CA Gen Toolset and lists all business systems defined in the model. The application is a simple Java class with the method main().
You need to run the application from the command line. Yon need be sure that you have two jar files on the classpath. They are jmmi
and ToolsetAutomationWrapper
.
Here is the source of the application:
package eu.jgen.notes.automation.example; import com.ca.gen.jmmi.schema.ObjTypeCode; import com.ca.gen.jmmi.schema.ObjTypeHelper; import com.ca.gen.jmmi.schema.PrpTypeCode; import com.ca.gen.jmmi.schema.PrpTypeHelper; import eu.jgen.notes.automation.wrapper.JGenEncyclopedia; import eu.jgen.notes.automation.wrapper.JGenFactory; import eu.jgen.notes.automation.wrapper.JGenModel; import eu.jgen.notes.automation.wrapper.JGenObject; public class ListAllBusinessSystems { public static void main(String[] args) { // create instance of the factory class JGenFactory factory = JGenFactory.eINSTANCE; // create instance of the encyclopedia JGenEncyclopedia ency = factory.createEncyclopedia(); // connect to the encyclopedia (model needs to be opened in the toolset // already) ency.connect(); // select model for processing JGenModel genModel = ency.findModels()[0]; System.out.println(genModel.getName()); // find all business system in the model JGenObject[] bussyss = genModel.findTypeObjects(ObjTypeHelper.getCode(ObjTypeCode.BUSSYS)); for (JGenObject bussys : bussyss) { System.out.println(bussys.findTextProperty(PrpTypeHelper.getCode(PrpTypeCode.NAME))); } } }
The application will print the following messages on the console for the sample.ief model which is coming with the standard CA Gen installation on the workstation.
GEN SAMPLE MODEL 8 6 CORPORATE_MANAGEMENT GUI_CORPORATE_MANAGEMENT COOP_CORPORATE_MANAGEMENT
Summary
Solution and sample application have been developed using the following software:
- Windows 10
- CA Gen 8.6 (Free)
- Java Version 8 (Update 20)
- Eclipse Neon.3 Release (4.6.3)