Have you ever wondered, why there are few post functions available in the Jira platform while transitioning between statuses of an issue workflow? Of course, I felt while I am working with Jira platform.
Today we will look how we can add post function which can be listed in transition states of jira workflow. Fyi, Jira platform uses Open Symphony (OS) workflow api in it's architecture which will take care of issue transition states. To know more about OS workflow API please visit here
Following are the various steps required to implement to create a post function.
1. Create a class "ModifyCustomFieldPF" which incorporates the implementation of business logic. Whenever this post-function is called, execute behavior will be executed by the Jira platform and it's implementation class "ModifyCustomFieldPFImpl" as shown below.
2. Create a velocity template(ModifyCustomFieldPF.vm) file
3. Entries in the atlassian-plugin.xml file.
4. Now build your plug-in and deploy the artifact and restart the application server.
Go to any workflow listed in Jira platform and check "Ensures that CustomFieldValue will be modified....." will be visible in the post function tab of the selected workflow transition.
Today we will look how we can add post function which can be listed in transition states of jira workflow. Fyi, Jira platform uses Open Symphony (OS) workflow api in it's architecture which will take care of issue transition states. To know more about OS workflow API please visit here
Following are the various steps required to implement to create a post function.
1. Create a class "ModifyCustomFieldPF" which incorporates the implementation of business logic. Whenever this post-function is called, execute behavior will be executed by the Jira platform and it's implementation class "ModifyCustomFieldPFImpl" as shown below.
package com.company.application.module.postfunction;
import java.util.Map;
import com.atlassian.jira.issue.MutableIssue;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.FunctionProvider;
import com.opensymphony.workflow.WorkflowException;
import com.opensymphony.workflow.FunctionProvider;
import com.opensymphony.workflow.WorkflowException;
public class ModifyCustomFieldPF implements FunctionProvider {
public static final String ISSUE = "issue";
public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException {
MutableIssue mutableIssue = (MutableIssue) transientVars.get(ISSUE);
// here implement the required business logic
}
}
package com.company.application.module.postfunction;
import java.util.HashMap;
import java.util.Map;
import com.atlassian.jira.plugin.workflow.AbstractWorkflowPluginFactory;
import com.atlassian.jira.plugin.workflow.WorkflowPluginConditionFactory;
import com.opensymphony.workflow.loader.AbstractDescriptor;
public class ModifyCustomFieldPFImpl extends AbstractWorkflowPluginFactory implements WorkflowPluginConditionFactory
{
public ModifyCustomFieldPFImpl() {
super();
// TODO Auto-generated constructor stub
}
protected void getVelocityParamsForEdit(Map arg0, AbstractDescriptor arg1) {
// TODO Auto-generated method stub
}
protected void getVelocityParamsForInput(Map arg0) {
// TODO Auto-generated method stub
}
protected void getVelocityParamsForView(Map arg0, AbstractDescriptor arg1) {
// TODO Auto-generated method stub
}
public Map getDescriptorParams(Map arg0) {
// TODO Auto-generated method stub
return new HashMap();
}
}
import java.util.HashMap;
import java.util.Map;
import com.atlassian.jira.plugin.workflow.AbstractWorkflowPluginFactory;
import com.atlassian.jira.plugin.workflow.WorkflowPluginConditionFactory;
import com.opensymphony.workflow.loader.AbstractDescriptor;
public class ModifyCustomFieldPFImpl extends AbstractWorkflowPluginFactory implements WorkflowPluginConditionFactory
{
public ModifyCustomFieldPFImpl() {
super();
// TODO Auto-generated constructor stub
}
protected void getVelocityParamsForEdit(Map arg0, AbstractDescriptor arg1) {
// TODO Auto-generated method stub
}
protected void getVelocityParamsForInput(Map arg0) {
// TODO Auto-generated method stub
}
protected void getVelocityParamsForView(Map arg0, AbstractDescriptor arg1) {
// TODO Auto-generated method stub
}
public Map getDescriptorParams(Map arg0) {
// TODO Auto-generated method stub
return new HashMap();
}
}
2. Create a velocity template(ModifyCustomFieldPF.vm) file
Ensures that CustomFieldValue will be modified......
3. Entries in the atlassian-plugin.xml file.
<workflow-function key="ModifyCustomFieldPF" name="ModifyCustomFieldPF" class="com.company.application.module.postfunction.ModifyCustomFieldPFImpl">
<description>Description of your post function plug-in.</description>
<function-class>"com.company.application.module.postfunction.ModifyCustomFieldPF</function-class>
<orderable>true</orderable>
<unique>true</unique>
<deletable>true</deletable>
<editable>true</editable>
<resource type="velocity" name="view" location="templates/ModifyCustomFieldPF.vm"/>
</workflow-function>
<description>Description of your post function plug-in.</description>
<function-class>"com.company.application.module.postfunction.ModifyCustomFieldPF</function-class>
<orderable>true</orderable>
<unique>true</unique>
<deletable>true</deletable>
<editable>true</editable>
<resource type="velocity" name="view" location="templates/ModifyCustomFieldPF.vm"/>
</workflow-function>
4. Now build your plug-in and deploy the artifact and restart the application server.
Go to any workflow listed in Jira platform and check "Ensures that CustomFieldValue will be modified....." will be visible in the post function tab of the selected workflow transition.