package com.onresolve.jira.groovy.jql

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
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.document.NumberTools
import org.apache.lucene.index.Term
import com.onresolve.jira.groovy.jql.AbstractScriptedJqlFunction
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;

class HasInactiveReporter extends AbstractScriptedJqlFunction implements JqlQueryFunction{
    String getDescription() {
        "Function to show only the inactive users"

    List<Map> getArguments() {
                "description": "Subquery",
                "optional": false,

    String getFunctionName() {

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

    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 ->
								def active = issue.reporter.isActive()
								if ( !active )
                                booleanQuery.add(new TermQuery(new Term("issue_id", as String)), BooleanClause.Occur.SHOULD)
                        }catch(NullPointerException NPE){
        return booleanQuery

Posted by:.

2 replies on “Custom JQL Function “HasInactiveReporter” and “HasInactiveAssignee” compatible with JIRA 7

    1. Yes is for scriptrunner…. but in few days I want to do a new plugin with a couple of jql functions like this ( jql native, not dependent of scriptrunner


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s