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

What parameters are needed to instantiate an ItemQueryIterator object

 As part of an Asynchronous Task, I need to get a list of Project Areas so I use the code snippet below:

private List<IProjectAreaHandle> findProjectAreas(IProgressMonitor monitor) throws TeamRepositoryException {
IItemType itemType= IProjectArea.ITEM_TYPE;
IDynamicQueryModel model= itemType.getQueryModel();
IItemQuery query= IItemQuery.FACTORY.newInstance((IItemQueryModel) model);
IQueryService queryService = getService(IQueryService.class);
ItemQueryIterator<IProjectAreaHandle> iterator= new ItemQueryIterator<IProjectAreaHandle>(queryService, query, parameters );
return iterator.getAllItems();
}

When instantiating ItemQueryIterator, one of the parameters is an Object array called parameters. What values do I use for this array? Can you point me to documentation that would answer this question?

0 votes



2 answers

Permanent link
Found the constant  IQueryService.EMPTY_PARAMETERS 

I used it for the parameters parameter and it worked.

0 votes


Permanent link
Hi Andrew,

if your query is parameterized, you will pass an array with the expected parameters. In the snippet you provide however, you wouldn't need to pass parameters so you can use the constructor that doesn't expect parameters:

ItemQueryIterator(IServerQueryService queryService, IItemQuery query)

Note that for querying for the project areas you can find a snippet of code here: https://jazz.net/wiki/bin/view/Main/QueryDevGuide.

Regards,

Jorge.

0 votes

Comments
I think the constructor above has been removed because I checked the source code and only found 2 constructors for  ItemQueryIterator:

public ItemQueryIterator(IQueryService queryService, IItemQuery itemQuery, Object[] parameters) throws TeamRepositoryException 
-----------------------------------------------------------------------------------------------------------

public ItemQueryIterator(IQueryService queryService, IItemQuery itemQuery, Object[] parameters, int pageSize) throws TeamRepositoryException 


Both of them require the parameters parameter.


Note there are more than one "ItemQueryIterator" classes. The one from the wiki page I mentioned is from work items.

Anyway, your solution of "IQueryService.EMPTY_PARAMETERS" sounds good to me as well.

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

Question asked: May 22 '13, 5:10 p.m.

Question was seen: 4,899 times

Last updated: Jun 28 '13, 7:09 p.m.

Confirmation Cancel Confirm