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 votes

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,760 views 11 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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot