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

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

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.

0 votes

Comments

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);

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.

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.

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

0 votes


Permanent link
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.

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,937
× 201
× 169

Question asked: May 20 '16, 4:03 a.m.

Question was seen: 3,775 times

Last updated: May 20 '16, 11:11 a.m.

Confirmation Cancel Confirm