I am programming a service within a plugin. It is a service that is programmed in the administration for automatic execution. I need to do JQL queries from it, but 0 records are always retrieved.
If the same query is executed within another action, it does return results. From the service, the AO query and the retrieval of data from objects such as the issue, the project, the history, ... work well, but not the JQL queries.
Any idea to be able to carry out that query from here?
public class UpdateDaysInsStatusService extends AbstractService{
@Override
public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
return getObjectConfiguration("UpdateDays", "services/updateDays.xml", null);
}
@Override
public void run() {
pruebajql("Backlog");
}
private void pruebajql (String estado) {
SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
builder.where().project("TKB").and().status(estado);
Query query = builder.buildQuery();
SearchResults<Issue> results;
try {
results = searchService.search(user, query, PagerFilter.getUnlimitedFilter());
System.out.println(" filas encontradas: " + results.getResults().size());
} catch (SearchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}