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

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

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!

0 votes



2 answers

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

0 votes


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

0 votes

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
× 10,948

Question asked: Aug 13 '12, 12:43 p.m.

Question was seen: 5,563 times

Last updated: Apr 18 '13, 12:03 p.m.

Confirmation Cancel Confirm