It's all about the answers!

Ask a question

Programaticaly How to get list of Work Items for a specific time period?


V Niranjan (12534669) | asked Apr 21 '14, 10:43 p.m.
Hi All

I have  TASKS created between a specific time period say between Apr 14, 2014 to Apr 18 , 2014.

Programaticaly how to get list of Work Items for this specific time period?

Regards
Niranjan V

Accepted answer


permanent link
Takehiko Amano (1.3k3641) | answered Apr 22 '14, 12:15 a.m.
JAZZ DEVELOPER
Probably, the most easy way is to use Reports restAPI.

 https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#Resources_provided_by_RTC

For example, in you case:

https://<your-server>:9443/ccm/rpt/repository/workitem?fields=workitem/workItem[creationDate > 2014-4-14T10:10:53.000-0900 and  creationDate < 2014-4-18T10:10:53.000-0900](id|summary)


V Niranjan selected this answer as the correct answer

One other answer



permanent link
Susan Hanson (1.6k2190193) | answered May 02 '14, 3:39 a.m.
You can also do it using the Java APIs although you have to build the SQL yourself.  For example:

Term itemsToQuery = new Term(Operator.AND); //AND all my things together
IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute createDateAttribute = factory.findAttribute(myProjectArea, (IWorkItem.CREATION_DATE_PROPERTY), auditableClient, monitor);
Timestamp t = new Timestamp(2014 - 1900, 3, 22, 23, 59, 0, 0); //4/22/2014 00:00 - 4/22/2014 23:59
AttributeExpression startDateExpression = new AttributeExpression(creationDateAttribute,
                                                                          AttributeOperation.AFTER,
                                                                          t);
itemsToQuery.add(startDateExpression);

Then do the same thing with another Timestamp for the date you want and do a endDateExpress with the same creationDateAttribute, AttributeOperation.BEFORE, and the other Timestamp.

Then create a statement:
Statement s = new Statement(new SelectClause(), itemsToQuery, new SortCriteria[] { sortByIdSortCriteria }); //sortByIdSortCriteria is a SortCriteria object

And then the query uses the queryClient:
            IQueryResult<IResolvedResult<IWorkItem>> results = null;
            results = queryClient.getResolvedExpressionResults(myProjectArea, s, IWorkItem.FULL_PROFILE);

Then you can do results.next().getItem() to get the matchingWorkItems.





        Timestamp tt = new Timestamp(2014 - 1900, 3, 28, 0, 0, 0, 0); //4/22/2014 00:00 - 4/22/2014 23:59
        AttributeExpression endDateExpression = new AttributeExpression(creationDateAttribute,
                                                                        AttributeOperation.BEFORE,
                                                                        tt);
        newItemsToBridgeToJava.add(startDateExpression);

        /* Sort by id */
        SortCriteria byId = new SortCriteria(wasRepo.findQueryableAttribute(IWorkItem.ID_PROPERTY), true);

        /* Create statement */
        Statement s = new Statement(new SelectClause(), newItemsToBridgeToJava, new SortCriteria[] { byId });


Your answer


Register or to post your answer.