Change Workflow Definition

cancel
Showing results for 
Search instead for 
Did you mean: 
moakra
Member II

Change Workflow Definition

Hi,

I am currently trying to find a clean solution to change the strategy of the version counting. In fact, If you deploy the same workflow twice, Activiti will add +1 to the current version. I would like to change this behavior to the workflow definition and the process instance definition.

I saw that we can change SetProcessDefinitionVersionCmd changes the process definition version of an existing process instance. I am looking for the equivalent to change the workflow definition during the deployment.

Is there a possibility to solve this issue?

Thank you in advance,

Med

1 Reply
gdharley
Intermediate

Re: Change Workflow Definition

Ok, a really interesting question.

So I haven't actually done this myself, but I believe you can add your own custom Deployer in the Process Engine Configuration (setCustomPreDeployers) based on a method I found therein.

So on searching the forums I then found the following topic which confirms my belief:

Setting deployers on the ProcessEngineConfiguration 

That said, if you set a custom pre deployer, it can be used to override the default deployer for say a BPMN file:

protected Collection< ? extends Deployer> getDefaultDeployers() {
List<Deployer> defaultDeployers = new ArrayList<Deployer>();

if (bpmnDeployer == null) {
bpmnDeployer = new BpmnDeployer();
}

Ok, so now that we know all we have to do is override the default BPMN Deployer you should implement a class that extends org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.

You would override the deploy() method and modify the processDefinitionVersion logic (default is below):

if (latestProcessDefinition != null) {
processDefinitionVersion = latestProcessDefinition.getVersion() + 1;
} else {
processDefinitionVersion = 1;
}

processDefinition.setVersion(processDefinitionVersion);

Like I said, this is all theory as I haven't actually implemented this, but it looks pretty straight forward.

Would love to see what you come up with.

Greg