IBM Support

How to add Execution Occurrences to sequence diagrams via the API in Rational Rhapsody

Question & Answer


Question

How do you add an Execution Occurrence to a sequence diagram if there is no IRPCollaboration.addExecutionOccurrence() method in the Application Programming Interface (API) in IBM Rational Rhapsody?

Cause

There is a IRPCollaboration.getExecutionOccurrences() method in the API but you have to add the IRPCollaboration.addExecutionOccurrence() method separately.

Answer

You need to add the Execution Occurrence directly to the diagram message, rather than to the diagram's collaboration object.

  1. Setup objects for sequence diagram:
    IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
     IRPPackage pkg = (IRPPackage)app.getSelectedElement();
     IRPClass ClassA = pkg.addClass("ClassA");
     IRPClass ClassB = pkg.addClass("ClassB");
     IRPOperation OpB = ClassB.addOperation("OperationB");



  2. Create collaboration for SD behaviour:
    IRPCollaboration Collab = app.activeProject().getNewCollaboration();


  3. Add objects to Collab object:
    IRPClassifierRole crClassA = Collab.addClassifierRole("ClassA", ClassA);
     IRPClassifierRole crClassB = Collab.addClassifierRole("ClassB", ClassB);
     IRPMessage msg = Collab.addMessage(OpB, "", crClassA, crClassB);



  4. Add SE to message
    IRPExecutionOccurrence eo = msg.addSourceExecutionOccurrence();


  5. Create sequence diagram from collaboration object:
    IRPSequenceDiagram SD = Collab.generateSequence("MySD", pkg);

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Documentation","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.5;7.6;8.0","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21643314