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).
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.