IBM Support

How to display information in a tag in Rational Rhapsody

Question & Answer


Question

How do you display information of Class parameters such as In, Out, InOut on a tag in IBM Rational Rhapsody?

Answer

In order to display the information in a tag in Rational Rhapsody, you can use of the following piece of JavaScript code:

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.


import com.telelogic.rhapsody.core.IRPApplication;
import com.telelogic.rhapsody.core.IRPArgument;
import com.telelogic.rhapsody.core.IRPModelElement;
import com.telelogic.rhapsody.core.IRPOperation;
import com.telelogic.rhapsody.core.IRPProject;
import com.telelogic.rhapsody.core.IRPTag;
import com.telelogic.rhapsody.core.RhapsodyAppServer;


public class argInfoToTag {

public static void main(String[] args) {
 
 IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
 IRPProject prj = app.activeProject();
 
 for (Object obj : prj.getNestedElementsRecursive().toList())
 {
  if(obj instanceof IRPOperation)
  {
   IRPOperation myOp = (IRPOperation) obj;
   if(myOp.getArguments().getCount() > 0)
   {
    IRPModelElement myEle = myOp.addNewAggr("Tag", "Tag_"+myOp.getName());
    IRPTag myTag = (IRPTag) myEle;
    String str = "";
    int count=1;
    for(Object obj1 : myOp.getArguments().toList())
    {
     IRPArgument myArg = (IRPArgument) obj1;
     str = str + "Argument"+count+": --> ";
     str = str + "Name: " + myArg.getName() + " ";
     str = str + "Type: " + myArg.getType().getName() + " ";
     str = str + "Direction: " + myArg.getArgumentDirection() + " \n\n";
     count++;
    }
    myTag.setDescription(str);
   }
  }
 }
}

[{"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.2;7.3;7.4;7.4.0.1;7.5.1;7.5.0.1;7.5","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21456035