cancel
Showing results for 
Search instead for 
Did you mean: 

Using roles and users of wepapp

rnauruhn
Champ in-the-making
Champ in-the-making
Dear all,

I am currently evaluating Activiti as to embed it as workflow engine in our existing application. Currently we have a hard coded workflow but with the number of companies which use it growing the need of customizable workflow(s) is also growing.

While reading the user guide and the example code I did not find a solution for one of my problems:

Our application ist hosted at our location and can be accessed by a number of companies with their users. It is used to manage orders. Each order has a variable number of participants and each participant has a defined role within the order (e.g.: client, provider, printer, …). Depending on the orders state and the users role the user has to perform tasks which can result in a change of the orders state. When using Activiti I have to model the currently hard coded process. One task in the process could be that one of the participants with the role "provider" has to upload a pdf for proofing. After this has been done the next task could be that one of the participants with the role "client" has to make an approval of the pdf. My problem is now that I don't know how to model this. If I understould it correctly I will put a user task in the process (e.g. for the upload pdf task) which needs a candidateGroup. This group can not have a fix name as there will be running several processes (one for each order) where the group members will be different for each order. What I need would be a group containg all users of my appliaction which are participant of the order and have a specific role (in case of the upload pdf task all users which are participant of the order and have the role "provider").

Next thing I don't know how to is to connect Activiti's group/user management with out application's user management.

Every hint is very welcome.

Regards
Ralph
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
When using candidateGroups, you can use an expression which delegates the logic to some custom java code, eg. candidateGroups="${myLogic.resolveOrderParticipants}". Would that approach work ?

Regarding linking the identity management: you should replace the IdentitySession with your own implementation. There are a few threads on the forum that described how to do this.

rnauruhn
Champ in-the-making
Champ in-the-making
When using candidateGroups, you can use an expression which delegates the logic to some custom java code, eg. candidateGroups="${myLogic.resolveOrderParticipants}". Would that approach work ?
Is myLogic one of my implemented logics? Is there any example available for this?

Regarding linking the identity management: you should replace the IdentitySession with your own implementation. There are a few threads on the forum that described how to do this.
If found a thread that helped me to create my own implementation. The users are no problem. But as we do not use groups but roles which result in a list of users only when they are in the context of an order this is a problem. The IdentitySession-Interface has some group related methods. As I don't know anything about the order when those methods are executed I am not sure how to implement this.

What I could do is to persist for each order the id of the ProcessInstance when the order is created (the process is also started at this time). If I could get the id of the process in the IdentitySession's methods I could also get my order. But this seems to be problem. Or could I solve this via "Context.getExecutionContext().getProcessInstance()"?

jbarrez
Star Contributor
Star Contributor
Is myLogic one of my implemented logics? Is there any example available for this?

See http://activiti.org/userguide/index.html#apiExpressions

if found a thread that helped me to create my own implementation. The users are no problem. But as we do not use groups but roles which result in a list of users only when they are in the context of an order this is a problem. The IdentitySession-Interface has some group related methods. As I don't know anything about the order when those methods are executed I am not sure how to implement this.

Just throw an UnsupportedOperationException in those methods, you will see quickly which ones are used.

What I could do is to persist for each order the id of the ProcessInstance when the order is created (the process is also started at this time). If I could get the id of the process in the IdentitySession's methods I could also get my order. But this seems to be problem. Or could I solve this via "Context.getExecutionContext().getProcessInstance()"?

I don't get this, what exactly do you need? When you start the Process Instance, you can easily get the id back.

rnauruhn
Champ in-the-making
Champ in-the-making
Just throw an UnsupportedOperationException in those methods, you will see quickly which ones are used.
To find the methods that are used is not the problem but to make to correct implementation is one. Let us take a look at "IdentitySession.findUsersByGroupId". This has to return the list of users for a specified group. As I mentioned above we don't have groups but roles. A role results in users only if it the context (the order) is available. That means that a lot of users have e.g. the role "client" but only when creating a new order (and so starting a new process for this order) alle participants of this order with the role "client" are the correct users for the requested role.

Maybe I have a misunderstanding and "IdentitySession.findUsersByGroupId" must not be seen in a context of a running process and is correct to return ALL user with the role "client" assigned. Maybe I have to implement my own logic to resolve roles in the order's context. My thinking was about a scenario where a task has a candidate group (which would be a candidate role for me) and the engine has to perform an action for all members by itself (e.g. sending an email). How shall the engine get the correct list of users as my implemtation of "IdentitySession.findUsersByGroupId" returns alls users with the role assigned (which is wrong).

I don't get this, what exactly do you need? When you start the Process Instance, you can easily get the id back.
This was my attempt to solve the problem above (to get the context which is an order) in the implementing methods of IdentitySession which are related to groups.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Maybe I have to implement my own logic to resolve roles in the order's context.

This is the case and in the candidateGroups="${myLogic.resolveOrderParticipants}" you can also pass parameters like process variables or whatever so you are kind of in the 'context' then.