Adding new Issue Types to existing Scheme

Hey guys,

I’m struggling to adapt currently deployed Issue Type Schemes with a new Issue Type through java API (I don’t have access to Jira source :cry:)
This should be handled on plugin deploy, through a custom PluginEvent handler we already have in place.

Any ideas would be gold. Thanks.

String iconUrl = "/images/icons/issuetypes/exclamation.png";
String name = "MyIssueType";
String description = "A new issue type";    
IssueType issueType = issueTypeManager.createIssueType(name, description, iconUrl);

Hey David,

Thanks for the response, but not quite what I need - which is to add this new issue type to an existing Issue Type Scheme.

Something like…

    private void addIssueTypeToScheme(FieldConfigScheme issueTypeScheme, IssueType issueType) {
        List<Project> associatedProjects = issueTypeScheme.getAssociatedProjectObjects();
        if ((associatedProjects != null) && (!associatedProjects.isEmpty()))
        {
            Map<String, FieldConfig> fields = issueTypeScheme.getConfigs();
           // Add issueType to fields - but how???

            FieldConfigScheme newIssueTypeScheme = 
                    new FieldConfigScheme.Builder(issueTypeScheme)
                    .setName(issueTypeScheme.getName())
                    .setDescription(issueTypeScheme.getDescription())
                    .setConfigs(fields)
                    .toFieldConfigScheme();
        }
    }

Thanks…

List<String> issueTypeIds = ImmutableList.<String>builder()
        .addAll(getIssueTypeIds(issueTypeScheme))
        .add(myNewIssueType.getId())
        .build();

issueTypeSchemeManager.update(issueTypeScheme, issueTypeIds);
1 Like