JiraCreateSearch

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

 
(None)
  1. Jun 23, 2005

    E Joseph Guay says:

    You can also use sr.getQueryString() to create an URL of the form: <server>/sec...

    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.

  2. Jun 23, 2005

    E Joseph Guay says:

    Once you have an issue, you can lookup the value of a custom field as follows: ...

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

  3. Jun 24, 2005

    Praveen Kallakuri says:

    I am being a little lazy here, but any suggestions on how to create a search usi...

    I am being a little lazy here, but any suggestions on how to create a search using a custom field?

  4. Oct 17, 2005

    Mike Doustan says:

    How would one search for a particular "Summary" or "Description?"

    How would one search for a particular "Summary" or "Description?"

  5. Oct 18, 2005

    Nick Menere says:

    Mike, You should be able to do something like the following: SearchRequest s...

    Mike,

    You should be able to do something like the following:

    SearchRequest sr = new SearchRequest(remoteUser);
    sr.addParameter(new StringParameter(DocumentConstants.ISSUE_SUMMARY, "example summary"));
    sr.addParameter(new StringParameter(DocumentConstants.ISSUE_DESC, "example desctiption"));
    resolvedCount=searchProvider.searchCount(sr, remoteUser);

    Or if you wish you strings to be stemmed you can use a FreeTextParameter.

    Cheers,
    Nick

  6. Nov 19, 2005

    Mike Doustan says:

    I have a select list custom field.&nbsp; What is the proper searchparameter to u...

    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

  7. Nov 20, 2005

    Mark Chaimungkalanont says:

    Mike You should use the {{StringParameter}} search parameter Cheers Mark C

    Mike

    You should use the StringParameter search parameter

    Cheers

    Mark C

  8. Nov 03, 2006

    Matthias David says:

    Is it possible to search for votes on issues? For example get all issues where t...

    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.