IBM Support

How to set the tag type in the Rational Rhapsody API

Question & Answer


Question

How do you set the type of a tag to a specific meta class using the Application Programming Interface (API) for IBM Rational Rhapsody?

Cause

You have tried using setMetaclass and found that it does not set the type of the tag to a specific metaclass.

Answer

You must use th method setDeclaration(string declaration) to set the type of the tag to a specific metaclass.

The method setMetaclass(string tagMetaClass) sets the metaclass type that the tag should be applicable to, not the type of the actual tag itself. The IRPTag interface inherits the method setDeclaration(string declaration) from the IRPVariable interface.

For example:

IRPTag tag = (IRPTag) flow.addNewAggr("Tag", "realization");
tag.setTagMetaClass("Link");


This will create a tag applicable to Link model elements, but the tag will default to type of string.
Instead we should use setDeclaration(string declaration) to set the tag's type:

IRPTag tag = (IRPTag) flow.addNewAggr("Tag", "realization");
tag.setDeclaration("Link");

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Documentation","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"8.0.6","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21672532