Below are the accessors that connects to the active Rhapsody application to read or write models.
Model readers:
String getProperty(String)
.Model writers:
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:\Users\<user>\IBM\Rational\Rhapsody\<version>\Share"
).
Here is how the accessors determine the Rhapsody OMRoot location:
"rhapsody.omroot"
may be used to set the location.
"rhapsody.omroot"
may be used to set the location.
These accessors have a predefined behaviour described by a set of properties.
Note that the default value is always underline.
exportAllTags
: false, true. Not available for accessor Rhapsody On-Demand.exportFilenames
: false, trueexportDiagrams
: false, trueexportStatecharts
: false, trueexportFlowcharts
: false, trueexportGraphicalProperties
: false, true. Default value is false for accessor Rhapsody Application (no graphics).exportPredefinedPackages
: false, trueexportDescriptionHTML
: false, true Not available for accessor Rhapsody On-Demand.exportDescriptionRTF
: false, true Not available for accessor Rhapsody On-Demand.importLevel
: Package, ProjectimportGUID
: false, trueexistingPackageName
: <empty>replaceExternalPackages
: false, truepackageType
: Create New, Default, Existing, Rhapsody_ImportnewPackageName
: <empty>importExternalPackages
: false, trueoverwriteExistingElements
: false, trueskipAllChecks
: false, truespecifyOptions
: false, true. If true same behaviour as connector Rhapsody Application (specify options).unitsToReplace
: <list>. Provide a java.util.List
based instance1.packagesToKeep
: <list>. Provide a java.util.List
based instance1.packagesToDelete
: <list>. Provide a java.util.List
based instance1.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.
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); }
1 This property could be customized only at runtime.