IBM Support

How to extract overridden properties using Rational Rhapsody Java API

Question & Answer


Question

How do you extract overridden properties using IBM Rational Rhapsody Java API?

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

You can use the Java API call getOverriddenProperties(int recursive) available for the IRPModelElement interface, in order to extract overridden properties.

The argument (int recursive) determines if you want the overridden properties only at the level where the API is called or that level and all levels (recursively) below it.

Find below the Java API code snippet:

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.

import com.telelogic.rhapsody.core.RhapsodyAppServer;          
import com.telelogic.rhapsody.core.IRPApplication;              
import com.telelogic.rhapsody.core.IRPModelElement;            
import com.telelogic.rhapsody.core.IRPProject;                  
import com.telelogic.rhapsody.core.IRPUnit;                    
                                                               
public class getOverriddenProperties

{                          
public static void main(String[] args)

 {                      
  IRPApplication app =                                        
RhapsodyAppServer.getActiveRhapsodyApplication();              
     IRPProject actPro = app.activeProject();                  
     for(Object o:actPro.getNestedElementsRecursive().toList())
     {                                                        
      IRPModelElement myEle = (IRPModelElement)o;              
      //if(!(myEle.getMetaClass() .contains("Diagram")))
      IRPUnit unit = myEle.getSaveUnit();                      
      if(unit.isReadOnly()== 0)                                
       {                                                      
       if(myEle.getOverriddenProperties(0).getCount()>0)      
        System.out.println("\n" + myEle.getName() + "\n");    
       for(Object o1:myEle.getOverriddenProperties(0).toList())
        System.out.println(o1.toString());                    
       }    
     }
}
}

[{"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":"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.6;7.6.0.1","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21439246