bpmnServer / bpmn-server

BPMN 2.0 server for Node.js , providing modeling, execution, persistence and monitoring for Workflow. along with sample UI. Intended to be developers workbench for BPMN 2.0
MIT License
183 stars 47 forks source link

how to define target user and group of user in user task #114

Closed kstan79 closed 1 year ago

kstan79 commented 1 year ago

I'm try to use the webUI create service task however I cant figure up the way to define target user/group and seems no documentation explain how to do that, is it require camunda modeler?

ralphhanna commented 1 year ago

Documentation is coming soon.

kstan79 commented 1 year ago

after some research i notice that we can capture camunda assignee property by adding more type in moddle option. i'd add some for user task which is userful and had apply PR #117 .

Technically it seems can capture xml property in json, however I dont know how to save it into mongodb instance. Hope your side can implement it.

Modified moddle moddle

xml pasrsed successfully in definations loaded definations

if the assignee's properties can save into user task (in instance collection), then I think is enough for basic implementation of user task in production.

kstan79 commented 1 year ago

I'm manage to store bpmn user assignments into mongodb. Im using camunda:assignee setting, the bpmn editor obtain from vscode extension list.

method2c

the code i changed is src/engine/Item.ts: method2a

you can see below is the result obtain from dataStore.findItems() method2 we can search using below way

items = await this.bpmnServer.dataStore.findItems( { "items.assignments.assignee":'benjamin' })

Kindly advise whether above approach approve, or need another way to implement it, I will send another PR after you approve

I know there is some others requirement like below, but I wish to get greenlight from you whether column assignee can use for this purpose.

  1. convert string for assignee, candidateUsers, candidateGroups to array
  2. we may need to accept parameter from data like $#{data.createdby}.
ralphhanna commented 1 year ago

Thanks for all your help, but please consider my initial design as follows:

Access Rules

   [
    { Authorize: {group:'public', toPerform: 'Execute', on: 'start'}},
    { Designate: {user: currentUser, as : 'Owner'} , 
        at:{ element: 'start', event:'start'}},
    { Authorize: {actor:'Owner', toPerform: 'Execute', on: ['Buy','Drive'],}},
    { Assign: {group:'Cleaners', toPerform: 'Execute', on:'Clean',}},
    { Assign: {group:'Mechanics', toPerform: 'Execute', on:'Repair',}},
    { Notify: {actor:'Owner'   },
        at: {element: 'Drive', event:' start'}
        delayed: { min: 15 , cancelOn: 'end' }
   ]

Authorize is evaluated on request:

- isAuthorized(user,action,object): true/false
- getAccessList(user,action): list of objects
- getAuthorizedUsers(action,object): list of users

Designate is evaluated at specified Event; creates an [Involvement]()

Assign is evaluated at Start Event; creates an [Assignment]()

Notify is evaluated at specified Event; creates a [Notification]()

AccessRules Internal Design

ralphhanna commented 1 year ago

Here is a sample of the above: image

And in MongoDB under item: image

ralphhanna commented 1 year ago

Please give me your feedback on the above, I have mistakenly merge your changes in PR, not realizing the conflict between the two designs, I will work locally for the next few days till I becomes stable then will push.

Do you know how to incorporate the above design in the editor?

Thanks very much

ralphhanna commented 1 year ago

Assignment can also have a dueDate which can be a javascript function and priority

kstan79 commented 1 year ago

Yes I aware this document but I not understand how it work and link to it previously. IMHO I feel that leverage from camunda modeller is easier approach cause building editor seems painful and redesign the wheel.

However i respect your decision, I will try understand your initial design then get back to you afterward

kstan79 commented 1 year ago

after some reading, I feel that using json to define rules outside bpmn flow chart seems defeat the purpose of bpmn and add difficulty to process designe and approve. I guess you intension is:

  1. design separate json file allow developer to define suitable and flexible setting, and we no need to implement it in bpmn editor
  2. have better programming overview without navigate ever node, one by one.
  3. easier to program in overall, and easier to enhance too

IMHO,

  1. Developer need to maintain 2 files, and management level required to evaluate 2 documents, and need manual effort to ensure 2 document compatible to each others. It also added complexity to handle error. None developer can't implement it and contribute well
  2. as new comer the ideal is hard to understand, we will feel lose
  3. to make bpmn and json work perfectly, we need to build separate editor link up both and that is nightmare
  4. it is very custom design, i feel it will dead in one day. I recommend implementation compatible with camunda, activiti or etc. That is proven working well, and good for grow more community, since the bpmn diagram identical (i saw, we adobt camunda form, in this case we rather use back all their property.) 5.I can foresee this json rule will keep adding more complexity when function grows. Maintaining and documentation is hell, as open source philosophy we borrow something which is working and we focus more on somewhere which is missing.
ralphhanna commented 1 year ago

I fully agree with you regarding keeping everything in bpmn file and using the editor.

kstan79 commented 1 year ago

thanks, then shall we continue without using custom rule.json? You agree i use the assignee column for continue, and reserve authorization/notification for future, to bind with camunda modeler?

ralphhanna commented 1 year ago

Yes I agree, I am making all the required changes.

Thanks so much for your input

ralphhanna commented 1 year ago

See Release 1.4.0 User Assignment