The WorkflowService service exhibits all available operations around Workflows.
Retrieving workflows
Retrieving all workflows
The examples below show how to retrieve all workflows present on the scope.
# <CORE_HOST>: FlowerDocs Core base URL
# <TOKEN>: authentication token
curl -X GET "<CORE_HOST>/rest/workflow" \
-H "token: <TOKEN>"
@Autowired
private WorkflowService wkfService;
public List<Workflow> getAllWorkflow() throws FunctionalException, TechnicalException
{
return wkfService.getAll();
}
Retrieving a defined list of workflows
The examples below show how to retrieve a list of workflows from their identifiers.
# <CORE_HOST>: FlowerDocs Core base URL
# <TOKEN>: authentication token
# <IDS>: list of workflow identifiers, separated by commas
curl -X GET "<CORE_HOST>/rest/workflow/<IDS>" \
-H "token: <TOKEN>"
@Autowired
private WorkflowService wkfService;
public List<Workflow> getWorkflow() throws FunctionalException, TechnicalException
{
List<Id> workflowIds = Lists.newArrayList(new Id("processId"));
workflowIds.add(new Id("processId"));
return wkfService.get(workflowIds);
}
Creating workflows
The examples below show how to create a workflow.
# <CORE_HOST>: FlowerDocs Core base URL
# <TOKEN>: authentication token
curl -X POST "<CORE_HOST>/rest/workflow" \
-H "token: <TOKEN>" \
-H "Content-Type: application/json" \
-d '[
{
"startTaskClass": "GEC_Step0_Creation",
"taskClasses": [
"GEC_Step1_Distribution",
"GEC_Step2_ATraiter",
"GEC_Step0_Creation"
],
"id": "GECTest"
}
]'
@Autowired
private WorkflowService wkfService;
public void createWorkflow() throws FunctionalException, TechnicalException
{
List<Id> taskClasses = new ArrayList<>();
taskClasses.add(new Id("GEC_Step0_Creation"));
taskClasses.add(new Id("GEC_Step1_Distribution"));
taskClasses.add(new Id("GEC_Step2_ATraiter"));
Workflow wkf = new Workflow();
wkf.setId(new Id("GecTest"));
wkf.setStartTaskClass(new Id("GEC_Step0_Creation"));
wkf.setTaskClasses(taskClasses);
List<Workflow> workflowList = new ArrayList<>();
workflowList.add(wkf);
wkfService.create(workflowList);
}
Updating workflows
The examples below show how to update a workflow.
# <CORE_HOST>: FlowerDocs Core base URL
# <TOKEN>: authentication token
# <IDS>: list of workflow identifiers to update, separated by commas
curl -X POST "<CORE_HOST>/rest/workflow/<IDS>" \
-H "token: <TOKEN>" \
-H "Content-Type: application/json" \
-d '[
{
"id": "GECTest",
"startTaskClass": "GEC_Step0_Creation",
"taskClasses": [
"GEC_Step1_Distribution",
"GEC_Step2_ATraiter",
"GEC_Step3_CourrierTraite",
"GEC_Step0_Creation"
]
}
]'
@Autowired
private WorkflowService wkfService;
public List<Workflow> updateWorkflow(Workflow wkf) throws FunctionalException, TechnicalException
{
wkf.getTaskClasses().add(new Id("GEC_Step3_CourrierTraite"));
List<Workflow> workflowList = new ArrayList<>();
workflowList.add(wkf);
return wkfService.update(workflowList);
}
When using the REST service, unset fields will be cleared: you must send the entire workflow, not just the fields to modify.
Deleting workflows
The examples below show how to delete a list of workflows.
# <CORE_HOST>: FlowerDocs Core base URL
# <TOKEN>: authentication token
# <IDS>: list of workflow identifiers to delete, separated by commas
curl -X DELETE "<CORE_HOST>/rest/workflow/<IDS>" \
-H "token: <TOKEN>"
@Autowired
private WorkflowService wkfService;
public void deleteWorkflow() throws FunctionalException, TechnicalException
{
List<Id> workflowIds = Lists.newArrayList(new Id("workflowId"));
wkfService.delete(workflowIds);
}
Deletion does not perform any checks: you must verify that there are no active instances before deleting a workflow.