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.
public ruleset UpdateModel(inout source : rhapsody)
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 = java.util.ArrayList.new();
modifiedUnits.add(rhpClass);
context.getWorkbench().getMetamodelManager().getMetamodel("rhapsody")
.getModelWriterDescriptor("Rhapsody Application")
.setProperty("unitsToReplace", modifiedUnits);
[progress] Evaluation of RhapsodyUpdate [progress] Reading Rhapsody On-Demand [progress] Writing Rhapsody Application [progress] Building : Project [progress] Building Package : RHP1754740916436624630 / Default [progress] Building Package : RHP1754740916436624630 / package2 [progress] Building Class : RHP1754740916436624630 / / ClassOfpackage2 [progress] Creating generalizations [progress] Creating template instanciations [progress] Setting port contracts [progress] Creating relations [progress] Creating AssociationClasses [progress] Drawing Sequence Diagrams [progress] Creating flowlinks [progress] Creating unit links [progress] Creating instance slots [progress] Setting Links connections [progress] Creating Tags [progress] Creating dependencies [progress] Setting SendActions [progress] Creating referenced SequenceDiagrams [progress] Setting InteractionOccurences [progress] Drawing diagrams [progress] Done.
This sample needs some adaptation if you want to deploy this ruleset in Rhapsody and invoke it with Code Generator.
A tutorial will explain this procedure in details.
Prev Section: Create your own ruleset player and Rhapsody plugin