Question & Answer
Question
How canI use API interface "IRPMessagePoint" in IBM Rational Rhapsody?
Cause
You would like to access the point in the model where the sequence diagram message/event realizes an operation/event
Answer
You can either search the model for:
- IRPMessagePoint using instanceof
- "CollaborationEvent" using getMetaClass().equals("CollaborationEvent")
The code below creates an example sequence diagram and shows both methods mentioned above:
// create example sequence diagram
IRPPackage pkg = app.activeProject().addPackage("TestPkg");
IRPClass classA = pkg.addClass("ClassA");
IRPOperation opA = classA.addOperation("OperationA");
IRPCollaboration collab = app.activeProject().getNewCollaboration();
IRPClassifierRole crA = collab.addClassifierRole("its"+ classA.getName(), classA);
IRPClassifierRole sys = collab.addSystemBorder();
IRPMessage msgA = collab.addMessage(opA, "", sys, crA);
IRPSequenceDiagram sd = collab.generateSequence("SD", pkg);
/////////////////////////////////////
// Retrieve entire model and find collaboration events/IRPMessagePoint objects
List<IRPModelElement> listModelElements = app.activeProject().getNestedElementsRecursive().toList();
for (IRPModelElement currentElement : listModelElements) {
if ((currentElement.getMetaClass().equals("CollaborationEvent")) && (currentElement instanceof IRPMessagePoint)) {
IRPMessagePoint mp = (IRPMessagePoint)currentElement;
System.out.println("CollaborationEvent (IRPMessagePoint) in "+ mp.getFullPathName() +" for " + mp.getMessage().getName());
}
}
/////////////////////////////////
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. |
---|
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21971334