Question & Answer
Question
How do you add tags in a IBM Rational Rhapsody model using JAVA API?
Cause
You would like to add Tags in Rational Rhapsody model by making use of Java API code instead of using the Graphical Use Interface [GUI]
Answer
In order to add a tag in Rational Rhapsody, you can use of the following piece of JavaScript 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. |
---|
[<code>]
import com.telelogic.rhapsody.core.*;
public class testCls
{
public static void main(String[] args) {
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPProject prj = app.activeProject();
IRPPackage myPack = prj.addPackage("testPkg");
IRPTag myTag1 = (IRPTag) myPack.addNewAggr("Tag", "Tag1");
IRPClass myCls = myPack.addClass("testCls");
myTag1.setDescription("Description of Tag1");
IRPTag myTag2 = (IRPTag) myCls.addNewAggr("Tag", "Tag2");
myTag2.setDescription("Description of Tag2");
}
}
The above code creates a new package and a class, for an open project and adds two tags with descriptions, one each for the package and the class. Like the description, other attributes of the tags can also be set.
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21453644