Rhapsody Application Accessors

Overview

Below are the accessors that connects to the active Rhapsody application to read or write models.

Model readers:

Model writers:

Rhapsody OMRoot

Those accessors use the Rhapsody APIs to connect to the active application. Those APIs are located in the Rhapsody Share folder, internally known as the Rhapsody OMRoot. The Share folder typically contains the following sub folders: JavaAPI\rhapsody.jar, Profiles, Properties etc.

Depending on your operating system and Rhapsody version, the Share folder can typically be found in the Rhapsody install directory or within the user home directory (e.g. "C:\Program Files\IBM\Rhapsody\<version>\Share").

Here is how the accessors determine the Rhapsody OMRoot location:

  1. A System property "rhapsody.omroot" may be used to set the location.
    Please refer to this documentation for details on how to set a System property in Eclipse:
    Platform Plug-in Developer Guide > Reference > Other reference information > The Eclipse runtime options.

  2. A Windows environment variable "rhapsody.omroot" may be used to set the location.

Rhapsody Application & On-Demand Accessors Properties

These accessors have a predefined behaviour described by a set of properties.

Note that the default value is always underline.

Reader Settings

Writer Settings

Customize behaviour

The behaviour can be customized in static mode

Theses accessors are provided by two plugins, located in your eclipse plugins folder a sub-folder.

The plugin corresponding to Rhapsody Application accessors is named com.sodius.mdw.metamodel.rhapsody.com_Iyyyymmdd
(where yyyymmdd is a timestamp like 20150913).

The plugin corresponding to Rhapsody O-Demand accessors is named com.sodius.mdw.metamodel.rhapsody.proxy_Iyyyymmdd

Open one of these folders and locate this configuration files: mdw.ini.

A second configuration mdw_nographics.ini is exclusively dedicated to the accessor Rhapsody Application (no graphics).

Edit one of this file according to your needs.

The behaviour can be customized in runtime mode

An example in Java to write a model into Rhapsody.

We use here the class com.sodius.mdw.core.model.Model as parameter:

    private static void writeModel(Model source) throws CoreException {

        Application app = (Application) source.getInstances("Application").first();
        
        // Always get active project only !
        Project proj = app.getActiveProject();
           
        com.sodius.mdw.metamodel.rhapsody.Package newPkg = source.create("Package");
           
        newPkg.setName("Hello");
           
        proj.getPackages().add(newPkg);
        
        //Setuping the update writer
        List modifiedUnits = new ArrayList();
        modifiedUnits.add(newPkg);
        source.getMetamodel().getModelWriterDescriptor("Rhapsody Application")
                  .setProperty("unitsToReplace", modifiedUnits);
        
        // Update model in Rhapsody
        source.write("Rhapsody Application", null);        
    }
	

The same process implemented in a TGL or MQL:

  public ruleset UpdateModel(in source : rhapsody) {

	  public rule myRule() {
		var app : rhapsody.Application = source.getInstances("Application").first();
		
		// Always get active project only !
		var proj : rhapsody.Project = app.activeProject;
		   
		var newPkg : rhapsody.Package = source.create("Package");
		   
			newPkg.name = "Hello";
		   
		proj.packages.add(newPkg);
		
		//Setuping the update writer
		var modifiedUnits : java.util.List = java.util.ArrayList.new();
		modifiedUnits.add(newPkg);
		context.getWorkbench().getMetamodelManager()
			  .getMetamodel("rhapsody").getModelWriterDescriptor("Rhapsody Application")
				  .setProperty("unitsToReplace", modifiedUnits);
		
		// Update model in Rhapsody
		model.write("Rhapsody Application", null);
	}
  }
	

Another example in Java to read a model from Rhapsody.

We use here the class com.sodius.mdw.core.model.Model as parameter:

    private static void readModel(Model model) throws CoreException {
        // Change reading behaviour
        model.getMetamodel().getModelReaderDescriptor("Rhapsody Application").setProperty("exportAllTags", true);
        model.getMetamodel().getModelReaderDescriptor("Rhapsody Application").setProperty("exportDiagrams", false);

        model.read("Rhapsody Application", null);
    }
    

Redirect the log trace

1) To a log file in a Java command-line or Eclipse.ini:

        -Dcom.sodius.rhapsody.log=D:/trace.log
	

1) To a log file in a TGL or MQL script:

    context.getWorkbench().getMetamodelManager()
        .getMetamodel("rhapsody")
            .getModelReaderDescriptor("Rhapsody Application")
                .setProperty("com.sodius.rhapsody.log", "D:/trace.log");
	

2) To a log file in a Java source:

    model.getMetamodel()
        .getModelReaderDescriptor("Rhapsody Application")
            .setProperty("com.sodius.rhapsody.log", "D:/trace.log");
	

3) To an object implementing the interface com.sodius.mdw.core.util.log.Logger:

    workbench.getConfiguration().setLogger(new MyLogger((...));
	

Or also:

    model.getMetamodel()
    	.getModelReaderDescriptor("Rhapsody Application")
	  		.setProperty("customLogger", (new MyLogger((...));
	

4) A complete example with On-Demand connector and using preloader in Java:

    MDWorkbench workbench = MDWorkbenchFactory.create();
    FileLogger logger = new FileLogger(new File("D:/trace.log"));
    logger.setLevel(Level.DEBUG);
    try {
        workbench.getConfiguration().setLogger(logger);
        Model model = workbench.getMetamodelManager().getMetamodel("rhapsody").readModel("Rhapsody On-Demand", null);
        ProxyPreloader preloader = new ProxyPreloader(model, logger);
        preloader.preload();
    } catch (CoreException e) {
        logger.error(e.getMessage(), e);
    }
	

1 This property could be customized only at runtime.