I have been learning how to create project-blueprint module and playing around with more advanced configurations like adding custom fields. I would also like to add postfunctions and conditions to the workflows - now in the basic template tutorial says under the part about AddProjectHook.java “The
configure() function can be used for a wide variety of configuration options. For example, you can use this to create Workflow Post Functions, Resolutions, and more”, but it doesn’t specify on how exactly do you actually create the postfunctions and transitions.
I have searched around and discovered the WorkflowTransitionService class, which seems to be able to do exactly what I need since it has methods addConditionToWorkflow and addPostFunctionToWorkflow. I tried to use it this way:
WorkflowTransitionService workflowTransitionService = ComponentAccessor.getComponent(WorkflowTransitionService.class); ConditionDescriptor conditionDescriptor = DescriptorFactory.getFactory().createConditionDescriptor(); conditionDescriptor.setType("class"); final Map conditionArgs = conditionDescriptor.getArgs(); conditionArgs.put("class.name", "cz.principal.jira.TestCondition"); workflowTransitionService.addConditionToWorkflow("In Progress", conditionDescriptor, basicWorkflow);
There are no errors returned in the ErrorCollection from the method, or exceptions of any kind, yet there is no condition attached to the transition when the project is created. I have discovered this question which is exactly the same problem as I am having, sadly unanswered.