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

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

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.

1

2 votes


Accepted answer

Permanent link
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

1 vote

Comments

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 vote

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);
                    
            }

1 vote


One other answer

Permanent link
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/





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

Question asked: Jul 15 '13, 2:53 a.m.

Question was seen: 6,554 times

Last updated: May 22 '14, 5:08 a.m.

Confirmation Cancel Confirm