How to set the value of Filed Against in Plain Java API?
One answer
WorkItemWorkingCopyManager wcmgr = IWorkItemClient.getWorkItemWorkingCopyManager();
wcmgr.connect(workItemHandle...);
WorkItemWorkingCopy wc = wcmgr.getWorkingCopy(workitemHandle);
WorkItem wi = wc.getWorkItem();
wi.setCategory(ICategory value);
wc.save();
wcmgr.disconnect(workItemhandle);
(You can also use the IWorkItemOperation class, it will connect and disconnect under the covers, making it look like a more atomic operation.. it cannot detect conflicts between multiple clients changing the same workitem at the same time)
to FIND the category,
Its a TREE, so take care that u search the whole tree..
CategoriesManager catManager = CategoriesManager.createInstance(IAuditableClient, IProjectAreaHandle, monitor);
CategoryTreeNode rootnode= catManager.getRoot();
rootnode.getChildren().... will get u the list of root level categories, then u have to search thru them to find the one that matches the text u have, or team area or ...
for (CategoryTreeNode node : rootnode.getChildren())
{
if(node.getName().equalsIgnoreCase(your_text))
{
// found category
ICategory xx = node.getCategory();
}
Ralph probably has a category search function in one of his blog entries. ;->
wcmgr.connect(workItemHandle...);
WorkItemWorkingCopy wc = wcmgr.getWorkingCopy(workitemHandle);
WorkItem wi = wc.getWorkItem();
wi.setCategory(ICategory value);
wc.save();
wcmgr.disconnect(workItemhandle);
(You can also use the IWorkItemOperation class, it will connect and disconnect under the covers, making it look like a more atomic operation.. it cannot detect conflicts between multiple clients changing the same workitem at the same time)
to FIND the category,
Its a TREE, so take care that u search the whole tree..
CategoriesManager catManager = CategoriesManager.createInstance(IAuditableClient, IProjectAreaHandle, monitor);
CategoryTreeNode rootnode= catManager.getRoot();
rootnode.getChildren().... will get u the list of root level categories, then u have to search thru them to find the one that matches the text u have, or team area or ...
for (CategoryTreeNode node : rootnode.getChildren())
{
if(node.getName().equalsIgnoreCase(your_text))
{
// found category
ICategory xx = node.getCategory();
}
Ralph probably has a category search function in one of his blog entries. ;->