It's all about the answers!

Ask a question

How can I get the list of the columns of a query using Plain API?


Michele Pegoraro (1.8k12114101) | asked May 20 '16, 4:03 a.m.
Hi, I've a shared query (an IQueryDescriptor) that I've obtained and used to get the result list (which is the list of work items returned by the query). I would like to know which are the field used in the query as output (the column list to be clear).

How can I obtain them?

Thanks,
Michele.

Comments
sam detweiler commented May 20 '16, 7:56 a.m.

in my execute shared query code, I supply the profile for the workitems.

see my code in the accepted answer here
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
private static void printResolved(IQueryClient queryClient,
            IQueryDescriptor queryToRun,

how did u execute the query?

I did
IQueryResult<IResolvedResult<IWorkItem>> resolvedResults = queryClient
                .getResolvedQueryResults(queryToRun, IWorkItem.FULL_PROFILE);


Ralph Schoon commented May 20 '16, 8:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Sam, the question as I understand it is, how to get the output columns (and parameters) that are specified for the query to print them according to the query specification.


Michele Pegoraro commented May 20 '16, 8:57 a.m.

Yes, it is correct. I'm already using the full profile otherwise I would not be able to get the values. I'm ok with the query results as work item list, I'm trying to get the query configuration for the output.


sam detweiler commented May 20 '16, 9:14 a.m.

yes, I understand what the question was..

I don't see that data in the query descriptor tho.. parameters is the filter for WHICH workitems, not the column contents.. t would make sense that there is a profile object saved with the query descriptor someplace.

2 answers



permanent link
SEC Servizi (97122549) | answered May 20 '16, 5:58 a.m.
In the Eclipse client, the com.ibm.team.workitem.ide.ui.internal.queryeditor.QueryEditorInput has a getConfiguration() method to return com.ibm.team.workitem.ide.ui.internal.queryeditor.QueryEditorConfiguration which has methods like getColumnAttributes(), getDefaultColumns(), getDefaultSortOrder(). Maybe it could help you...
Cheers.

permanent link
Michele Pegoraro (1.8k12114101) | answered May 20 '16, 11:11 a.m.
edited May 20 '16, 11:11 a.m.
I found it. Here it is if someone else needs it.

Expression exp = queryDescriptor.getExpression();
if(exp instanceof Statement){
            Statement statement = (Statement)exp;
            List<String> attributeIds = statement.getSelectClause().getColumnIdentifiers();
}

Statement object has also the sorting clause.

Your answer


Register or to post your answer.