To create and run a search using the Jira API, obtain a SearchRequest object and addParameter's to it.
SearchRequest sr = new SearchRequest(remoteUser); sr.addParameter(new StatusParameter( String.valueOf(IssueFieldConstants.RESOLVED_STATUS_ID) )); sr.addParameter(new DateParameter(DocumentConstants.ISSUE_UPDATED, EntityOperator.GREATER_THAN_EQUAL_TO, start)); sr.addParameter(new DateParameter(DocumentConstants.ISSUE_UPDATED, EntityOperator.LESS_THAN_EQUAL_TO, end)); sr.addParameter(new ProjectParameter(projectid)); resolvedCount=searchProvider.searchCount(sr, remoteUser);
If the Jira search API doesn't do what you need, you may need to extract issues from a search and loop over them.
Collection issueList=searchProvider.search(sr,remoteUser);
Iterator issIt=issueList.iterator();
while (issIt.hasNext()){
GenericValue issue = (GenericValue) issIt.next();
Map myIssue = issue.getAllFields();
//log.debug("iss="+issue.getAllFields()+","+issue.getAllKeys());
log.debug("check issue "+myIssue.get("key")+" res= "+myIssue.get("resolution"));
}
Things like creation date are in the main issue object's map, see Issue Properties, resolved dates etc. are in the issues change log, see JiraIssueChangeHistory.
Labels:

9 Comments
Hide/Show CommentsJun 23, 2005
E Joseph Guay
You can also use sr.getQueryString() to create an URL of the form:
<server>/secure/IssueNavigator.jspa?reset=true&mode=hide&<sr.getQueryString()>
to list the issues in the Issue Navigator screen.
Jun 23, 2005
E Joseph Guay
Once you have an issue, you can lookup the value of a custom field as follows:
CustomField severity = customFieldManager.getCustomFieldObjectByName("Severity");
Object severityValue = severity.getValue(issue);
Jun 24, 2005
Praveen Kallakuri
I am being a little lazy here, but any suggestions on how to create a search using a custom field?
Oct 17, 2005
Mike Doustan
How would one search for a particular "Summary" or "Description?"
Oct 18, 2005
Nick Menere
Mike,
You should be able to do something like the following:
Or if you wish you strings to be stemmed you can use a FreeTextParameter.
Cheers,
Nick
Nov 19, 2005
Mike Doustan
I have a select list custom field. What is the proper searchparameter to use for searching a select list? I tried FreeTextParameter, but that did not seem to work.
Thank you,
Mike
Nov 20, 2005
Mark Chaimungkalanont
Mike
You should use the
StringParametersearch parameterCheers
Mark C
Nov 03, 2006
Matthias David
Is it possible to search for votes on issues? For example get all issues where the number of votes is greater than 10?
I could not find a SearchParameter for this.
Thanks,
Matthias.
Sep 21, 2010
Betsy Walker
Is there a way to make a copy of a filter for another user? I'd like to do so via a Groovy script if possible.
Thanks!