Workflows created with java api are still inactive despite use in project


I use the java api to import workflows from XML during plugin installation. Afterwards I create a workflowscheme and assign the workflows to this scheme. I create my a project using a project-template and in the configure() method of the AddProjectHook I configure the previously loaded and created inactive workflows (e.g. adding postfunctions). Everything works fine, but I recognized that my workflows are still shown as inactive in the GUI even when they are assigned to a workflowscheme which is used in my project.

The configure part works like this:

  • I get the workflow to configure
  • I create a draft of the workflow with workflowManager.createDraftWorkflow()
  • I add a postfunction to the workflow
  • I save the updated draft with workflowManager.saveWorkflowWithoutAudit()

I expected the workflow to be saved into an active version in this case.

Does anybody had the same experience or does somebody know what is going on?

I just recognized that I do not create a draft of the workflow because at this point the workflow is not active (no project or workflowscheme yet) and I work on the “normal” workflow instead. But should not change anything. I still expect the workflow to be active after being put into a scheme and the scheme is used in a project.

Maybe the problem is related to the workflow scheme? I assign it like this:

public void assignProjectToWorkFlowScheme(Project project, AssignableWorkflowScheme newScheme) {
        log.debug("project: " + project.getKey());
        log.debug("newScheme: " + newScheme.getName());
        log.debug("assigning workflowscheme for " + project.getKey() + " to " + newScheme.getName());
        Map<String, String> issueWorkflowMap = newScheme.getMappings();
        Scheme scheme = workflowSchemeManager.getSchemeObject(newScheme.getId());
        workflowSchemeManager.addSchemeToProject(project, scheme);

Maybe @sfbehnke has an idea? :slight_smile: