Unable to add string to DefaultJqlQueryParser.parseQuery()

 

Hello,

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)

filter.setQuery(jqlqueryparser)   

return jqlqueryparser }

   }

 

1 answer

1 accepted

0 vote

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

212 views 1 18
Join discussion

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