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.
 Hello,

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
}

@Override
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();
if(workItem.getWorkItemType().equals("dev_task")){
String categoryName = "Dev";
List<String> namePath= Arrays.asList(categoryName.split("/"));
ICategoryHandle category = common.findCategoryByNamePath(projectArea,namePath,monitor);
return category;
}
else
return null;
}
}

One answer



permanent link
Ralph Schoon (63.6k33646) | answered Jul 25 '13, 2:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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 http://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ where, as far as I remember, I always return the resolved object and not the handle. Resolve using
workItemCommon.getAuditableCommon().resolveAuditable(.....
 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.