美文网首页工作流引擎
Flowable REST API入门

Flowable REST API入门

作者: 蜗牛DWade | 来源:发表于2019-04-13 21:25 被阅读56次

前序

本篇文章与上一篇相同的示例:部署流程定义,启动流程实例,获取任务列表和完成任务
这次使用Flowable API而不是Java API

设置REST应用程序

  1. 从flowable.org网站下载.zip文件时
  2. 需要一个servlet容器来运行WAR文件
    • INFO [main] org.apache.catalina.startup.Catalina.start服务器启动xyz ms表示服务器已准备好接收请求
    • 默认情况下使用内存中的H2数据库实例,这意味着数据将无法在服务器重新启动后继续存在
curl --user rest-admin:test http://localhost:8080/flowable-rest/service/management/engine
  • 默认情况下,所有REST调用都受基本身份验证保护(rest-admin:test)

部署流程定义

1.不是流程定义,使用REST API,可以通过将.bpmn20.xml文件(或多个流程定义的.zip文件)上传为multipart / formdata来完成

curl --user rest-admin:test -F "file=@holiday-request.bpmn20.xml" http://localhost:8080/flowable-rest/service/repository/deployments
image.png

2.验证是否正确部署了流程定义,可以请求流程定义列表

curl --user rest-admin:test http://localhost:8080/flowable-rest/service/repository/process-definitions
image.png

启动流程实例

curl --user rest-admin:test -H "Content-Type: application/json" -X POST -d '{ "processDefinitionKey":"holidayRequest", "variables": [ { "name":"employee", "value": "John Doe" }, { "name":"nrOfHolidays", "value": 7 }]}' http://localhost:8080/flowable-rest/service/runtime/process-instances
image.png

任务列表并完成任务

  1. 通过REST API完成任务查询
curl --user rest-admin:test -H "Content-Type: application/json" -X POST -d '{ "candidateGroup" : "managers" }' http://localhost:8080/flowable-rest/service/query/tasks

返回管理员组的所有任务列表


image.png
  1. 完成此类任务
curl --user rest-admin:test -H "Content-Type: application/json" -X POST -d '{ "action" : "complete", "variables" : [ { "name" : "approved", "value" : true} ]  }' http://localhost:8080/flowable-rest/service/runtime/tasks/25
image.png
  • 需要将类放在应用程序的类路径上,将其打包为JAR,并将其放在Tomcat 的webapps文件夹下的flowable -rest文件夹的WEB-INF / lib文件夹中

相关文章

网友评论

    本文标题:Flowable REST API入门

    本文链接:https://www.haomeiwen.com/subject/qevrwqtx.html