cpr.foundation.Workflow

A component that provides a way to process operations that are processed asynchronously in order.

Index

Methods
Name Return Type Description
err Workflow Specifies the function to handle the error.
exec Workflow Next, we run the function.
getReport { id: String, start: Number, end: Number, time: Number, success: Boolean }[] Returns a report of the workflow execution result.
send Workflow Next, execute Submission.

Constructor

Workflow(app, debug)
Parameters
name type description
app AppInstance
debugoptional Boolean defaultfalse

Methods

err(func)
Specifies the function to handle the error.
var workflow = new cpr.foundation.Workflow(app);
workflow.exec(...).send(...).error(function(error) {
  console.err(error);
});
Parameters
name type description
func (error: Object)=>Object Functions to handle errors
return Workflow
exec(func, id)
Next, we run the function.
var workflow = new cpr.foundation.Workflow(app);
workflow.exec(function() {
  ... CODE ...
});
Parameters
name type description
func (value: Object)=>Object Next execute function
idoptional String Name of the job to be executed (used for logging)
return Workflow
getReport()
Returns a report of the workflow execution result. Because the workflow execution may not end when the workflow call is completed. It is safe to call getReport through the workflow's exec function.
var workflow = new cpr.foundation.Workflow(app);
workflow.exec(...).send(...).exec(...).error(...)
.exec(function() {
  console.log(JSON.stringify(workflow.getReport()));
});
return { id: String, start: Number, end: Number, time: Number, success: Boolean }[]
send(submissionIds)
Next, execute Submission. If multiple IDs of Submission are passed, they are performed in parallel.
var workflow = new cpr.foundation.Workflow (app);
workflow.send ("submain", "subsub", ...);
 
Parameters
name type description
submissionIds String | cpr.protocols.Submission[] Submissions to be executed next
return Workflow