Search code examples
javaapirtc

How to get RTC work item attribute data using java API?


I am using below code and it returns some information about "Filed Against" attribute. But there I am not able to find attribute data. Please help

IAttribute someAttribute= workItemClient.findAttribute(projectAreaHandle, workItem.CATEGORY_PROPERTY, monitor);

Using below code to find out the work item by Id :

workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
                int id = new Integer("339406").intValue();  
                IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);

using this work item I want to fetch parent and children like Epic and story work items related to the work item. And then there attributes like story status, story planned for etc.


Solution

  • From this thread:

    You can't just put a string in there, I think.
    You have to find the category object from the string and then put in the ICategory object.

    That means:

    private static String CATEGORY_NAME = "UI1"; 
    List<ICategory> findCategories = workItemCommon.findCategories(projectArea, ICategory.FULL_PROFILE, monitor); 
        for(ICategory category : findCategories) { 
              if(category.getName().contains(CATEGORY_NAME)){ 
                  filedAgainstAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.CATEGORY_PROPERTY, auditableClient, monitor); 
                        filedAgainstExpression = new AttributeExpression(filedAgainstAttribute, AttributeOperation.EQUALS, category);
           } 
      }