Page 1 of 1

Get work item from whole repository with Java API

Posted: Mon May 30, 2016 8:16 am
by etruog
Hello community

I'm trying to figure out how to get a work item from the whole repository without the project ID.
Every function i can find to get a work item needs the project ID as parameter.

What I wanna do is to find a work item by ID to find out in which project this work item is. After that i want to create a new work item in the same project and link it to the work item i found.

I tried something like

Code: Select all

trackerService.getWorkItemById("Default Repository", itemID);

or

Code: Select all

trackerService.getWorkItemById("Reporitory", itemID);

but none of these are working.

With the web interface it is possible to search the whole repository for a particular work item.
So my question is: How can i do this with the Java API?

Thank you very much! :)

Re: Get work item from whole repository with Java API

Posted: Wed Mar 21, 2018 4:06 pm
by stewarca
Did you find a way to do this?

Re: Get work item from whole repository with Java API

Posted: Mon Jul 30, 2018 1:06 pm
by rpn
I am using the WebServices via the .ne-wrapper, the methods there should be the same.

Why don't you iterate over all projects/Modules/WorkItems in that space and search for the item in every project?

Alternative 1: The TrackerService has a method that allows you to pass an arbitrary lucene-query:
Tracker.queryWorkItems(string query, string sort, string[] fields)
The query can be buildt using the webinterface of polarion.

Alternative 2: Check the postgre-DB that runs in your polarion-installation. You can write concise SQL-Queries against that, which would be faster, than iterating and using the webservice/SDK. [SQL query is available also over the WebService TrackerWebService.queryWorkItemsBySQL([...])]

In the installation I am working with, every item is prefixes with a project-prefix, so there is no question about the project a item belongs to.