It's all about the answers!

Ask a question

How to retrieve a work item by Java plain client API?


0
1
Alex Zhang (111) | asked Aug 24 '09, 2:07 a.m.
I wanna query and collect work items information of a specific project by a java plain client. The Java plain client for Jazz has been downloaded and installed, but I CANNOT find the API interface for retrieving existing work item of a project. The Snippet sample just explains how to create work item. Please give a hand. Any hint is appreciated.

2 answers



permanent link
Patrick Streule (4.9k21) | answered Aug 24 '09, 8:31 a.m.
JAZZ DEVELOPER
I wanna query and collect work items information of a specific project
by a java plain client. The Java plain client for Jazz has been
downloaded and installed, but I CANNOT find the API interface for
retrieving existing work item of a project. The Snippet sample just
explains how to create work item. Please give a hand. Any hint is
appreciated.

Also take a look at the Developer's Guide to Querying Work Items:
http://jazz.net/wiki/bin/view/Main/QueryDevGuide

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Ralph Schoon (63.1k33646) | answered Aug 24 '09, 8:13 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
you should really ask in this forum: http://jazz.net/forums/viewforum.php?f=2 since they are talking about exactly your questions there. You could also search the forum, since I am positive I found the answer to your question there.

In the meantime here some code that I happen to have and I believe should also work with the Plain Java Api. This is only one possible way to do it. You can create and run queries etc.

IWorkItemClient workItemService = (IWorkItemClient) targetRepository
.getClientLibrary(IWorkItemClient.class);
IQueryClient queryClient = workItemService.getQueryClient();
IAuditableClient auditableClient = (IAuditableClient)targetRepository.getClientLibrary(IAuditableClient.class);
IQueryableAttribute attribute=QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(targetProjectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
Expression inProjectArea= new AttributeExpression(attribute,AttributeOperation.EQUALS, targetProjectArea);
IQueryResult<IResolvedResult<IWorkItem>> results=queryClient.getResolvedExpressionResults(targetProjectArea, inProjectArea,IWorkItem.SMALL_PROFILE);

while (results.hasNext(monitor)) {
IResolvedResult<IWorkItem> resresult = (IResolvedResult<IWorkItem>) results.next(monitor);
IWorkItem item = resresult.getItem();
System.out.println(item.getId()+" " + item.getHTMLSummary().toString());
...............

Your answer


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