Skip to content

Instantly share code, notes, and snippets.

@ItaloQualisoni
Last active July 22, 2020 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ItaloQualisoni/1c9791eb08f4e112a6a8b09015ce208e to your computer and use it in GitHub Desktop.
Save ItaloQualisoni/1c9791eb08f4e112a6a8b09015ce208e to your computer and use it in GitHub Desktop.
package helper;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.bc.project.component.ProjectComponentManager
class ComponentHelper {
ProjectManager projectManager = ComponentAccessor.getProjectManager()
ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager()
static ComponentHelper componentHelper = null;
ComponentHelper(){
}
Collection<ProjectComponent> getComponents(String projectKey,String query){
assert projectKey != null
def projectSource = projectManager.getProjectObjByKeyIgnoreCase(projectKey)
assert projectSource != null
def componentList = projectComponentManager.findAllForProject(projectSource.getId())
if(query!=null){
componentList = componentList.findAll {it->it.getName().toLowerCase().contains(query.toLowerCase())}
}
return componentList
}
static ComponentHelper getComponentHelper(){
if(componentHelper == null){
componentHelper = new ComponentHelper();
}
return componentHelper;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment