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