IBM Support

How to check out a Rational Rhapsody package from Rational ClearCase using JAVA API

Question & Answer


Question

How do you check out the IBM Rational Rhapsody package from IBM Rational ClearCase using 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

 
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.


In order to check out the Rational Rhapsody package along with its dependent packages from Rational Clear case, use the following Java API code:
*******************************************************
import java.io.IOException;

import javax.swing.JOptionPane;

import com.telelogic.rhapsody.core.IRPApplication;
import com.telelogic.rhapsody.core.IRPCollection;
import com.telelogic.rhapsody.core.IRPDependency;
import com.telelogic.rhapsody.core.IRPModelElement;
import com.telelogic.rhapsody.core.IRPProject;
import com.telelogic.rhapsody.core.IRPUnit;
import com.telelogic.rhapsody.core.RhapsodyAppServer;
import com.telelogic.rhapsody.core.RhapsodyRuntimeException;


public class CoWithDpen
{

/**
* @param args
*/
@SuppressWarnings("null")
public static void main(String[] args)
{
IRPApplication RhpApp = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject activeProject = RhpApp.activeProject();
IRPModelElement modelElement = RhpApp.getSelectedElement();
IRPUnit selectedUnit = (IRPUnit)modelElement;
JOptionPane.showMessageDialog(null, modelElement.getName());


////////////////search for dependencies///////////////////////////

IRPCollection allColl, allDep;
IRPModelElement temp;


allColl = modelElement.getNestedElementsByMetaClass("Class", 1);
for (int i = 1; i <= allColl.getCount(); i++)
{
IRPModelElement element = (IRPModelElement)allColl.getItem(i);
System.out.println(element.getName());
allDep = element.getDependencies();
for(int j=1; j<= allDep.getCount(); j++)
{
temp = (IRPModelElement)allDep.getItem(j);
System.out.println(temp.getName());
IRPModelElement myUnit = (IRPModelElement) activeProject.findNestedElementRecursive(temp.getName(), "Class");
System.out.println(myUnit.getOwner().getName());
IRPUnit myUnit1 = (IRPUnit) activeProject.findNestedElementRecursive(myUnit.getOwner().getName(), "Package");
if((myUnit1.isReadOnly()) == (int)1)
{
JOptionPane.showMessageDialog(null, "Package of dependent class is not checked out ");


////////////////////////////////checkout////////////////////////////

try
{
String chkoutPath1,chkoutPath2 = null;
chkoutPath1 = "M:\\Administrator_view\\rhpvob\\Projectcc\\Project_rpy\\";
chkoutPath2 = myUnit1.getName() + ".sbs";
System.out.println(chkoutPath2);
if(selectedUnit.isReadOnly() == 1)
Runtime.getRuntime().exec("cleartool checkout -nc -reserved \"" + chkoutPath1 + selectedUnit.getName() + ".sbs" );
Runtime.getRuntime().exec("cleartool checkout -nc -reserved \"" + chkoutPath1 + chkoutPath2 );

myUnit1.load(1);
} catch (IOException e)
{
e.printStackTrace();
}

}

}

System.out.println("\n");
}
}
}

*******************************************************

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

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21649983