Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourBlue
titleFrom 1.7.7.1 for JIRA up to 9.16

Status
colourBlue
titleFrom 1.7.9 for JIRA 9.17+

Please find an example ScriptRunner code below which showcase usage of 3 managers LinkTypeManager, PriorityManager and ResolutionManager with the common following methods:

...

Code Block
languagepy
import java.lang.StringBuilder
import com.develocenter.jira.extschemes.manager.export.ResolutionManager
import com.develocenter.jira.extschemes.manager.export.PriorityManager
import com.develocenter.jira.extschemes.manager.export.LinkTypeManager
import com.develocenter.jira.extschemes.manager.export.IdName
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.atlassian.jira.project.Project 

@WithPlugin("com.develocenter.jira.links-scheme")
@PluginModule LinkTypeManager linkTypeManager
@PluginModule PriorityManager priorityManager
@PluginModule ResolutionManager resolutionManager

/* Find on /secure/admin/ViewIssueTypeLinkSchemes.jspa - hoover on(go to) name link and check schemeId in a link*/
Integer issueTypeLinkTypeSchemeId = new Integer(3);
/* Find on /secure/admin/ViewIssueTypeExtendedPrioritySchemes.jspa - hoover on(go to) name link and check schemeId in a link*/
Integer issueTypePrioritySchemeId = new Integer(3);
/* Find on /secure/admin/ViewIssueTypeResolutionSchemes.jspa - hoover on(go to) name link and check schemeId in a link*/
Integer issueTypeResolutionSchemeId = new Integer(3);
Long projectId = new Long(10301);
Long issueTypeId = new Long(10002);

StringBuilder stringBuilder = new StringBuilder();

/* Links Exampe*/
Collection<Project> projects = linkTypeManager.getProjects(issueTypeLinkTypeSchemeId);
stringBuilder.append("<b>Links Exampe</b><br>"+projects.toString()+"<br><br>");

linkTypeManager.addSchemeToProject(issueTypeLinkTypeSchemeId,projectId);
projects = linkTypeManager.getProjects(issueTypeLinkTypeSchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

Collection<IdName> allowedLinkTypes = linkTypeManager.getLinks(projectId, issueTypeId);
stringBuilder.append("Link Types:<br>");
allowedLinkTypes.stream().forEach(linkType -> {
    stringBuilder.append(linkType.getName()+" ("+linkType.getId()+")<br>")}
);
stringBuilder.append("<br>");

linkTypeManager.removeSchemesFromProject(projectId);
projects = linkTypeManager.getProjects(issueTypeLinkTypeSchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

/* Priority Example*/
projects = priorityManager.getProjects(issueTypePrioritySchemeId);
stringBuilder.append("<b>Priority Example</b><br>"+projects.toString()+"<br><br>");

priorityManager.addSchemeToProject(issueTypePrioritySchemeId,projectId);
projects = priorityManager.getProjects(issueTypePrioritySchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

Collection<IdName> allowedPrioritires = priorityManager.getPriorities(projectId, issueTypeId);
stringBuilder.append("Priorities:<br>");
allowedPrioritires.stream().forEach(priority -> {
    stringBuilder.append(priority.getName()+" ("+priority.getId()+")<br>")}
);
stringBuilder.append("<br>");

priorityManager.removeSchemesFromProject(projectId);
projects = priorityManager.getProjects(issueTypePrioritySchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

/* Resolution Example*/
projects = resolutionManager.getProjects(issueTypeResolutionSchemeId);
stringBuilder.append("<b>Resolution Example</b><br>"+projects.toString()+"<br><br>");

resolutionManager.addSchemeToProject(issueTypeResolutionSchemeId,projectId);
projects = resolutionManager.getProjects(issueTypeResolutionSchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

Collection<IdName> allowedResolutions = resolutionManager.getResolutions(projectId, issueTypeId);
stringBuilder.append("Resolution:<br>");
allowedResolutions.stream().forEach(resolution -> {
    stringBuilder.append(resolution.getName()+" ("+resolution.getId()+")<br>")}
);
stringBuilder.append("<br>");

resolutionManager.removeSchemesFromProject(projectId);
projects = resolutionManager.getProjects(issueTypeResolutionSchemeId);
stringBuilder.append(projects.toString()+"<br><br>");

Example Result

Code Block
languagenone
[Project: SC2, Project: SD]

[Project: SC2, Project: SD, Project: SC]

Link Types:
clones (null)
is blocked by (null)
is cloned by (null)

[Project: SC2, Project: SD]

Priority Example
[Project: KAN2]

[Project: KAN2, Project: SC]

Priorities:
High (2)
Low (4)
Blocker (10100)
Minor (10101)

[Project: KAN2]

Resolution Example
[Project: TEST]

[Project: TEST, Project: SC]

Resolution:
Done (10000)
Won't Fix (10001)
Rejected (10300)

[Project: TEST]