本文整理汇总了Java中org.activiti.engine.repository.Deployment类的典型用法代码示例。如果您正苦于以下问题:Java Deployment类的具体用法?Java Deployment怎么用?Java Deployment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Deployment类属于org.activiti.engine.repository包,在下文中一共展示了Deployment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deploy
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 发布流程.
*/
@RequestMapping("console-deploy")
public String deploy(@RequestParam("xml") String xml) throws Exception {
RepositoryService repositoryService = processEngine
.getRepositoryService();
ByteArrayInputStream bais = new ByteArrayInputStream(
xml.getBytes("UTF-8"));
Deployment deployment = repositoryService.createDeployment()
.addInputStream("process.bpmn20.xml", bais).deploy();
List<ProcessDefinition> processDefinitions = repositoryService
.createProcessDefinitionQuery()
.deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : processDefinitions) {
processEngine.getManagementService().executeCommand(
new SyncProcessCmd(processDefinition.getId()));
}
return "redirect:/bpm/console-listProcessDefinitions.do";
}
示例2: execute
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
@Override
public Void execute(CommandContext commandContext) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("Deployment id is null");
}
DeploymentEntity deployment = commandContext
.getDeploymentEntityManager()
.findDeploymentById(deploymentId);
if (deployment == null) {
throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class);
}
// Update category
deployment.setCategory(category);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, deployment));
}
return null;
}
示例3: processUpload
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 上传发布流程定义.
*/
@RequestMapping("console-process-upload")
public String processUpload(@RequestParam("file") MultipartFile file,
RedirectAttributes redirectAttributes) throws Exception {
String tenantId = tenantHolder.getTenantId();
String fileName = file.getOriginalFilename();
Deployment deployment = processEngine.getRepositoryService()
.createDeployment()
.addInputStream(fileName, file.getInputStream())
.tenantId(tenantId).deploy();
List<ProcessDefinition> processDefinitions = processEngine
.getRepositoryService().createProcessDefinitionQuery()
.deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : processDefinitions) {
processEngine.getManagementService().executeCommand(
new SyncProcessCmd(processDefinition.getId()));
}
return "redirect:/bpm/console-listProcessDefinitions.do";
}
示例4: createProcessMetaData
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
private Map<String, Object> createProcessMetaData(Map<String, Object> processInstance) {
Map<String, Object> payload = new HashMap<String, Object>();
String processDefinitionId = (String) processInstance.get("processDefinitionId");
payload.put("procInstanceId", processInstance.get("processInstanceId"));
payload.put("procDefinitionId", processDefinitionId);
Map<String, Object> processMetaData = new HashMap<String, Object>();
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId)
.singleResult();
processMetaData.put("PROCESSDEFINITIONID", processDefinitionId);
processMetaData.put("PROCESSNAME", pd.getName());
processMetaData.put("PROCESSVERSION", pd.getVersion());
processMetaData.put("DEPLOYMENTID", pd.getDeploymentId());
Deployment dep = repositoryService.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();
processMetaData.put("APPNAME", dep.getName());
payload.put("processMetaData", processMetaData);
logger.debug("createProcessMetaData() return payload is: " + payload);
return payload;
}
示例5: deploy
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 根据Model部署流程
*/
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
try {
Model modelData = repositoryService.getModel(modelId);
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
byte[] bpmnBytes = null;
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
} catch (Exception e) {
logger.error("根据模型部署流程失败:modelId={}", modelId, e);
}
return "redirect:/workflow/model/list";
}
示例6: deploySingleProcess
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 部署单个流程定义
*
* @param resourceLoader {@link ResourceLoader}
* @param processKey 模块名称
* @throws IOException 找不到zip文件时
*/
private void deploySingleProcess(ResourceLoader resourceLoader, String processKey, String exportDir) throws IOException {
String classpathResourceUrl = "classpath:/deployments/" + processKey + ".bar";
logger.debug("read workflow from: {}", classpathResourceUrl);
Resource resource = resourceLoader.getResource(classpathResourceUrl);
InputStream inputStream = resource.getInputStream();
if (inputStream == null) {
logger.warn("ignore deploy workflow module: {}", classpathResourceUrl);
} else {
logger.debug("finded workflow module: {}, deploy it!", classpathResourceUrl);
ZipInputStream zis = new ZipInputStream(inputStream);
Deployment deployment = repositoryService.createDeployment().addZipInputStream(zis).deploy();
// export diagram
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : list) {
WorkflowUtils.exportDiagramToFile(repositoryService, processDefinition, exportDir);
}
}
}
示例7: deployModel
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
@PutMapping("{modelId}/deploy")
public ResponseMessage deployModel(@PathVariable String modelId) throws Exception {
Model modelData = repositoryService.getModel(modelId);
if (modelData == null) {
throw new NotFoundException("模型不存在!");
}
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment()
.name(modelData.getName())
.addString(processName, new String(bpmnBytes, "utf8"))
.deploy();
return ResponseMessage.ok(deployment).include(Deployment.class, "id", "name", "new");
}
示例8: queryDeploymentTest
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/***
* 查询 部署单元信息
*/
@Test
public void queryDeploymentTest() {
// ACT_RE_DEPLOYMENT
List<Deployment> deploymentList = repositoryService.createDeploymentQuery()
.deploymentId("111") // RES.ID_ =?
.deploymentCategory("222") // RES.CATEGORY_ =?
.deploymentCategoryNotEquals("333") // RES.CATEGORY_ <>? or RES.CATEGORY_ is null
.deploymentName("444") // RES.NAME_ =?
.deploymentNameLike("555") // RES.NAME_ like ?
.deploymentTenantId("666") // RES.TENANT_ID_ =?
.deploymentTenantIdLike("777") // RES.TENANT_ID_ like ?
.deploymentWithoutTenantId() // RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null
.list();
logger.info("###================================================ deploymentList, {}", deploymentList);
// 自定义SQL语句查询
deploymentList = repositoryService.createNativeDeploymentQuery()
.sql("select distinct RES.* from ACT_RE_DEPLOYMENT RES where RES.ID_ = #{id}")
.parameter("id", "123456")
.list();
logger.info("###================================================ deploymentList, {}", deploymentList);
}
示例9: deploymentQueryTest
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
@Test
public void deploymentQueryTest() {
List<Deployment> deploymentList = repositoryService.createDeploymentQuery()
.list();
for (Deployment deployment : deploymentList) {
String tmp = "\r\n" +
"#=======================================================================================================================#\r\n" +
"# Spring MVC Context 容器初始化完成之后的处理:\r\n" +
"#\t getId " + deployment.getId() + "\r\n" +
"#\t getName " + deployment.getName() + "\r\n" +
"#\t getDeploymentTime " + deployment.getDeploymentTime() + "\r\n" +
"#\t getCategory " + deployment.getCategory() + "\r\n" +
"#\t getTenantId " + deployment.getTenantId() + "\r\n" +
"#=======================================================================================================================#\r\n";
logger.info(tmp);
}
}
示例10: processList
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 流程定义列表
*/
public Page<Object[]> processList(Page<Object[]> page, String category) {
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.latestVersion().orderByProcessDefinitionKey().asc();
if (StringUtils.isNotEmpty(category)){
processDefinitionQuery.processDefinitionCategory(category);
}
page.setCount(processDefinitionQuery.count());
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults());
for (ProcessDefinition processDefinition : processDefinitionList) {
String deploymentId = processDefinition.getDeploymentId();
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
page.getList().add(new Object[]{processDefinition, deployment});
}
return page;
}
示例11: deploy
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 根据Model部署流程
*/
public String deploy(String id) {
String message = "";
try {
org.activiti.engine.repository.Model modelData = repositoryService.getModel(id);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
String processName = modelData.getName();
if (!StringUtils.endsWith(processName, ".bpmn20.xml")){
processName += ".bpmn20.xml";
}
// System.out.println("========="+processName+"============"+modelData.getName());
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
Deployment deployment = repositoryService.createDeployment().name(modelData.getName())
.addInputStream(processName, in).deploy();
// .addString(processName, new String(bpmnBytes)).deploy();
// 设置流程分类
List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
for (ProcessDefinition processDefinition : list) {
repositoryService.setProcessDefinitionCategory(processDefinition.getId(), modelData.getCategory());
message = "部署成功,流程ID=" + processDefinition.getId();
}
if (list.size() == 0){
message = "部署失败,没有流程。";
}
} catch (Exception e) {
throw new ActivitiException("设计模型图不正确,检查模型正确性,模型ID="+id, e);
}
return message;
}
示例12: processList
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 获取流程列表
* @param category 流程分类
*/
public Page<Object[]> processList(Page<Object[]> page, String category) {
/*
* 保存两个对象,一个是ProcessDefinition(流程定义),一个是Deployment(流程部署)
*/
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery()
.latestVersion().active().orderByProcessDefinitionKey().asc();
if (StringUtils.isNotEmpty(category)){
processDefinitionQuery.processDefinitionCategory(category);
}
page.setCount(processDefinitionQuery.count());
List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults());
for (ProcessDefinition processDefinition : processDefinitionList) {
String deploymentId = processDefinition.getDeploymentId();
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
page.getList().add(new Object[]{processDefinition, deployment});
}
return page;
}
示例13: execute
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
@Override
public InputStream execute(CommandContext commandContext) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("deploymentId is null");
}
if (resourceName == null) {
throw new ActivitiIllegalArgumentException("resourceName is null");
}
ResourceEntity resource = commandContext
.getResourceEntityManager()
.findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
if (resource == null) {
if (commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId) == null) {
throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class);
}
}
return new ByteArrayInputStream(resource.getBytes());
}
示例14: testZipStreamFromAbsoluteFilePath
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
@Test
public void testZipStreamFromAbsoluteFilePath() throws Exception {
// 从classpath读取资源并部署到引擎中
InputStream zipStream = getClass().getClassLoader().getResourceAsStream("chapter5/chapter5-deployment.bar");
repositoryService.createDeployment().addZipInputStream(new ZipInputStream(zipStream)).deploy();
// 统计已部署流程定义的数量
long count = repositoryService.createProcessDefinitionQuery().count();
assertEquals(2, count);
// 查询部署记录
Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
assertNotNull(deployment);
String deploymentId = deployment.getId();
// 验证4个资源文件是否都已成功部署
assertNotNull(repositoryService.getResourceAsStream(deploymentId, "candidateUserInUserTask.bpmn"));
assertNotNull(repositoryService.getResourceAsStream(deploymentId, "candidateUserInUserTask.png"));
assertNotNull(repositoryService.getResourceAsStream(deploymentId, "userAndGroupInUserTask.bpmn"));
assertNotNull(repositoryService.getResourceAsStream(deploymentId, "userAndGroupInUserTask.png"));
}
示例15: deploy
import org.activiti.engine.repository.Deployment; //导入依赖的package包/类
/**
* 根据Model部署流程
*/
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
try {
Model modelData = repositoryService.getModel(modelId);
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
byte[] bpmnBytes = null;
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String processName = modelData.getName() + ".bpmn20.xml";
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
} catch (Exception e) {
logger.error("根据模型部署流程失败:modelId={}", modelId, e);
}
return "redirect:/chapter20/model/list";
}