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 On-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 and the Connector Descriptor to store properties:
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 but using the Context Properties instead:
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);
List modifiedUnits = new ArrayList();
modifiedUnits.add(newPkg);
//Providing Context Properties to the update writer
Map map = new HashMap();
map.put("unitsToReplace", modifiedUnits);
source.write("Rhapsody Application", null, map);
}
Note: The properties stored in this variable map will override ones with same name provided in file mdw.ini
or in the Connector Descriptor, and the map can be changed at each call of method write.
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);
var map : java.util.Map = java.util.HashMap.new();
map.put("unitsToReplace", modifiedUnits);
// Update model in Rhapsody
model.write("Rhapsody Application", null, map);
}
}
Another example in Java to read a model from Rhapsody.
We use here the class com.sodius.mdw.core.model.Model as parameter with Context Properties:
private static void readModel(Model model) throws CoreException {
// Change reading behaviour
Map map = new HashMap();
map.put("exportAllTags", true);
map.put("exportDiagrams", false);
model.read("Rhapsody Application", null, map);
}
1) To a log file in a Java command-line or Eclipse.ini:
-Dcom.sodius.rhapsody.log=D:/trace.log
2) 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");
3) To a log file in a Java source:
model.getMetamodel()
.getModelReaderDescriptor("Rhapsody Application")
.setProperty("com.sodius.rhapsody.log", "D:/trace.log");
Or using with Context Properties:
map.put("com.sodius.rhapsody.log", "D:/trace.log");
4) 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 accessor 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);
}