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
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 Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21671317