Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Custom JQL - Jira 8.x compatible

I have a series of JQLs like:

package com.onresolve.jira.groovy.jql

import com.atlassian.jira.lucenelegacy.NumberTools
import com.atlassian.jira.lucenelegacy.NumericUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.operand.QueryLiteral
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.jql.query.RangeQueryFactory
import com.atlassian.jira.util.MessageSetImpl
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.query.operand.FunctionOperand
import com.atlassian.query.operator.Operator
import org.apache.log4j.Category
import com.atlassian.jira.util.MessageSet
import com.atlassian.crowd.embedded.api.User
import com.atlassian.query.clause.TerminalClause
import com.atlassian.jira.jql.query.QueryCreationContext
import org.apache.lucene.index.Term
import org.apache.lucene.search.Query
import org.apache.lucene.search.TermQuery
import com.onresolve.jira.groovy.jql.AbstractScriptedJqlFunction
import org.apache.lucene.search.BooleanClause
import org.apache.lucene.search.BooleanQuery
import org.apache.lucene.search.Query
import org.apache.lucene.search.TermQuery
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.security.JiraAuthenticationContext;

 

class HasInactiveAssignee extends AbstractScriptedJqlFunction implements JqlQueryFunction{
@Override
String getDescription() {
"Function to show only the inactive users"
}

@Override
List<Map> getArguments() {
[
[
"description": "Subquery",
"optional": false,
]
]
}

@Override
String getFunctionName() {
"hasInactiveAssignee"
}

def String subquery
//@Override
MessageSet validate(User user, FunctionOperand operand, TerminalClause terminalClause) {
def messageSet = new MessageSetImpl()
return messageSet
}

@Override
Query getQuery(QueryCreationContext queryCreationContext, FunctionOperand operand, TerminalClause terminalClause) {
//User user=ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
JiraAuthenticationContext context = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser applicationUser = context.getUser();
def booleanQuery = new BooleanQuery()
issues = getIssues(operand.args[0], applicationUser)
issues.each {Issue issue ->
try{
def active = issue.assignee.isActive()
if ( !active )
booleanQuery.add(new TermQuery(new Term("issue_id", issue.id as String)), BooleanClause.Occur.SHOULD)
}catch(NullPointerException NPE){

}
}

return booleanQuery
}
}

 

 

------

 

This is not Jira 8.x compatible - and I have added/replaced (as statted on https://confluence.atlassian.com/adminjira/lucene-upgrade-955171970.html)

 

com.atlassian.jira.index.NumberTools
com.atlassian.jira.util.LuceneNumericUtils

moved → com.atlassian.jira.lucenelegacy.NumberTools

moved → com.atlassian.jira.lucenelegacy.NumericUtils

 

But some small code tweaks are missing. Any help out there?

 

Current error:

 

2019-05-03 14:26:42,832 http-nio-6060-exec-1 ERROR npn 866x32109x2 dktr5i 77.243.XX.XX /rest/issueNav/1/issueTable [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Could not find which method <init>() to invoke from this list:
org.apache.lucene.search.BooleanQuery#<init>(int, [Lorg.apache.lucene.search.BooleanClause;, org.apache.lucene.search.BooleanQuery$1)
private org.apache.lucene.search.BooleanQuery#<init>(int, [Lorg.apache.lucene.search.BooleanClause;)
org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method <init>() to invoke from this list:
org.apache.lucene.search.BooleanQuery#<init>(int, [Lorg.apache.lucene.search.BooleanClause;, org.apache.lucene.search.BooleanQuery$1)
private org.apache.lucene.search.BooleanQuery#<init>(int, [Lorg.apache.lucene.search.BooleanClause;)
at groovy.lang.MetaClassImpl.chooseMethodInternal(MetaClassImpl.java:3223)
at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:3160)
at groovy.lang.MetaClassImpl.createConstructorSite(MetaClassImpl.java:3467)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:90)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Data Center

Introducing Data Center Community licenses

I'm Alison Huselid, Head of Product for Data Center at Atlassian. As we shared in our last post, we’ve been working on a solution for those of you who work for charitable non-profit organizations tha...

229 views 1 17
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you