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