It's all about the answers!

Ask a question

How to add work item category programmatically in RTC project area ?


2
1
Dashrath Kale (1542723) | asked Jul 15 '13, 2:53 a.m.

I am trying to add the work item category as a child for the root category "Unassigned" , it works fine when I add it manually but it does get added when I use the RTC API as shown below:

  IAuditableClient auditableClient = (IAuditableClient) teamRepository
    .getClientLibrary(IAuditableClient.class);
  CategoriesManager catManager = CategoriesManager.createInstance(
    auditableClient, projectArea, null);
  CategoryTreeNode rootNode = catManager.getRoot();
  CategoryTreeNode childCat = rootNode.createChild("childCategory");
  catManager.save(monitor);

The code gets executed successfully but can not see the newly added child work item category in the project area.

Please correct me if I am missing anything.

Accepted answer


permanent link
Ajay Mallikarjunaiah (148410) | answered May 22 '14, 4:21 a.m.
Hi,
 The code snippet is correct and it works perfectly fine( i tried it). Please recheck in eclipse client. Sometimes newly created items wont reflect in web UI. It should be there when checked from eclipse client.
Ralph Schoon selected this answer as the correct answer

Comments
1
Ajay Mallikarjunaiah commented May 22 '14, 4:51 a.m. | edited May 22 '14, 4:52 a.m.

For any mysterious reason if the above method is not working, you can create categories in following way also.

public ICategory createCategory( IProjectArea iProjectArea, String categoryName){
           
            IWorkItemClient workItemClient = (IWorkItemClient) repository
                .getClientLibrary(IWorkItemClient.class);
            ICategory category = workItemClient.createCategory(iProjectArea, categoryName, monitor);
              return workItemClient.saveCategory(category, monitor);
                    
            }


1
Ajay Mallikarjunaiah commented May 22 '14, 5:08 a.m.

For creation of sub categories
public ICategory createSubCategory(ICategoryHandle parentCategory, String categoryName){
           
            IWorkItemClient workItemClient = (IWorkItemClient) repository
                .getClientLibrary(IWorkItemClient.class);
            ICategory category = workItemClient.createSubcategory(parentCategory,
                    categoryName, monitor);
                    return workItemClient.saveCategory(category, monitor);
                    
            }

One other answer



permanent link
Ralph Schoon (63.3k33646) | answered Jul 15 '13, 3:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi, I would suggest to have a look at Snippet 3 of the snippets shipped with the Plain Java Client Libraries. You probably have to save the project area similar to how it is shown in that snippet. Please also consider reading http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/






Your answer


Register or 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.