IBM Support

How to create sequence diagrams using the Rational Software Architect or Rational Software Modeler extensibility interface

Question & Answer


Question

How can you automatically create a sequence diagram for all the interactions contained in your IBM Rational Software Modeler (RSM) or IBM Rational Software Architect (RSA) model using a pluglet?

Cause

A typical usage scenario is the case where you have created communication diagrams and want to automate the creation of equivalent sequence diagrams in each existing interaction.

Answer

 DISCLAIMER:


All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

The attached file CreateSeqDiagramProject.zip contains a pluglet example which shows how this can be done.

The class com.ibm.rational.support.CreateSequenceDiagram.java contains the following two methods which create a sequence diagram based on UML interactions in the model.

Note that the pluglet will create an empty diagram if the interaction does not contain any content/children.


private void getInteraction(Object object) {
if (null != object) {
if (object instanceof Interaction) {
Interaction interac = (Interaction) object;
out.println("Interaction: " + interac.getQualifiedName());
out.println(interac.eContents());
createDiagram(interac);
}
}
if (object instanceof EObject) {
Iterator contents = ((EObject) object).eContents().iterator();
while (contents.hasNext()) {
getInteraction(contents.next()); //$NON-NLS-1$
}
}
}

private void createDiagram(Interaction interaction) {
out.println("Creating diagram in ");
IUMLDiagramHelper dgmHelper = UMLModeler.getUMLDiagramHelper();
out.println(dgmHelper);
Diagram newDiagram = dgmHelper.createDiagram((Namespace) interaction,UMLDiagramKind.SEQUENCE_LITERAL, interaction);
out.println(newDiagram);
newDiagram.setName(interaction.getName()+" - seq");
}

}

CreateSeqDiagramProject.zip

[{"Product":{"code":"SSCLKU","label":"Rational Software Modeler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Extensibility","Platform":[{"code":"PF033","label":"Windows"},{"code":"PF016","label":"Linux"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5;7.5.5.1;7.5.5.2;7.5.5.3;7.5.5.4;7.5.5.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS4JCV","label":"Rational Software Architect for WebSphere Software"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Extensibility","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5;7.5.5.1;7.5.5.2;7.5.5.3;7.5.5.4;7.5.5.5;8.0;8.0.1;8.0.2;8.0.3;8.0.4;8.0.4.1;8.0.4.2;8.5;8.5.1;9.0","Edition":"","Line of Business":{"code":"LOB15","label":"Integration"}},{"Product":{"code":"SS4JE2","label":"Rational Software Architect Standard Edition"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Extensibility","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.1;7.5.2;7.5.3;7.5.4;7.5.5;7.5.5.1;7.5.5.2;7.5.5.3;7.5.5.4;7.5.5.5","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21397565