Can anyone please provide a sample java client which will get all the attributes and the values of the specified workitem
2 answers
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
Below is my example i am trying...
List builtInAttributeHandles = workItemClient.findBuiltInAttributes(projectArea, null);
for (Iterator iterator = builtInAttributeHandles.iterator(); iterator.hasNext();) {
IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator.next();
IAttribute iAttribute = (IAttribute) repository.itemManager().fetchCompleteItem(iAttributeHandle, IItemManager.DEFAULT ,null);
System.out.println("getIdentifier->"+ iAttribute.getIdentifier());
System.out.println("getAttributeType->"+ iAttribute.getAttributeType());
System.out.println("getDisplayName->"+ iAttribute.getDisplayName());
System.out.println("getFullTextKind->"+ iAttribute.getFullTextKind());
IAttribute someAttribute= workItemClient.findAttribute(projectArea, iAttribute.getIdentifier(), null);
}
Just want to use this someAttribute variable to get the workItem and finally to print the value of the attribute...
Can you please help me in this... Or please if you have any class file, you can share me... I will refer to that and complete the rest.. Thanks
.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(...)
Comments
Hi,
Thanks for the reply. I am looking for a method or a simple class which prints the attributes and also its corresponding values for the given workitem.
Thanks,
I guess you have to write that yourself as I did below.
The methods below get the data, cast it and print it.
see the function static void printAttributes(IWorkItem workItem,
IAuditableClient auditableClient, IProjectArea projectArea,
org.eclipse.core.runtime.IProgressMonitor monitor, ITeamRepository repository, String XML)