Unable to add string to DefaultJqlQueryParser.parseQuery()

AramaM September 19, 2017

 

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
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2017

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

AramaM September 20, 2017

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

Thank you!

Suggest an answer

Log in or Sign up to answer