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

Technote (FAQ)


Question

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

Cause

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.

Answer

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

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.

=======================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========================


Rate this page:

(0 users)Average rating

Document information


More support for:

Rational Rhapsody
General Information

Software version:

7.5, 7.5.0.1, 7.5.1, 7.5.1.1, 7.5.2, 7.5.2.1, 7.5.3, 7.5.3.1, 7.5.3.2, 7.5.3.3, 7.6, 7.6.0.1, 7.6.1, 7.6.1.1, 7.6.1.2, 7.6.1.3, 8.0, 8.0.1

Operating system(s):

Windows

Reference #:

1627229

Modified date:

2013-03-12

Translate my page

Machine Translation

Content navigation