Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

REST Services: Get issues by filter

Carl Nolan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Hi,

Can't seem to find any examples/info about this. I have a JIRA gadget which takes a project ID (example: "project-1000") which comes from a dropdown box and then creates a certain graph of issues for that project.

I did this by writing a REST service (I think that's what it's called) in Java which uses ComponentManager.getIssueManager().getIssueIdsForProject().

However now I need to add the ability to choose a filter instead of a whole project. I've gotten as far as getting the filter id (ex: "filter-10000") to the Java backend service but I can't find a method which will do something similar to getIssueIdsForProject() for a filter id.

Anyone know how I'd go about this?

Thanks in advance.

Carl

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Use SearchRequestService to get the SearchRequest.

http://docs.atlassian.com/jira/4.4.5/com/atlassian/jira/bc/filter/SearchRequestService.html#getFilter%28com.atlassian.jira.bc.JiraServiceContext,%20java.lang.Long%29

After you do that, try the following:

List<Issue> issues = searchService.search(user, searchRequest.getQuery(), PagerFilter.getUnlimitedFilter());

Carl Nolan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Hey Jobin, this looks like the right way to go except I'm not sure how to use getFilter. I'm trying something along the lines of this at the moment:

SearchRequest sr = SearchRequestService.getFilter(null, filterId);

But I know this is wrong. getFilter isn't static. Could you possibly give me some example code?

Thanks.

EDIT: I've gotten it to this:

SearchRequest sr = ??.getFilter(new JiraServiceContextImpl(user), filterId);

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

Use ComponentManager.getSearchRequestService().getFilter....

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

or inject it in the constructor as you do with other manager classes!

Carl Nolan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 3, 2012

Okay I think I almost have it. Do you have any idea why the following lines would cause the plugin to not get compiled/deployed with atlas-cli?

SearchRequest sr = cm.getSearchRequestService().getFilter(new JiraServiceContextImpl(user), filterId);
SearchService ss = cm.getSearchService();
        	
PagerFilter filter = PagerFilter.getUnlimitedFilter();
com.atlassian.query.Query filterQuery = sr.getQuery();

SearchResults results = ss.search(user, filterQuery, filter);
List<Issue> issues = results.getIssues();

As you can see I've broken it up all into individual lines, this was to try find the culprit. Turns out it's this line:

SearchResults results = ss.search(user, filterQuery, filter);

Any idea why?

Thank you again and sorry for being so helpless!!

Carl Nolan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 3, 2012

Was missing a try/catch around that one line! Stupid! Thank you for all your help

0 votes
Erik Dasque May 2, 2012

Just use:

https://yourdomain.jira.com/rest/api/latest/search?jql=assignee was erik

or something similar

Carl Nolan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2012

I think this would only fetch the results on the Javascript side? I need to get them into Java to do some work on them first. Thanks though

Erik Dasque May 2, 2012

Yes, this is the REST endpoint for it. How you use it is language dependant.

TAGS
AUG Leaders

Atlassian Community Events