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
...
}
|
One answer
Ralph Schoon (63.5k●3●36●46)
| answered Oct 07 '14, 10:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
|
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.