This commit is contained in:
wangwei
2017-09-04 17:02:58 +08:00
4 changed files with 220 additions and 18 deletions

View File

@@ -21,6 +21,7 @@ import org.hswebframework.web.NotFoundException;
import org.hswebframework.web.commons.entity.PagerResult;
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
import org.hswebframework.web.controller.message.ResponseMessage;
import org.hswebframework.web.workflow.flowable.entity.SimpleProcessDefinition;
import org.hswebframework.web.workflow.flowable.service.BpmActivityService;
import org.hswebframework.web.workflow.flowable.service.BpmProcessService;
import org.hswebframework.web.workflow.flowable.service.BpmTaskService;
@@ -42,6 +43,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.zip.ZipInputStream;
/**
@@ -101,9 +103,17 @@ public class FlowableDeploymentController extends FlowableAbstract {
});
int total = (int) processDefinitionQuery.count();
param.rePaging(total);
List<ProcessDefinition> models = processDefinitionQuery.listPage(param.getPageIndex(), param.getPageSize() * (param.getPageIndex() + 1));
return ResponseMessage.ok(new PagerResult<>(total, models))
.exclude(ProcessDefinitionEntity.class, "identityLinks");
if (total == 0) {
return ResponseMessage.ok(PagerResult.empty());
}
List<ProcessDefinition> models = processDefinitionQuery
.listPage(param.getPageIndex(), param.getPageSize() * (param.getPageIndex() + 1))
.stream()
.map(SimpleProcessDefinition::new)
.collect(Collectors.toList());
return ResponseMessage.ok(new PagerResult<>(total, models));
}
/**
@@ -115,22 +125,22 @@ public class FlowableDeploymentController extends FlowableAbstract {
// 获取上传的文件名
String fileName = file.getOriginalFilename();
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 得到输入流(字节流)对象
InputStream fileInputStream = file.getInputStream();
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// 文件的扩展名
String extension = FilenameUtils.getExtension(fileName);
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
// zip或者bar类型的文件用ZipInputStream方式部署
DeploymentBuilder deployment = repositoryService.createDeployment();
if (extension.equals("zip") || extension.equals("bar")) {
ZipInputStream zip = new ZipInputStream(fileInputStream);
deployment.addZipInputStream(zip);
} else {
// 其他类型的文件直接部署
deployment.addInputStream(fileName, fileInputStream);
}
deployment.deploy();
return ResponseMessage.ok();
}

View File

@@ -0,0 +1,175 @@
package org.hswebframework.web.workflow.flowable.entity;
import org.activiti.engine.repository.ProcessDefinition;
/**
* TODO 完成注释
*
* @author zhouhao
*/
public class SimpleProcessDefinition implements ProcessDefinition {
private String id;
private String category;
private String name;
private String key;
private String description;
private int version;
private String resourceName;
private String deploymentId;
private String diagramResourceName;
private boolean suspended;
private boolean hasStartFormKey;
private boolean hasGraphicalNotation;
private String tenantId;
public SimpleProcessDefinition() {
}
public SimpleProcessDefinition(ProcessDefinition definition) {
id = definition.getId();
category = definition.getCategory();
name = definition.getName();
key = definition.getKey();
description = definition.getDescription();
version = definition.getVersion();
resourceName = definition.getResourceName();
deploymentId = definition.getDeploymentId();
diagramResourceName = definition.getResourceName();
suspended = definition.isSuspended();
hasGraphicalNotation = definition.hasGraphicalNotation();
hasStartFormKey = definition.hasStartFormKey();
tenantId = definition.getTenantId();
}
public void setSuspended(boolean suspended) {
this.suspended = suspended;
}
@Override
public boolean isSuspended() {
return suspended;
}
@Override
public boolean hasGraphicalNotation() {
return hasGraphicalNotation;
}
@Override
public boolean hasStartFormKey() {
return hasStartFormKey;
}
@Override
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
@Override
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
@Override
public String getResourceName() {
return resourceName;
}
public void setResourceName(String resourceName) {
this.resourceName = resourceName;
}
@Override
public String getDeploymentId() {
return deploymentId;
}
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
@Override
public String getDiagramResourceName() {
return diagramResourceName;
}
public void setDiagramResourceName(String diagramResourceName) {
this.diagramResourceName = diagramResourceName;
}
public boolean isHasStartFormKey() {
return hasStartFormKey;
}
public void setHasStartFormKey(boolean hasStartFormKey) {
this.hasStartFormKey = hasStartFormKey;
}
public boolean isHasGraphicalNotation() {
return hasGraphicalNotation;
}
public void setHasGraphicalNotation(boolean hasGraphicalNotation) {
this.hasGraphicalNotation = hasGraphicalNotation;
}
@Override
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
}

View File

@@ -0,0 +1,17 @@
package org.hswebframework.web.workflow.flowable;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* TODO 完成注释
*
* @author zhouhao
*/
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}

View File

@@ -3,7 +3,7 @@ spring:
auto: true
proxy-target-class: true
datasource:
url : jdbc:h2:file:target/workflow-test
url : jdbc:h2:file:./target/workflow-test
username : sa
password :
type: com.alibaba.druid.pool.DruidDataSource