Topic
10 replies Latest Post - ‏2012-10-26T09:30:14Z by SystemAdmin
navaneethms
navaneethms
8 Posts
ACCEPTED ANSWER

Pinned topic Unable to create hyperlinks in Requirement field by automation

‏2011-07-07T10:59:26Z |
Hello,

I am unable to create hyperlink for the description I made it in description field of Requirement.
(I am able to make hyperlink manually)

Do anybody know the method, how to create hyperlinik using automation and here I need to set the description into the
Free Text/ Link Target field of hyperlink.

Thanks
NavaneethMS
Updated on 2012-10-26T09:30:14Z at 2012-10-26T09:30:14Z by SystemAdmin
  • MerlinUK
    MerlinUK
    106 Posts
    ACCEPTED ANSWER

    Re: Unable to create hyperlinks in Requirement field by automation

    ‏2011-07-07T12:14:29Z  in response to navaneethms
    You need to use setDescriptionRTF and format the RTF accordingly
    To see how to format it- use getDescriptionRTF on an existing description field that has a hyperlink in it :)
    • navaneethms
      navaneethms
      8 Posts
      ACCEPTED ANSWER

      Re: Unable to create hyperlinks in Requirement field by automation

      ‏2011-07-11T08:23:36Z  in response to MerlinUK
      Hello MerlinUK,

      Thanks for the info, But I am still not clear how the prcedure need to be set in order to get the
      hyperlink activation. Can you please explain a little more detail?

      Thanks,
      NavaneethMS
      • MerlinUK
        MerlinUK
        106 Posts
        ACCEPTED ANSWER

        Re: Unable to create hyperlinks in Requirement field by automation

        ‏2011-07-11T09:58:23Z  in response to navaneethms
        Sure - in order to add hyperlinks in description fields you have to add them as RTF text. The easiest way to find out how to format that text is to take an existing description with a hyperlink in it and see what it looks like.

        Lets say I have a Block A that has a hyperlink in it's description to Block B.
        If I use the API to getDescriptionRTF - it comes out like this:

        {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}}
        {\colortbl ;\red0\green0\blue0;\red0\green0\blue255;}
        \viewkind4\uc1\pard\cf1\fs20 This is a link to a Block: \cf2\ul\protect B\cf0\ulnone\protect0\par
        }

        Now you can see the format of a Hyperlink - you can add one yourself by using setDescriptionRTF. The hyperlink itself is the itej between the protect tags - see the attached screenshot for what the link looked like in Rhapsody
        • navaneethms
          navaneethms
          8 Posts
          ACCEPTED ANSWER

          Re: Unable to create hyperlinks in Requirement field by automation

          ‏2011-07-11T11:09:19Z  in response to MerlinUK
          Hello MerlinUK,

          Thanks for the reply. But here my conditions are a little different.

          As my first step, I am adding the description in the description field with the help of,
          "setDescriptionHTML" API.
          After adding this with the API, as u said I have to get the exsiting description wih the help of,
          "getDescriptionRTF"
          So here I get the String information of my description, as per your procedure now I need to use
          "setDescriptionRTF" for the String information which I got from above API.

          But here in my case it is not setting the hyperlink, may be because two times I am trying to set the
          description.
          (I have attached the screenshot of my piece of test code)
          Can you please suggest me whereit is going wrong?
          • MerlinUK
            MerlinUK
            106 Posts
            ACCEPTED ANSWER

            Re: Unable to create hyperlinks in Requirement field by automation

            ‏2011-07-11T11:39:40Z  in response to navaneethms
            I dont think its going to be that easy for you - you are trying to convert a HTML description into an RTF one - the API isnt going to make that conversion for you. The setDescription commands effectively just paste text in - the Rhapsody UI itself then creates the visual links from the underlying text.

            • you'll need to parse the HTML that you have and extract the hyperlinks so you can construct your RTF 'text'

            Get your code to print out the results of a getDescriptionHTML versus getDescriptionRTF and you'll see what i mean
            • navaneethms
              navaneethms
              8 Posts
              ACCEPTED ANSWER

              Re: Unable to create hyperlinks in Requirement field by automation

              ‏2011-07-14T14:56:10Z  in response to MerlinUK
              Hello Merlin,

              I have tried to get the hyperlink information from the already given hyperlink with the help of
              "getDescriptionRTF" API. This information I stored in a string. Then this particular string I tried
              to pass to another requirement's description field as hyperlink with the help of "setDescriptionRTF" API,
              then I observed that, this is just coming as a text, in description field, not as a hyperlink. I have
              attached the screenshot of the same along with this. Text is appearing with blue background and with underline,
              but didn't get activated as hyperlink.

              I have also attached the screenshot of the code which I used for the hyperlink test. Please suggest if
              there is any changes need to be done here.

              Thanks
              NavaneethMS
              • MerlinUK
                MerlinUK
                106 Posts
                ACCEPTED ANSWER

                Re: Unable to create hyperlinks in Requirement field by automation

                ‏2011-07-15T14:43:38Z  in response to navaneethms
                Right- you will need to use 'setDescriptionAndHyperlinks'
                • navaneethms
                  navaneethms
                  8 Posts
                  ACCEPTED ANSWER

                  Re: Unable to create hyperlinks in Requirement field by automation

                  ‏2011-07-18T13:45:38Z  in response to MerlinUK
                  Hello Merlin,

                  Thanks for the info. But in "setDescriptionAndHyperlinks" API, I observed that its arguments are String and Collection.
                  String I am able to pass, as I already have the string for the description in the form of RTF, but regarding the IRPCollection-
                  Which collection of data I need to pass? Because I have to pass individual requirement elements and description need to be
                  added under it as hyperlink.

                  Awaiting your valuable suggestion.

                  NavaneethMS
                  • MerlinUK
                    MerlinUK
                    106 Posts
                    ACCEPTED ANSWER

                    Re: Unable to create hyperlinks in Requirement field by automation

                    ‏2011-07-18T19:25:30Z  in response to navaneethms
                    No problem - try this code (assuming you have a Use Case called UC1 and two actors A1 and A2):

                    public class CreateHyperlinks {

                    static IRPApplication rpy;
                    static IRPProject prj;

                    public static void main(String[] args) {

                    rpy = RhapsodyAppServer.getActiveRhapsodyApplication();
                    prj = rpy.activeProject();

                    IRPUseCase uc = (IRPUseCase) prj.findNestedElementRecursive("UC1", "UseCase");

                    IRPActor a1 = (IRPActor) prj.findNestedElementRecursive("A1", "Actor");
                    IRPActor a2 = (IRPActor) prj.findNestedElementRecursive("A2", "Actor");

                    //Create the collection
                    IRPCollection col = rpy.createNewCollection();
                    col.addItem(a1);
                    col.addItem(a2);

                    //Compile the RTF
                    String rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\n";
                    rtf += "{\\colortbl ;\\red0\\green0\\blue255;\n}";
                    rtf += "\\viewkind4\\uc1\\pard\\fs20 Here is an actor: \\cf1\\ul\\protect A1\\cf0\\ulnone\\protect0\\par\n";
                    rtf += "Here is another: \\cf1\\ul\\protect A2\\cf0\\ulnone\\protect0\\par\n";
                    rtf += "And thats how you add hyperlinks\\par";
                    rtf += "}";
                    uc.setDescriptionAndHyperlinks(rtf, col);
                    }

                    }
                    • SystemAdmin
                      SystemAdmin
                      1305 Posts
                      ACCEPTED ANSWER

                      Re: Unable to create hyperlinks in Requirement field by automation

                      ‏2012-10-26T09:30:14Z  in response to MerlinUK
                      Hi merlin,

                      I have elements with hyperlinks in their description field and how can i get the collection with the destinations of the links in order to paste the description in other elements.
                      The function getDescriptionAndHyperlinks() doesn't exist.

                      Thanks,
                      Florent.