Please help me to write JQLQuery

AlexeyH March 6, 2012

Hello!
Please help me to write JQLQuery which will be equivalent to real-query :

project="PROJECT" AND issuetype = Bug AND status was in ("RESOLVED") before 2012-03-06

At this time I build JQLQuery

queryBuilder.where().project(PROJECT_ID).and().issueType("Bug").and().status(RESOLVED)

How I can realize part: before 2012-03-06 ?
Thanks!

2 answers

1 vote
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.
March 6, 2012

Try lt (less than) operator for before.

http://docs.atlassian.com/jira/latest/com/atlassian/jira/jql/builder/ConditionBuilder.html#lt(java.lang.String)

Alternatively, you can write the query as a String a parse it to a Query object.

0 votes
MatthewC
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.
March 7, 2012

Here's some sample code for a plugin I've just written that takes JQL string. Easier than working our the train-carriage approach of building the query.

            final UserUtil userUtil = ComponentManager.getInstance().getUserUtil(); 
            String serviceAccountName = "SERVICE_ACC_NAME";
            User serviceAccount = userUtil.getUser(serviceAccountName);

            String jqlQuery ="projec;t="PROJECT" AND issuetype = Bug AND status was in ("RESOLVED") before 2012-03-06"

            SearchService.ParseResult parseResult =  searchService.parseQuery(serviceAccount, jqlQuery);              
            assert parseResult.isValid() : "Invalid JQL, can't parse: " + jqlQuery;  
           
            final SearchResults results = searchService.search(serviceAccount, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
            List<Issue> issueList = results.getIssues();

AlexeyH March 11, 2012

Thanks a lot for your answers!

Suggest an answer

Log in or Sign up to answer