It's all about the answers!

Ask a question

How to query work item by status and change wi status programmatically?


Jia Jia Li (8057152192) | asked Aug 13 '12, 12:43 p.m.
retagged Apr 18 '13, 12:03 p.m. by Morten Madsen (3053149)
Hi, 
I have two requirement needed to be implement by Plain Java
1. Query the work item by status=resolved
2. Change the work item status to closed by action

Do you know how to do this?
I know the SDK2.0 wiki for create workitem, but do not know how to change status by action and query API.

Thanks very much!

2 answers



permanent link
Ralph Schoon (63.1k33645) | answered Aug 13 '12, 4:55 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I have used this kind of code to query:

        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);
        results.setLimit(Integer.MAX_VALUE);

        while (results.hasNext(monitor)) {
            IResolvedResult<IWorkItem> resresult = (IResolvedResult<IWorkItem>) results.next(monitor);
            IWorkItem item = resresult.getItem();

Not sure if there is a clause for querying a state group or state, I guess there is.

permanent link
Ralph Schoon (63.1k33645) | answered Aug 13 '12, 4:35 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Jia,

you can use pre built queries and you can create queries. i believe Robin has some code to get you started here: http://ryehle.wordpress.com/2012/06/28/custom-build-result-pruner/

See Sam's answer https://jazz.net/forum/questions/84612/workitem-state-change-programatically?page=1&focusedAnswerId=84627#84627 for the state change. You can also search the SDK for examples. I found the code there.

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.