Unable to add string to DefaultJqlQueryParser.parseQuery()



We are running the below script, trying to automatically update the content of filters. It will be useful for us as in the near future we will have to change the names for all the projects in our JIRA instance, and all the filters will be updated. The script below should go through each filter id, change it into a string, make the change (old name to new name) and then change the string back to a jql object.

Somehow, the error that we receive when we run it through the console is:

No signature of method: static
com.atlassian.jira.jql.parser.DefaultJqlQueryParser.parseQuery() is
applicable for argument types: (java.lang.String) values: [project =
"nume nou" AND issuetype = Story ORDER BY Rank ASC]
Possible solutions: parseQuery(java.lang.String)

although, from our point of view, we gave it a string.

The script is below, but I also attached a screenshot.

import com.atlassian.crowd.embedded.api.User

import com.atlassian.jira.user.ApplicationUser;

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.search.SearchRequest

import com.atlassian.jira.issue.search.SearchRequestEntity

import com.atlassian.jira.issue.search.SearchRequestManager

import com.atlassian.jira.sharing.SharePermission

import com.atlassian.jira.sharing.SharePermissionImp

limport com.atlassian.jira.sharing.SharedEntity.SharePermissions

import com.atlassian.jira.sharing.type.ShareType.Name    

import com.atlassian.jira.bc.filter.SearchRequestService

import com.atlassian.jira.jql.parser.DefaultJqlQueryParser

import com.atlassian.jira.bc.issue.search.SearchService

import com.atlassian.query.Query

def list = [32100,32000]

for (String item : list) { long l = Long.parseLong(item);

SearchRequestManager srm = ComponentAccessor.getComponentOfType(SearchRequestManager.class);

def searchService = ComponentAccessor.getComponentOfType(SearchService.class)     

for (eachitem in l)

{ SearchRequest filter = srm.getSearchRequestById((Long)eachitem);

String str = filter.getQuery().getQueryString() str= str.replace ("Wow a new name", "nume nou")

def jqlqueryparser = DefaultJqlQueryParser.parseQuery((String)str)


return jqlqueryparser }



1 answer

1 accepted

0 votes
Accepted answer

parseQuery is not a static method. You have to define an object for JqlQueryParser like you do with SearchService.

Yes, correct! The script is now working after defining the object.

Thank you!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,081 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you