Need Java api calls for listing and executing Queries
8 answers
You have to use IQueryService, IQueryClient or IQueryCommon (it depends on what kind of use do you need). Then you can use, for example
IQueryCommon.findPersonalQueries
IQueryCommon.findSharedQueries
in order to get queries and than
IQueryCommon.getQueryResults(query)
to get results.
Best regards,
Michele.
IQueryCommon.findPersonalQueries
IQueryCommon.findSharedQueries
in order to get queries and than
IQueryCommon.getQueryResults(query)
to get results.
Best regards,
Michele.
So now i got it and I want to share the results here.
The Queryclient is initialzied like this
The query I search is shared within my Projectarea. It could also be a Team. Or both i think.
The project is from type IProjectArea
The method call for the SharedQueries
The Queryclient is initialzied like this
IWorkItemClient Client = (IWorkItemClient) this.teamRepository.getClientLibrary(IWorkItemClient.class);
IQueryClient QueryClient = Client.getQueryClient();
The query I search is shared within my Projectarea. It could also be a Team. Or both i think.
List<IProjectAreaHandle> sharingTargets = new ArrayList<IProjectAreaHandle>();
The project is from type IProjectArea
sharingTargets.add(Project.getProjectArea());
The method call for the SharedQueries
List<IQueryDescriptor> SharedQueries = QueryClient.findSharedQueries(Project.getProjectArea(), sharingTargets, QueryTypes.WORK_ITEM_QUERY, QueryDescriptor.FULL_PROFILE, monitor);The method call for your personal "My Queries"
List<IQueryDescriptor> MyQueries = QueryClient.findPersonalQueries(Project.getProjectArea(), (IContributorHandle)this.teamRepository.loggedInContributor().getItemHandle(), QueryTypes.WORK_ITEM_QUERY, QueryDescriptor.FULL_PROFILE, monitor);
I don't know how to do it exactly, but there is no simple 'api'... there are a bunch of methods on objects as this is an Object Oriented system..
you will have to connect to the repository and then use the IQuery interface classes to get and manage queries
see com.ibm.team.repository.common.query in the javadoc provided with 3.0.1.1. you will need some of com.ibm.team.repository.client and common to do that..
Sam
you will have to connect to the repository and then use the IQuery interface classes to get and manage queries
see com.ibm.team.repository.common.query in the javadoc provided with 3.0.1.1. you will need some of com.ibm.team.repository.client and common to do that..
Sam
You have to use IQueryService, IQueryClient or IQueryCommon (it depends on what kind of use do you need). Then you can use, for example
IQueryCommon.findPersonalQueries
IQueryCommon.findSharedQueries
in order to get queries and than
IQueryCommon.getQueryResults(query)
to get results.
Best regards,
Michele.
Hi Michele,
Do you know what value I should be passing in as the QueryType to those method calls? I have been trying to use them and I keep getting back empty lists.
String queryType= "WorkItemQuery";
ItemProfile<IQueryDescriptor> defaultprofile = IQueryDescriptor.DEFAULT_PROFILE;
List<IQueryDescriptor> personalQueries = queryClient.findPersonalQueries(projectArea, teamRepository.loggedInContributor(), queryType, defaultprofile, null);
Regards,
Adam
For my own Query i could get results with this call:
Now I stuck at the "List<extends>" for the sharingTargets at the findSharedQueries method.
Any ideas what that target is?
Regards
Tobias
List<IQueryDescriptor> Queries = QueryClient.findPersonalQueries(Project.getProjectArea(), (IContributorHandle)this.teamRepository.loggedInContributor().getItemHandle(), QueryTypes.WORK_ITEM_QUERY, QueryDescriptor.FULL_PROFILE, monitor);
Now I stuck at the "List<extends>" for the sharingTargets at the findSharedQueries method.
Any ideas what that target is?
Regards
Tobias
This post shows working code it especially allows you to exceed the query result set size limit. https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/