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

retrieving the conditions of a query programatically using the plain Java client libraries

I have seen a couple of posts on how to create query conditions using Java, but I would like to retrieve the conditions of every predefined query, for administration and reporting purposes.

Ideally, we would like to have something similar to a WHERE clause in an SQL statement. E.g.: WHERE ((Work_Item_Type == 'Task') AND (Priority == 'Medium'))
I guess we can use the Statement, Term and Operator classes as follows, but I was wondering if there is an easier way. Any ideas?

List<IQueryDescriptor> queryDescriptorList = queryClient.findSharedQueries(prj, sharingTargets, QueryTypes.WORK_ITEM_QUERY, IQueryDescriptor.FULL_PROFILE, monitor);
for (int countQueryDescriptor=0;countQueryDescriptor<queryDescriptorList.size();countQueryDescriptor++) {
IQueryDescriptor queryDescriptor = queryDescriptorList.get(countQueryDescriptor);
Statement stmt = (Statement)queryDescriptor.getExpression();
Term term = (Term) stmt.getConditions();
List<Expression> listConditions = term.getExpressions();
//Use a recursive function to retrieve all expressions along with their operators
...
}

0 votes



One answer

Permanent link
I would think that is the way to do it. You might want to check com.ibm.team.workitem.ide.ui.internal.queryeditor.QueryEditor how it does it. My assumption is, it would do it the very same way. You'd get a tree of expressions and conditions.

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,941

Question asked: Oct 07 '14, 9:23 a.m.

Question was seen: 3,693 times

Last updated: Oct 07 '14, 10:06 a.m.

Confirmation Cancel Confirm