Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Fetching WorkItems based on some text on URI of Related Artifacts using plain java API

We want to retrieve workItems based on some text (eg: ibm) from 'Related artifacts' (which is really standard html link, eg URI: www.ibm.com/developerworks) attached as Links in the Links tab. Any help would be really appreciated?

0 votes



2 answers

Permanent link
You can create a workitem query that will return workitems that HAVE Related Artifact links.
then you can examine each workitem..

I provided a sample that will dump out all workitems returned in a query, the accepted answer here.
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

after you get that to work, you can add code to create the query dynamically.
see Ralphs blog
https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/

0 votes


Permanent link
Thanks sam for your quick reply. I have not tried using workitem query. But worked for me as below,

//First get the required workitems and on each workitem do some logic based on "Related artifact" link defined.
-----------------------------------------
com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, term, IWorkItem.FULL_PROFILE);

while (results.hasNext(monitor)) {
  IResolvedResult<IWorkItem> workitemResult = (IResolvedResult<IWorkItem>) results.next(monitor);
  IWorkItem workItem = workitemResult.getItem();
  ILinkManager linkManager = (ILinkManager)      teamRepository.getClientLibrary(ILinkManager.class);
  workItemReference =  linkManager.referenceFactory().createReferenceToItem(workItem);

linkQueryPage = linkManager.findLinksBySource(WorkItemLinkTypes.RELATED_ARTIFACT, workItemReference, monitor);
linkCollection = linkQueryPage.getAllLinksFromHereOn();

for (ILink l : linkCollection) {
    System.out.println("URL: " + l.getTargetRef().createURI()+ ", Comment: " + l.getTargetRef().getComment());
    if (l.getTargetRef().createURI().toString().contains("some string that you would be searching as part of URI"))
    //Once you determined that WorkItem with specific URI string
   //DO your logic
    -------
   }
}

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,950
× 411

Question asked: Aug 27 '15, 11:03 a.m.

Question was seen: 3,827 times

Last updated: Sep 02 '15, 11:16 a.m.

Confirmation Cancel Confirm