IBM Support

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

Question & Answer


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

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General Information","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.0.1;8.0;7.6.1.3;7.6.1.2;7.6.1.1;7.6.1;7.6.0.1;7.6;7.5.3.3;7.5.3.2;7.5.3.1;7.5.3;7.5;7.5.0.1;7.5.1;7.5.1.1;7.5.2.1;7.5.2","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21627229