Missed Team ’24? Catch up on announcements here.

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

How do I build a Query like "status changed to Closed before -1d"? (Java API)

saraponga January 29, 2013

I need to build a Query like "status changed to Closed before -1d" for my Jira plugin, but I am unable to find any suitable examples for how to build queries with history and I am now stuck.

I hope anyone of you can give me some pointers.

Thanks a lot in advance.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Henning Tietgens
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.
January 30, 2013

Hi,

try this:

import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.web.bean.PagerFilter;

SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
String jqlQuery = "status changed to Closed before -1d";
SearchService.ParseResult parseResult =  searchService.parseQuery(user, jqlQuery);
if (parseResult.isValid()) {
    query = parseResult.getQuery(); 
} else {
    log.error("Invalid JQL: " + jqlQuery);
}

Henning

saraponga January 30, 2013

Of course that works! I had totally missed that awesome method in the service. Thank you, you made my day! =)

0 votes
C_ Faysal
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.
January 30, 2013

you mean sth like this?

<jira_host>/rest/api/2/search?jql=status changed to Closed BEFORE -1d

saraponga January 30, 2013

Yes, but using the java api and the JqlQueryBuilder.

C_ Faysal
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.
January 30, 2013

oh ok sorry. no idea then atm.

TAGS
AUG Leaders

Atlassian Community Events