Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Can anyone please provide a sample java client which will get all the attributes and the values of the specified workitem

Can anyone please provide a sample java client which will get all the attributes and the values of the specified workitem

0 votes



2 answers

Permanent link
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/

1 vote

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


Permanent link
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(...)

0 votes

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) 


in post 2 of this topic 

this will print the details for all attributes of a workitem
 

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Feb 10 '14, 8:00 a.m.

Question was seen: 5,696 times

Last updated: Feb 10 '14, 11:39 a.m.

Confirmation Cancel Confirm