In this step, we wil learn how to develop rules to update a Rhapsody model.
A sample can be used as a first step to develop rules to update a Rhapsody model.
"rhapsody" typed model argument in the ruleset main entry point as
inout to be sure to update model:public ruleset UpdateModel(inout source : rhapsody)
myRule, we need to load the active Project reference to
avoid a conflict during the update of the model between the "Rhapsody On-Demand" connector reader and the "Rhapsody Application"
connector writer:
var application : rhapsody.Application = rhpModel.getInstances("Application").first();
var project : rhapsody.Project = application.activeProject;
var project : rhapsody.Project = rhpModel.getInstances("Project").first();
var modifiedUnits : java.util.List = [];
searchClassesAndRename, each updated units must be add the modifiedUnits list.modifiedUnits.add(rhpClass);
Package with new nested units, you need just to add this package the modifiedUnits list,
the nested elements will be automatically added to the model."Rhapsody Application" connector writer which units will be added or updated:
context.getWorkbench().getMetamodelManager().getMetamodel("rhapsody")
.getModelWriterDescriptor("Rhapsody Application")
.setProperty("unitsToReplace", modifiedUnits);
"Rhapsody On-Demand" and press OK,"Rhapsody Application" and press OK,[progress] Done.