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

Query RTC work items with a certain tag programmatically

I am trying to create and run a query in order to find all work items in a specific project area that has a specific tag.

For that I am using the following code:

    ITeamRepository repo = (ITeamRepository) prjArea.getOrigin();
    IAuditableCommon auditableCommon = (IAuditableCommon) repo.getClientLibrary(IAuditableCommon.class);
    IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);

    IQueryableAttribute attributeTags =
        factory.findAttribute(prjArea, IWorkItem.TAGS_PROPERTY, auditableCommon, monitor);

    Expression hasTag = new AttributeExpression(attributeTags, AttributeOperation.CONTAINS, TAG_NAME);

    Term term = new Term(Operator.AND);
    term.add(hasTag);

    IQueryClient queryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class);
    IQueryResult<IResolvedResult<IWorkItem>> queryResult =
        queryClient.getResolvedExpressionResults(prjArea, term, IWorkItem.FULL_PROFILE);

    List<IWorkItem> workItems = new ArrayList<IWorkItem>(queryResult.getResultSize(monitor).getTotalAvailable());


The resulting list is empty although it should return one work item. (I tested with a manually created query).

What am I missing here?

Thank you


0 votes



One answer

Permanent link
I missed that part of code.

    while (queryResult.hasNext(monitor)) {
      if (monitor.isCanceled()) {
        return null;
      }
      IResolvedResult<IWorkItem> resolvedResult = queryResult.next(monitor);
      IWorkItem workItem = resolvedResult.getItem();
      workItems.add(workItem);
    }

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,998

Question asked: Mar 09 '16, 9:35 a.m.

Question was seen: 3,046 times

Last updated: Mar 09 '16, 11:35 a.m.

Confirmation Cancel Confirm