jerryfiunam (61) [Avatar] Offline
#1
Hi again,

In the webapp I am developing, I will use my own Entity Management. I was looking into the Activiti's API finding out about how can I declare candidate starter users and groups and I have read that I can do that in two ways: by configutation directly inside the BPMN file with the activiti:candidateStarterUsers and activiti:candidateStarterGroups attributes of the process TAG, OR programatically using the API methods addCandidateStarterGroup and addCandidateStarterUser.

I have some doubts regarding this:

* If I declare groups or users directly in the BPMN file, deploy de BPMN, add a user or group programatically and then get the BPMN file back again, the resulting file will have that changes?

* What could be the pros and cons or advantages of each manner? I think for instance that if I want to change the starters directly using the BPMN file, this way implies a new version of the process rigth? while doing this programatically, make that changes over the same process version rigth?

* I have reviwed the API and there are ways to retreive the users or groups that are possible starters of a process definition:
identityLinks = repositoryService.getIdentityLinksForProcessDefinition("processDefinitionId");
or
List<User> authorizedUsers = identityService().createUserQuery().potentialStarter("processDefinitionId").list();
or
List<Group> authorizedGroups = identityService().createGroupQuery().potentialStarter("processDefinitionId").list();

But on the other hand, I dont find methods in order to know the List of process Definitions that can be initiated by the given user or by a given Group.

I found this method:

processDefinitions = repositoryService.createProcessDefinitionQuery().startableByUser("userxxx").list();

but is only for USERS but I dont find the method for a given group. I need this in order to list in the web app the list of process definitions that a given user of group are able to initialize. For instance, a user XXXX belongs to two groups: G01 y G02,
and

process1 is able to be initlized by XXXX
process2 is able to be initlized by G01
process3 is able to be initlized by G02


so I need to retreive the list of process definitions that can be initialized by XXXX, G01 y G02, that is to say, [prcoess1, process2, process3].

So I wonder if exists a method similar to repositoryService.createProcessDefinitionQuery().startableByUser("userxxx").list(); but using GROUP ID's.

Thanks smilie.
jerryfiunam (61) [Avatar] Offline
#2
Re: Candidate USERS and candidate GROUPS
Hi again smilie,

Regarding to my previous post, I also have another question. I know that is possible to declare candidate starters (Users or Groups) either in process definitions and userTasks declaring that in HARD CODE in the BPMN file, but what if the candidate users or groups in a task are defined in a dinamic basis, that is to say, the final user or candidate user or group of a Task or Process is know in runtime. So I wonder if is possible to declare that in the BPMN file using expressions or Spring beans, for intance:

we can declare
<userTask id="task" name="My Task" activiti:assignee="${myService.getEmployee()}"/>
or
<process id="potentialStarter" activiti:candidateStarterUsers="${myServices.getCandidates()}" >
or
<userTask id="theTask" name="my task" activiti:candidateUsers="${userVariable}" />

rahter than:
<userTask id="task" name="My Task" activiti:assignee="kermit"/>
or
<process id="potentialStarter" activiti:candidateStarterUsers="kermit,gonzo" >
or
<userTask id="theTask" name="my task" activiti:candidateUsers="fozzie" />

Is this possible?

Thanks
tijs.rademakers (494) [Avatar] Offline
#3
Re: Candidate USERS and candidate GROUPS
Hi,

Hope I answer your questions here below:

* If I declare groups or users directly in the BPMN file, deploy de BPMN, add a user or group programatically and then get the BPMN file back again, the resulting file will have that changes?

No the BPMN file will remain the same. In the Activiti database, the identity links are stored for each candidate user and group and those are used by the engine, not the BPMN source file.

* What could be the pros and cons or advantages of each manner? I think for instance that if I want to change the starters directly using the BPMN file, this way implies a new version of the process rigth? while doing this programatically, make that changes over the same process version rigth?

Doing it programmatically is easier to make it maintainable for a longer period of time. You could also use a combination by defining starters in the BPMN file directly and adding starters programatically over time when needed.

* so I need to retreive the list of process definitions that can be initialized by XXXX, G01 y G02, that is to say, [prcoess1, process2, process3].
So I wonder if exists a method similar to repositoryService.createProcessDefinitionQuery().startableByUser("userxxx").list(); but using GROUP ID's.

The usage of startableByUser was to be able to create a list of process definitions that a specific user can start. Your use case is a bit different and that's not support right now. It would be quite easy to add the functionality you are asking for if you want to search for a specific group id. Can you create a JIRA issue in the Activiti project?

* So I wonder if is possible to declare that in the BPMN file using expressions or Spring beans,

No it's not possible, because you would need to be able to query the process definitions and then you can only have static values. There's no process context yet, so expressions are not possible.

Best regards,

Tijs
jerryfiunam (61) [Avatar] Offline
#4
Re: Candidate USERS and candidate GROUPS
Thank you very much Tijs for your reply,

So just to clarify my doubt, if I have a user "USER1" and this user belongs to the group "GROUP1", and I have two process definitions with the following configuration:

<process id="PROCESS1" activiti:candidateStarterUsers="USER1">
and
<process id="PROCESS2" activiti:candidateStarterGroups="GROUP1">

After applying the method:

processDefinitions = repositoryService.createProcessDefinitionQuery().startableByUser("USER1").list();

Will the list "processDefinitions" have just one process definition (PROCESS1) or have both process definitions (PROCESS1 and PROCESS2) given that USER1 belongs to GROUP1?

Thanks for your support smilie.

Jerry
tijs.rademakers (494) [Avatar] Offline
#5
Re: Candidate USERS and candidate GROUPS
Hi Jerry,

It should return both process definitions, because user1 is a member of group1.

Best regards,

Tijs