I want to create jql query inside my java jira plugin. Query is something like this
Give me all issue where project is "x" and(
title is "y" or
summary is "y" or
key is "y" or
id is "y"
)
So, 1st 1 and condition and then all or condition.
title and summary are the same fields...
key and id are the same fields...
Summary is a free text field, in all free text field you can search only by ~
for example: summary ~ "test"
will find you all the tasks that their summary include the word "test"
So, for you question,
project = x AND (summary ~ "something" OR issuekey = XX-123)
@Nir Haimov I am trying to do it from java code. I have done this ->
JqlQueryBuilder queryBuilder = JqlQueryBuilder.newBuilder();
Query query = queryBuilder.where().project(Long.parseLong(projectKeyString)).and().summary(searchText).buildQuery();
But I need to put an or condition for summary, id, name and description. How to do it I am not find. it should project(). and(summery.or( title).or(id).or(name). Something like that
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I use jql in java differently:
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchResults;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.web.bean.PagerFilter;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.google.common.base.Throwables;
import com.wikistrat.jira.logic.PsProjectService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class MyClass {
private static final Logger logger = Logger.getLogger(PsProjectService.class);
private final SearchService searchService;
private final JiraAuthenticationContext authenticationContext;
@Autowired
public MyClass(@ComponentImport SearchService searchService,
@ComponentImport JiraAuthenticationContext authenticationContext) {
this.searchService = searchService;
this.authenticationContext = authenticationContext;
}
String query = String.format("project = %s and resolution is EMPTY and issuetype in (Epic)", projectKey);
List<Issue> issues = findByJql(query);
public List<Issue> findByJql(String jql) {
ApplicationUser applicationUser = authenticationContext.getLoggedInUser();
return getSelectedIssues(applicationUser, jql);
}
public List<Issue> getSelectedIssues(ApplicationUser applicationUser, String jql) {
SearchService.ParseResult parseResult = searchService.parseQuery(applicationUser, jql);
SearchResults searchResults;
try {
searchResults = searchService.search(applicationUser, parseResult.getQuery(), PagerFilter.getUnlimitedFilter());
} catch (SearchException ex) {
throw Throwables.propagate(ex);
}
return searchResults.getIssues();
}
}
Look at my "query", it looks exactly like regular jql.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.