Can anyone please provide a sample java client which will get all the attributes and the values of the specified workitem
2 answers
You can get at the built in attributes from somewhere else:
log("WorkItem: " + workItem.getId() + " "
+ workItem.getHTMLSummary().getPlainText() + "\t Type "
+ workItemType.getDisplayName() + "\n");
List builtInAttributeHandles = getWorkItemClient()
.findBuiltInAttributes(fProjectArea, monitor);
IFetchResult builtIn = getTeamRepository().itemManager()
.fetchCompleteItemsPermissionAware(builtInAttributeHandles,
IItemManager.REFRESH, monitor);
List custAttributeHandles = workItem
.getCustomAttributes();
IFetchResult custom = getTeamRepository().itemManager()
.fetchCompleteItemsPermissionAware(custAttributeHandles,
IItemManager.REFRESH, monitor);
log(builtIn.getMissingItems().size() + " "
+ builtIn.getNotFoundItems().size() + " "
+ builtIn.getPermissionDeniedItems().size() + " "
+ builtIn.getRetrievedItems().size() + "\n");
printAttributes(workItem, builtIn.getRetrievedItems());
printAttributes(workItem, custom.getRetrievedItems());
You can find more information about e.g. casting here: https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
Comments
List<IAttributeHandle> customAttributeHandles = workitem
.getCustomAttributes();
for (IAttributeHandle attributeHandle : customAttributeHandles) {
IAttribute attribute = (IAttribute) teamRepository.itemManager()
.fetchCompleteItem(attributeHandle, IItemManager.DEFAULT,
null);
//.... do something with attribute.
}
Please note that this only fetches custom attributes.
I'm not sure if it's possible to fetch all attributes. You normally access built-in attributes, by their individual getters and setters, for example:
workitem.getDueDate(...)
.getCustomAttributes();
for (IAttributeHandle attributeHandle : customAttributeHandles) {
IAttribute attribute = (IAttribute) teamRepository.itemManager()
.fetchCompleteItem(attributeHandle, IItemManager.DEFAULT,
null);
//.... do something with attribute.
}
Please note that this only fetches custom attributes.
I'm not sure if it's possible to fetch all attributes. You normally access built-in attributes, by their individual getters and setters, for example:
workitem.getDueDate(...)