How do you add source artifacts using Java Application Programming Interface (Java API) in IBM Rational Rhapsody?
You need to add source artifacts if you want to use Java API to automate the manual task to be performed within Rational Rhapsody.
In order to add source artifacts using Java API, execute the code provided below (sample):
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.
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPModelElement target = (IRPClassifier) app.getSelectedElement();
IRPModelElement SA = target.addNewAggr("File", target.getName());
//or, set it to "Implementation", "logical" or "other"