I have an Activiti project for some business process.
The problem is about migration. An existing process has some unfinished tasks. I want to modify the existing process by adding a new step.
Now, when I create a new task, this new task will be processed according to the updated process. And unfinished tasks will be processed according to the old process.
Let's take the following example: https://spring.io/blog/2015/03/08/getting-started-with-activiti-and-spring-boot
In this example, consider the following line:
taskVariables.put("telephoneInterviewOutcome", true);
Assume that, I have some business logic code where I check the value of this variable such as:
if (taskVariables.get("telephoneInterviewOutcome") == true) {...}
Now assume that, I want to modify this variable from Boolean to Enum. Now, I need to update my business logic as well:
if (taskVariables.get("telephoneInterviewOutcome") == SOMEENUM) {...}
Now, my business logic code needs to be branched according to the version of the process of the task at hand. If the task belongs to version 1 of the process, then I will use the first statement, else the second one like that:
if (getProcessVersion(task) == 1) {
if (taskVariables.get("telephoneInterviewOutcome") == true) {...}
} else {
if (taskVariables.get("telephoneInterviewOutcome") == SOMEENUM) {...}
}
The problem with this approach is that the business logic code will grow as the processes are updated. This will cause lots of bugs during production.
Is there any other solution to this problem? How can I solve this problem without changing business logic code?