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