本文整理汇总了Java中org.activiti.bpmn.model.BpmnModel.addProcess方法的典型用法代码示例。如果您正苦于以下问题:Java BpmnModel.addProcess方法的具体用法?Java BpmnModel.addProcess怎么用?Java BpmnModel.addProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.bpmn.model.BpmnModel
的用法示例。
在下文中一共展示了BpmnModel.addProcess方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDynamicDeploy
import org.activiti.bpmn.model.BpmnModel; //导入方法依赖的package包/类
@Test
public void testDynamicDeploy() throws Exception {
// 1. Build up the model from scratch
BpmnModel model = new BpmnModel();
Process process = new Process();
model.addProcess(process);
process.setId("my-process");
process.addFlowElement(createStartEvent());
process.addFlowElement(createUserTask("task1", "First task", "fred"));
process.addFlowElement(createUserTask("task2", "Second task", "john"));
process.addFlowElement(createEndEvent());
process.addFlowElement(createSequenceFlow("start", "task1"));
process.addFlowElement(createSequenceFlow("task1", "task2"));
process.addFlowElement(createSequenceFlow("task2", "end"));
// 2. Generate graphical information
new BpmnAutoLayout(model).execute();
// 3. Deploy the process to the engine
Deployment deployment = repositoryService.createDeployment().addBpmnModel("dynamic-model.bpmn", model).name("Dynamic process deployment").deploy();
// 4. Start a process instance
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process");
// 5. Check if task is available
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
Assert.assertEquals(1, tasks.size());
Assert.assertEquals("First task", tasks.get(0).getName());
Assert.assertEquals("fred", tasks.get(0).getAssignee());
// 6. Save process diagram to a file
InputStream processDiagram = repositoryService.getProcessDiagram(processInstance.getProcessDefinitionId());
FileUtils.copyInputStreamToFile(processDiagram, new File("target/diagram.png"));
// 7. Save resulting BPMN xml to a file
InputStream processBpmn = repositoryService.getResourceAsStream(deployment.getId(), "dynamic-model.bpmn");
FileUtils.copyInputStreamToFile(processBpmn, new File("target/process.bpmn20.xml"));
}
示例2: createProcess
import org.activiti.bpmn.model.BpmnModel; //导入方法依赖的package包/类
public String createProcess(TechnicalDeploymentInstance tdi, ActivationStepEnum processType) {
String processName = "activate-" + tdi.getName() + "-" + processType.getName() + "-" + System.currentTimeMillis();
Process process;
try {
process = activitiProcessFactory.generateProcessFromTDI(processType, tdi);
} catch (JAXBException | IOException e) {
throw new TechnicalException("unable to generate process from TDI", e);
}
BpmnModel model = new BpmnModel();
model.addProcess(process);
processEngine.getRepositoryService().createDeployment().addBpmnModel(processName +".bpmn", model).name("Activate " + tdi.getName()).deploy();
return process.getId();
}
示例3: buildModel
import org.activiti.bpmn.model.BpmnModel; //导入方法依赖的package包/类
private BpmnModel buildModel() {
BpmnModel bpmnModel = new BpmnModel();
// Process
Process process = new Process();
process.setId("testModel");
ExtensionAttribute initDate = new ExtensionAttribute("initDate");
initDate.setNamespace("http://activiti.org/bpmn");
initDate.setValue("${initDate}");
process.addAttribute(initDate);
bpmnModel.addProcess(process);
// StartEvent
StartEvent startEvent = new StartEvent();
startEvent.setId("startEvent");
FormProperty startDate = new FormProperty();
startDate.setId("startDate");
startDate.setType("date");
startEvent.getFormProperties().add(startDate);
ExtensionElement extElement = new ExtensionElement();
extElement.setName("extentProperty");
extElement.setNamespace("http://activiti.org/bpmn");
ExtensionAttribute nameAttr = new ExtensionAttribute("id");
nameAttr.setValue("status");
ExtensionAttribute valueAttr = new ExtensionAttribute("value");
valueAttr.setValue("0");
extElement.addAttribute(nameAttr);
extElement.addAttribute(valueAttr);
startEvent.addExtensionElement(extElement);
process.addFlowElement(startEvent);
// UserTask
UserTask userTask = new UserTask();
userTask.setId("userTask");
process.addFlowElement(userTask);
// EndEvent
EndEvent endEvent = new EndEvent();
endEvent.setId("endEvent");
process.addFlowElement(endEvent);
GraphicInfo giStartEvent = new GraphicInfo();
giStartEvent.setElement(startEvent);
bpmnModel.addGraphicInfo(startEvent.getId(), giStartEvent);
GraphicInfo giUserTask = new GraphicInfo();
giUserTask.setElement(userTask);
bpmnModel.addGraphicInfo(userTask.getId(), giUserTask);
GraphicInfo giEndEvent = new GraphicInfo();
giEndEvent.setElement(endEvent);
bpmnModel.addGraphicInfo(endEvent.getId(), giEndEvent);
return bpmnModel;
}
示例4: testDynamicDeploy
import org.activiti.bpmn.model.BpmnModel; //导入方法依赖的package包/类
@Test
public void testDynamicDeploy() throws Exception {
// 1. 创建一个空的BpmnModel和Process对象
BpmnModel model = new BpmnModel();
Process process = new Process();
model.addProcess(process);
process.setId("my-process");
// 创建Flow元素(所有的事件、任务都被认为是Flow)
process.addFlowElement(createStartEvent());
process.addFlowElement(createUserTask("task1", "First task", "fred"));
process.addFlowElement(createUserTask("task2", "Second task", "john"));
process.addFlowElement(createEndEvent());
process.addFlowElement(createSequenceFlow("start", "task1"));
process.addFlowElement(createSequenceFlow("task1", "task2"));
process.addFlowElement(createSequenceFlow("task2", "end"));
// 2. 流程图自动布局(位于activiti-bpmn-layout模块)
new BpmnAutoLayout(model).execute();
// 3. 把BpmnModel对象部署到引擎
Deployment deployment = activitiRule.getRepositoryService().createDeployment()
.addBpmnModel("dynamic-model.bpmn", model).name("Dynamic process deployment")
.deploy();
// 4. 启动流程
ProcessInstance processInstance = activitiRule.getRuntimeService()
.startProcessInstanceByKey("my-process");
// 5. 检查流程是否正常启动
List<Task> tasks = activitiRule.getTaskService().createTaskQuery()
.processInstanceId(processInstance.getId()).list();
Assert.assertEquals(1, tasks.size());
Assert.assertEquals("First task", tasks.get(0).getName());
Assert.assertEquals("fred", tasks.get(0).getAssignee());
// 6. 导出流程图
InputStream processDiagram = activitiRule.getRepositoryService()
.getProcessDiagram(processInstance.getProcessDefinitionId());
// 把文件生成在本章项目的test-classes目录中
String userHomeDir = getClass().getResource("/").getFile();
System.out.println(userHomeDir);
FileUtils.copyInputStreamToFile(processDiagram, new File(userHomeDir + "/diagram.png"));
// 7. 导出Bpmn文件到本地文件系统
InputStream processBpmn = activitiRule.getRepositoryService()
.getResourceAsStream(deployment.getId(), "dynamic-model.bpmn");
FileUtils.copyInputStreamToFile(processBpmn,
new File(userHomeDir + "/process.bpmn20.xml"));
}