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?
|
2 answers
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. Comments
Andrew Soloninka
commented May 23 '13, 11:59 a.m.
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.
|
Found the constant IQueryService.EMPTY_PARAMETERS
I used it for the parameters parameter and it worked.
|
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.