It's all about the answers!

Ask a question

DefaultValueProvider : return Category

Antoine LELEU (5012728) | asked Jul 24 '13, 7:11 a.m.
edited Jul 24 '13, 11:05 a.m.

I try to code a Plugin (DefaultValueProvider) to return the default category according the workitem type.
I have this code but i don't understand how return the category.

public class DefaultValueProvider1 extends AbstractService implements IDefaultValueProvider<Category> {

public DefaultValueProvider1() {
// TODO Auto-generated constructor stub

public Category getDefaultValue(IAttribute attribute, IWorkItem workItem,
IWorkItemCommon workItemCommon, IConfiguration configuration,
IProgressMonitor monitor) throws TeamRepositoryException {
// TODO Auto-generated method stub
IWorkItemCommon common = getService(IWorkItemCommon.class);
IProjectAreaHandle projectArea = workItem.getProjectArea();
String categoryName = "Dev";
List<String> namePath= Arrays.asList(categoryName.split("/"));
ICategoryHandle category = common.findCategoryByNamePath(projectArea,namePath,monitor);
return category;
return null;

One answer

permanent link
Ralph Schoon (63.2k33646) | answered Jul 25 '13, 2:59 a.m.
Is there any exception thrown?

Currently you return the handle to the category. I would suggest to resolve the handle and to get the ICategory and return that. Consider looking at where, as far as I remember, I always return the resolved object and not the handle. Resolve using
 Another approach you could try is returning category.getItemId(), but I don't think that is going to work.

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.