It's all about the answers!

Ask a question

How can I get the high level categories for an ICategory I have?


Torsten Knodt (536) | asked Jun 17 '22, 6:51 a.m.

When I have an ICategory of a IWorkItem , I would like to climb up the category hierarchy to see whether it is in a one with a well-known name by my EWM Client Plug-In.
However, I did not find a method for that in ICategory .
How can I get this information, beside resorting to the OSLC interface?

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Jun 20 '22, 2:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Methods to work with ICathegory are on com.ibm.team.workitem.common.IWorkItemCommon . The category resembles a path separated by /, so you would do string operations to get the higher hierarchy.


https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ section Category shows calculateCategoryAsString.

This code does the reverse operation


    private ICategoryHandle findCategory(String value) throws TeamRepositoryException {
        List<string> path = StringUtil.splitStringToList(value, PATH_SEPARATOR);
        ICategoryHandle category = getWorkItemCommon().findCategoryByNamePath(getWorkItem().getProjectArea(), path,
                monitor);
        if (category == null && value != null) {
            if (value.equals("Unassigned")) {
                // category=ICategory.DEFAULT_CATEGORY_PROPERTY;
                category = getWorkItemCommon().findUnassignedCategory(getWorkItem().getProjectArea(),
                        ICategory.SMALL_PROFILE, monitor);
            }
        }
        return category;
    }
</string>
    


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.