How can I get the high level categories for an ICategory I have?
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
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>