Adding comments while creating workitem using java APi
Accepted answer
See https://rsjazz.wordpress.com/2013/07/12/work-item-command-line-client-to-add-a-comment/
This is no different to modifying the work item. You do it in a WorkItemOperation
This is no different to modifying the work item. You do it in a WorkItemOperation
private static class WorkItemInitialization extends WorkItemOperation {
private String fSummary;
private ICategoryHandle fCategory;
public WorkItemInitialization(String summary, ICategoryHandle category) {
super("Initializing Work Item");
fSummary = summary;
fCategory = category;
}
@Override
protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem = workingCopy.getWorkItem();
workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary));
workItem.setHTMLDescription(XMLString.createFromPlainText(fSummary));
workItem.setCategory(fCategory);
List tags = workItem.getTags2();
tags.add("NewTag");
workItem.setTags2(tags);
}
}
You add the comment in the execute section. You run it this way.
WorkItemInitialization operation = new WorkItemInitialization("Test", category);
IWorkItemHandle handle = operation.run(workItemType, monitor);