IBM Support What's New?

How to use Rhapsody Java API to identify dependencies drawn to a specific requirement

Technote (FAQ)


How do you write Java API in IBM Rational Rhapsody in order to identify all the dependencies drawn to a specific requirement?


Normally, you can use Rhapsody Java API getDependencies() to directly retrieve all the dependency information from a selected model element; however, for Requirement model element, no corresponding getDependencies() API being provided. In this specific case, you should consider to utilize other available API to retrieve the dependency info.


The code provided below shows you how to get the reference information from a requirement instance, and extract only dependencies information for further processing.


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.

=======================Begin of Sample Code=======================

IRPRequirement iReq;

//Step1: Retrieve all the references related to requirement iReq
IRPCollection iRefCollect = iReq.getReferences();

//Step2: Run a loop to get each referenced elements in turn
for(int i=1 ; i<=iRefCollect.getCount() ; i++) {

    //Step3: Check if the current referenced element is the instance of dependency

    if (iRefCollect.getItem(i)  instanceof IRPDependency) {
      // Step4: Perform type cast and continue the further user operation
      IRPDependency iDep = (IRPDependency)(iRefCollect.getItem(i));

========================End of Sample Code========================

Document information

More support for: Rational Rhapsody
General Information

Software version: 7.5,, 7.5.1,, 7.5.2,, 7.5.3,,,, 7.6,, 7.6.1,,,, 8.0, 8.0.1

Operating system(s): Windows

Reference #: 1627229

Modified date: 2013-03-12