Set project Field Configuration Scheme programmatically

Charly [DEISER]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2013
Hi, We are trying to set some project schemes programmatically for an inside development. We are able to set some schemes like: notification scheme, issue security scheme, permission scheme, issue type screen scheme, etc. using WorkflowSchemeManager, PermissionSchemeManager, etc etc etc. But we don't know how to set the Field Configuration Scheme and the Issue Type scheme Any ideas on how can we set those 2 schemes to projects??? Regards

4 answers

1 accepted

3 votes
Answer accepted
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2013

try with this

FieldConfigurationScheme srcProjectFieldLayout = fieldLayoutManager.getFieldConfigurationScheme(srcProjectGV)
        if (srcProjectFieldLayout) {
            fieldLayoutManager.addSchemeAssociation(newprojectGV, srcProjectFieldLayout.getId())
        }

for your reference

https://bitbucket.org/jamieechlin/scriptrunner-public/src/f37f6c2d74aa/src/main/resources/com/onresolve/jira/groovy/canned/admin/CopyProject.groovy

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

@Iryna, if some thing helped you don't forget to voteup/accept as a answer,

it will help other users to choose right answer

Iryna Laryionava July 30, 2013

this doesn't copy IssueTypeScheme, but I found a solution in your reference.

Thanks =)

1 vote
Mirko Skramusky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2013

Hi all,

for the issue type scheme (based on AssociateIssueTypeSchemes):

FieldConfigScheme newIssueTypeScheme = fieldConfigSchemeManager.getFieldConfigScheme(issueTypeSchemeId);

        JiraContextTreeManager treeManager = ComponentManager
                .getComponentInstanceOfType(JiraContextTreeManager.class);

        // Set the contexts
        List<JiraContextNode> contexts = CustomFieldUtils.buildJiraIssueContexts(false,
                null,
                new Long[]{project.getId()},
                treeManager);

        ConfigurableField configurableField = newIssueTypeScheme.getField();
        fieldConfigSchemeManager.updateFieldConfigScheme(newIssueTypeScheme, contexts, configurableField);

        fieldManager.refresh();

and for the field layout configuration scheme:

FieldLayoutScheme fieldLayoutScheme = fieldLayoutManager.getMutableFieldLayoutScheme(fieldLayoutSchemeId);
      fieldLayoutManager.addSchemeAssociation(project, fieldLayoutScheme.getId());

Iryna Laryionava July 30, 2013

Thanks, you saved me.

But can you tell how you retrieve issueTypeSchemeId in your example ?

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

i ahve given link check there you will get entire code

0 votes
Iryna Laryionava July 29, 2013

Hi. Have you found any solution for setting Issue Type Scheme?

I actually tried to set it with IssueTypeSchemeManager but couldn't do it till now.

But Field Configuration you can set with this (here i was copying scheme from one project to another, but i think this will be the same with created scheme):

com.atlassian.jira.issue.fields.layout.field.FieldLayoutManager flmanager = ComponentManager.getInstance().getFieldLayoutManager();

org.ofbiz.core.entity.GenericValue projectFrom = pmanager.getProjectByKey(keyFrom);

org.ofbiz.core.entity.GenericValue projectTo = pmanager.getProjectByKey(keyTo);

com.atlassian.jira.issue.fields.layout.field.FieldConfigurationScheme fieldConfigurationScheme = flmanager	.getFieldConfigurationScheme(projectFrom);

Long fieldLayoutSchemeId = fieldConfigurationScheme.getId();

flmanager.addSchemeAssociation(projectTo, fieldLayoutSchemeId);

Charly [DEISER]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2013

Hi. i found a solution here https://bitbucket.org/topmanage/tm-project-templates/overview

hope this can help you

0 votes
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2013

IssueTypeScheme has a manager

e.g.

issueTypeSchemeManager.create("name of scheme", "description", issueTypdIds);

The issueTypeIds is a List of Strings whose id's are the IssueTypes to go in that scheme

Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2013

I'll checkout FieldConfigurationScheme as was looking at that recently myself

Suggest an answer

Log in or Sign up to answer