cancel
Showing results for 
Search instead for 
Did you mean: 

Add or modify candidateGroup on processDefinition task

aeross
Champ in-the-making
Champ in-the-making
Hi,
after many search, i will ask to activiti forum for my question.

I want to define dynamically candidateGroup, task by task, for my ProcessDefinition.

When i go to
ProcessEngine.getRepositoryService().getBpmnModel(processDefinitionId).getMainProcess().findFlowElementsOfType(UserTask.class)

i see candidateGroups but can't modify it. or i don't understood.

When i use
ProcessEngine.getTaskService().addGroupIdentityLink(taskId, groupId, IdentityLinkType.CANDIDATE)

it work but i want to define once for all task of my ProcessDefinition .


The best way to explain what i want is to compare with existing :
I want add candidateGroup to a taks of my processDefinition like the method addCandidateStarterGroup that is in RepositoryService.


It existing a way to do that?

Thanks
9 REPLIES 9

trademak
Star Contributor
Star Contributor
Hi,

You can use the BpmnModel to change the candidate groups of a task for example and then transform it to XML and deploy the process definition again. But is your requirement to have different values for every process instance you start? Or do you want to change the whole process definition? If it's the latter changing the BpmnModel and deploying the XML again makes the most sense.

Best regards,

aeross
Champ in-the-making
Champ in-the-making
Hi Tijs,
You're right! I want to change BpmnModel.

Another thing you need to know, ideploy Bpmn xml file into zip file with jar file that is connected to.

Is that a problem?
Secondly, i found in RepositoryService methods to extract and read bpmn process, but don't found methods to import or overwrite the old version? Can you help me for that?


Thanks for your response

jbarrez
Star Contributor
Star Contributor
Shouldn't be a problem. The process is taking out of the zip file before being deployed.

For your second question: the DeploymentBuilder accepts a BpmnModel as input.

aeross
Champ in-the-making
Champ in-the-making
Thanks Joram for your response.

I have tested your solution, i modified and redeployed my BpmnModel like this :
<code>
ProcessEngine.getRepositoryService().createDeployment().name("bpmn.processes.zip").addBpmnModel("process.bpmn20.xml", model).addInputStream(""ProcessGUI.jar", inputStream).deploy();
</code>

It work, but it create a new deployment and i have to clean(delete) the older version that is deleting all running tasks and process.

Thanks for your responses, it's very interesting, but i need to find another solution.

trademak
Star Contributor
Star Contributor
Why would you have to delete the older version? When you deploy a new version every new instance will automatically use that new version.

Best regards,

aeross
Champ in-the-making
Champ in-the-making
Hi Tijs,

I would have to delete the older version because it isn't correspond to the new process version deployment.

Imagine you have 100 more tasks running and you need to change candidate groups that leads to deploy a new process version.
I can't delete tasks running and can't use old and new process version together.

I found a basic solution, that bothers me a little but for the moment it's the only who correspond to what i need, that is to create a database table . Table description below :
<code>
ACT_PROC_TASK_GROUP
PROC_DEF_ID_ VARCHAR2(64 CHAR)
TASK_DEF_KEY_ VARCHAR2(255 CHAR)
GROUP_ID_ VARCHAR2(64 CHAR)
</code>
It works this way:
I record for each task(taskDefinitionKey) in my process (processDefinitionId) the candidate groups(groupId)


Thanks for your help

trademak
Star Contributor
Star Contributor
If candidate users and groups are changing a lot and you want these changes to be reflected in running tasks as well, this isn't a bad solution. You can also use the addCandidateGroup and deleteCandidateGroup methods for individual tasks.

Best regards,

aeross
Champ in-the-making
Champ in-the-making
Thank Tijs for your response.

For the complete explanation of what i do :

First case, processes deployment :
1. I deploy some processes.
2. I configure deployed processses, that means for each process I defined process starter groups and for each task I defined candidate groups.
3. These configurations are recorded into the table i created (ACT_PROC_TASK_GROUP) that link processDefinitionId, taskDefinitionKey and groupId.


Second case, process setup change :
1. I modify one process candidate groups for some tasks.
2. Configurations are recorded into the table i created (ACT_PROC_TASK_GROUP) that link processDefinitionId, taskDefinitionKey and groupId.
3. I modify with addCandidateGroup and deleteCandidateGroup the existing tasks with the new configured values.

Best regards.

trademak
Star Contributor
Star Contributor
Ok, yes that makes sense