IBM Support

How to access SysML FlowItems from a Flow using the Rational Rhapsody API

Question & Answer


Question

How do you access SysML FlowItems from a Flow using the IBM Rational Rhapsody API?

Cause

There is no getFlowItems method. This technote shows you the correct method to use for accessing this model data.

Answer

Disclaimer

All source code examples in 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 method IRPFlow.getConveyed() will return a collection of IRPFlowItem objects contained within an IRPFlow object. 

You can do the reverse access (Flowitems > Flow) by using the IRPItemFlow.getReferences() method. You will need to run a condition to check for IRPFlow types in the collection that is returned.


For example:

    IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
    IRPFlow el = (IRPFlow)app.getSelectedElement();

    // access the collection of itemflows
    List<IRPFlowItem> ListOfItemFlows = el.getConveyed().toList();
    System.out.println("Item flows under "+el.getName()+" flow:");
    for (IRPFlowItem itemflow : ListOfItemFlows) {
        System.out.print("\t" + itemflow.getName());
                
    // access the flow that contains/owns the above flowitems
        List<IRPModelElement> ItemFlowRefs = itemflow.getReferences().toList();
        for (IRPModelElement ref : ItemFlowRefs) {
            if (ref instanceof IRPFlow)
                System.out.println(" (belongs to "+ref.getName()+")");
        }
    }

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

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21671317