Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

static type checking cannot find matching constructor

Juan Felipe Garcia Carreño August 25, 2023 edited

I usually work a lot with Scriptrunner in Jira, and I'm facing a problem I have not been able to solve yet.

 

It concerns the update of a script field which uses a Regex to filter components and then displays them. When I create a new component which is supposed to pass the filter, it does not appear within the field until I manually update the script field (via the Scriptrunner menu).

 This is the code for the Script field:

 

import org.apache.commons.lang3.StringUtils
import java.util.regex.*
import com.onresolve.scriptrunner.canned.jira.fields.model.PickerOption
import com.onresolve.scriptrunner.parameters.annotation.ComponentPicker
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager

def projectComponentManager = ComponentAccessor.getComponent(ProjectComponentManager)

Collection<ProjectComponent> projectComponents = projectComponentManager.findAllForProject(40500)
List<ProjectComponent> newOptions = []
log.warn("GET COMPONETS: " + projectComponents)

/*
@ComponentPicker(
    label = 'Component', description = 'Pick a component',
    projectPlaceholder = 'Pick a project', placeholder = 'Pick a component'
)
*/
ProjectComponent component

//Creates new list with all Option values that match the names of the existing components
for (a in projectComponents){
    if(useRegex(a.getName())){
        newOptions.add(a)
    }
}

search = { String inputValue ->
    newOptions.findAll {
        !it.archived && StringUtils.containsIgnoreCase(it.name, inputValue)
    }
}

getItemFromId = { String id ->
    projectComponentManager.getProjectComponent(id.toLong())
}

toOption = { ProjectComponent compo, Closure highlight ->
    new PickerOption(
        value: compo.id.toString(),
        label: compo.name,
        html: "${highlight(compo.name, false)}",
    )
}

renderItemViewHtml = { ProjectComponent compo ->
    "$compo.name ${getLozenge(compo)}"
}

renderItemTextOnlyValue = { ProjectComponent compo ->
    compo.name
}

String getLozenge(ProjectComponent compo) {
    if (compo.isArchived()) {
        '<span class="aui-lozenge aui-lozenge-subtle">Archived</span>'
    } else if (compo.deleted) {
        '<span class="aui-lozenge aui-lozenge-success aui-lozenge-subtle">Deleted</span>'
    } else {
        '<span class="aui-lozenge aui-lozenge-current aui-lozenge-subtle"></span>'
    }
}

//Method for searching a Regular Expression (in red)
public String useRegex(String input) {
       
        // Compile regular expression
        final Pattern pattern = Pattern.compile(/R_Topic_\\*/, Pattern.CASE_INSENSITIVE);
        // Match regex against input
        final Matcher matcher = pattern.matcher(input);
        // Return results that match the regex...
        if(matcher.find()){
            return input
        }
        else{
            return
        }
}

I'm trying to use a way to reindex all issues from a listener which gets triggered by a ProjectComponentCreated event:
But it does not compile and the error goes like: static type checking cannot find matching constructor for these two: 
import com.atlassian.jira.task.context.LoggingContextSink
import com.atlassian.jira.task.context.PercentageContext

1 answer

0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
October 6, 2023

Hi @Juan Felipe Garcia Carreño

From the documentation link you shared, which points to the Reindex All Issues with Scripted Fields section, the Listener event you need to use is the ReindexAllCompletedEvent.

Have you tried using that event? I am asking this because your description mentioned that you have tried using the ProjectComponentCreated event, which will not work as expected.

Please clarify.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer