Created
December 5, 2012 20:28
-
-
Save mwawrusch/4219208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getTasks: (req,res,next) => | |
return res.json {},401 unless req.user | |
### | |
Obtain one eligible task | |
### | |
@bonitaClient.queryRuntime.getOneTask "READY",req.user.username,null, (err,taskList) => | |
console.log "------1" | |
console.log JSON.stringify(taskList) | |
console.log "------1" | |
return next err if err | |
firstTaskUUID = taskList?.value | |
if firstTaskUUID | |
### | |
This is most likely an assign task. So we execute it and assign it to the current user | |
### | |
@bonitaClient.runtime.executeTask firstTaskUUID,true, req.user.username,opts = {},(err) => | |
console.log "------2" | |
console.log "EXECUTE TASK" | |
console.log "------2" | |
return next err if err | |
### | |
# Now we need to retrieve the process instance id. | |
### | |
@bonitaClient.queryRuntime.getTask firstTaskUUID,"admin",{}, (err,t) => | |
return next err if err | |
console.log "------3" | |
console.log JSON.stringify(t) | |
console.log "------3" | |
processInstanceId = t?.instanceUUID?.value | |
return res.json {} unless processInstanceId | |
### | |
Now we retrieve a list of possible task states | |
### | |
@bonitaClient.queryRuntime.getOneTaskByProcessInstanceUUIDAndActivityState processInstanceId,"READY",req.user.username,{}, (err,nextTask) => | |
console.log "------4" | |
console.log JSON.stringify(nextTask) | |
console.log "------4" | |
taskUUID = nextTask?.value | |
#"admin" | |
@bonitaClient.runtime.startTask taskUUID,true,req.user.username,{}, (err) => | |
console.log "------5" | |
console.log "EXECUTE" | |
console.log "------5" | |
result = @bonitaTransformer.toNextAction taskUUID,@servicesBonita.baseUrl | |
res.json result | |
else | |
res.json {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment