It's all about the answers!

Ask a question

How to detect if some link belongs to RTC work items ?


Arshad Adavani (231218) | asked Apr 04 '16, 1:08 a.m.
Hello All,

Can we detect if some link belongs to RTC work item ?
For E.g. say in one of my work item's description I have mentioned 2 links, one contains a link to another work item in RTC and one more say www.google.com.

I want to detect that one work item link which belongs to RTC and remove www.google.com from this result.

Any hints how do I achieve this..?

Thanks for any help :)

Comments
Ralph Schoon commented Apr 04 '16, 2:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I don't know. You could try to use the RTC CM OSLC interface to try to access the resource and check the data you get back. I would assume there are some hints that you could use to distinguish between a work item/OSLC resource and just an arbitrary URL.


Ralph Schoon commented Apr 04 '16, 5:31 a.m. | edited Apr 04 '16, 5:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Another way might be the format of the link. There are multiple formats available as far as I know. Below publicURIRoot looks like https://server:7443/ccm


One looks like: publicURIRoot/resource/itemName/com.ibm.team.workitem.WorkItem/2 and the last part is the work item ID.

Another one looks like I am publicURIRoot/resource/itemOid/com.ibm.team.workitem.WorkItem/_bV3EMPA2EeWIVM8BVm4oIg where the last part is the UUID of the work item.


Arshad Adavani commented Apr 04 '16, 7:25 a.m.

Hi Ralph,

Thanks for the response.
I have one more question. We have short forms to specify a link in RTC.

For E.g. say in summary field I write as Work Item 123, then it becomes a link to work item 123 but when I fetch this summary using getHTMLSummary(), it is plain text. How do I fetch this link in the background ?


Ralph Schoon commented Apr 04 '16, 7:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There is a computation behind the work item editor and work item save, where the pattern e.g. defect 123 is detected and a potential link to a work item is computed.

The link in the summary (the summary is an XMLText attribute) is created as HTML link tag and the work item is also added to as a mentions link.
 

3 answers



permanent link
sam detweiler (12.5k6189201) | answered Apr 04 '16, 8:28 a.m.
If you use the Java api, you can determine the endpoint type without any issue

permanent link
Ralph Schoon (61.4k33643) | answered Apr 04 '16, 9:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Apr 04 '16, 9:28 a.m.
It ain't trivial Sam. As mentioned above there are two types of links. One is basically an item reference and one is an URI reference. these have to be dealt with in different ways. Here code that worked for me:

https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/

See
analyzeReference()

Comments
sam detweiler commented Apr 04 '16, 9:37 a.m.

I disagree.. we did this before, maybe three lines of code..


Ralph Schoon commented Apr 04 '16, 9:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Please share then Sam.


permanent link
sam detweiler (12.5k6189201) | answered Apr 04 '16, 10:01 a.m.
see

   private static void analyzeReferences(IWorkItemReferences iReferences)

in https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

tells you all the reference types of all the links in a workitem.

more than 3 lines of code, but the decision is easy, in his case wanting to remove the google.com uri reference
        if (iReference.isURIReference())
        {
            analyzeReferenceTarget(iReference);
        }
       

Comments
Ralph Schoon commented Apr 04 '16, 10:16 a.m. | edited Apr 04 '16, 10:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Pretty much my code I refer to above. The trick starts after the trivial lines, where you have to figure the URI and resolve the work item to be sure, which is three times as much code.

Your answer


Register or to post your answer.