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

Need Java api calls for listing and executing Queries

Hi all,

I have a requirement where I need to show the list of pre-defined queries and my queries created in RTC 3.0 in my Java client code. Also, I need to execute those queries and display the results. Can anyone provide me with sample code for doing this?

Thanks,
Sumana Bhat

0 votes



8 answers

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

1 vote


Permanent link
So now i got it and I want to share the results here.

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

1 vote


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

0 votes


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

0 votes


Permanent link
I'm at the same point like you. Did you already find out which value you have to pass for QueryType?

Regards,
Tobias

0 votes


Permanent link
In many cases, the only answers are to read the source code.

Sam

0 votes


Permanent link
For my own Query i could get results with this call:

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

0 votes

Comments

SharingTarget could be a List of IProjectAreaHandle as in the example above. What is the problem with "extends"?


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

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

Question asked: Dec 08 '11, 7:25 a.m.

Question was seen: 8,000 times

Last updated: Feb 11 '13, 4:08 p.m.

Confirmation Cancel Confirm