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
...
}