Question & Answer
Question
How do you get all the objects being applied with same stereotype using JAVA API in IBM Rational Rhapsody?
Cause
You would like to use Java Application Programming Interfaces (API) code to automate the manual task to be performed with in Rational Rhapsody.
Answer
In order to get all the objects being applied with same stereotype in Rational Rhapsody use the following Java API code:
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. |
---|
public class ClsReqId
{
public static void main(String[] args)
{
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject prj = app.activeProject();
for(Object o1:prj.getPackages().toList())
{
IRPPackage pkg = (IRPPackage)o1;
//System.out.println(pkg.getName());
for(Object o2:pkg.getGlobalObjects().toList())
{
IRPInstance obj = (IRPInstance)o2;
//System.out.println(obj.getName());
for(Object o3:obj.getStereotypes().toList())
{
IRPStereotype streo = (IRPStereotype)o3;
if(streo.getName().equals("pack1Stereo"))
System.out.println(obj.getName());
}
}
}
}
}
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21596681