Java Code Examples for org.activiti.engine.ProcessEngine#getRepositoryService()
The following examples show how to use
org.activiti.engine.ProcessEngine#getRepositoryService() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddBpmnModelTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) throws Exception { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 新建部署构造器 DeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); String resourceName = "My Process"; BpmnModel bpmnModel = createProcessModel(); // 发布部署构造器 deploymentBuilder.addBpmnModel(resourceName, bpmnModel); // 发布部署构造器 deploymentBuilder.deploy(); // 关闭流程引擎 engine.close(); }
Example 2
Source File: VerySimpleLeaveProcessTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@Test public void testStartProcess() throws Exception { // 创建流程引擎,使用内存数据库 ProcessEngine processEngine = ProcessEngineConfiguration .createStandaloneInMemProcessEngineConfiguration() .buildProcessEngine(); // 部署流程定义文件 RepositoryService repositoryService = processEngine.getRepositoryService(); String processFileName = "me/kafeitu/activiti/helloworld/sayhelloleave.bpmn"; repositoryService.createDeployment().addClasspathResource(processFileName) .deploy(); // 验证已部署流程定义 ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery().singleResult(); assertEquals("leavesayhello", processDefinition.getKey()); // 启动流程并返回流程实例 RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService .startProcessInstanceByKey("leavesayhello"); assertNotNull(processInstance); System.out.println("pid=" + processInstance.getId() + ", pdid=" + processInstance.getProcessDefinitionId()); }
Example 3
Source File: AddBpmnModelTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) throws Exception { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 新建部署构造器 DeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); String resourceName = "My Process"; BpmnModel bpmnModel = createProcessModel(); // 发布部署构造器 deploymentBuilder.addBpmnModel(resourceName, bpmnModel); // 发布部署构造器 deploymentBuilder.deploy(); // 关闭流程引擎 engine.close(); }
Example 4
Source File: BpmnErrorTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 新建部署构造器 DeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); // 增加错误的schema文件(包括无效的标签)<test>test</test> // 报错信息:[Validation set: 'activiti-executable-process' | //Problem: 'activiti-start-event-multiple-found'] : //Multiple none start events are not supported - //[Extra info : processDefinitionId = myProcess | // processDefinitionName = My process | | id = startevent1 | //| activityName = Start | ] ( line: 4, column: 47) deploymentBuilder.addClasspathResource("error/bpmn_error.bpmn"); // 禁用Bpmn验证 deploymentBuilder.disableBpmnValidation(); // 发布部署构造器 deploymentBuilder.deploy(); // 关闭流程引擎 engine.close(); }
Example 5
Source File: SchemaErrorTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 新建部署构造器 DeploymentBuilder deploymentBuilder = repositoryService.createDeployment(); // 增加错误的schema文件(包括无效的标签)<test>test</test> // 校验报错:发现了以元素 'test' 开头的无效内容。 deploymentBuilder.addClasspathResource("error/schema_error.bpmn"); // 禁用Schema验证 deploymentBuilder.disableSchemaValidation(); // 发布部署构造器 deploymentBuilder.deploy(); // 关闭流程引擎 engine.close(); }
Example 6
Source File: BpmnQueryTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) throws Exception { // 创建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 得到流程存储服务对象 RepositoryService repositoryService = engine.getRepositoryService(); // 部署一份流程文件 Deployment dep = repositoryService.createDeployment() .addClasspathResource("MyFirstProcess.bpmn").deploy(); // 查询流程定义实体 ProcessDefinition def = repositoryService.createProcessDefinitionQuery() .deploymentId(dep.getId()).singleResult(); // 查询资源文件 InputStream is = repositoryService.getProcessModel(def.getId()); // 读取输入流 int count = is.available(); byte[] contents = new byte[count]; is.read(contents); String result = new String(contents); //输入输出结果 System.out.println(result); // 关闭流程引擎 engine.close(); }
Example 7
Source File: TextQueryTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) throws Exception { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 新建部署构造器 DeploymentBuilder deploymentBuilder = repositoryService .createDeployment(); deploymentBuilder.addClasspathResource("my_text.txt"); Deployment deployment = deploymentBuilder.deploy(); // 数据查询 InputStream inputStream = repositoryService.getResourceAsStream( deployment.getId(), "my_text.txt"); int count = inputStream.available(); byte[] contents = new byte[count]; inputStream.read(contents); String result = new String(contents); // 输入结果 System.out.println(result); // 关闭流程引擎 engine.close(); }
Example 8
Source File: ImageQueryTest.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 5 votes |
public static void main(String[] args) throws Exception { // 创建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 得到流程存储服务对象 RepositoryService repositoryService = engine.getRepositoryService(); // 部署一份流程文件与相应的流程图文件 Deployment dep = repositoryService.createDeployment() .addClasspathResource("MyFirstProcess.bpmn").deploy(); // 查询流程定义 ProcessDefinition def = repositoryService .createProcessDefinitionQuery().deploymentId(dep.getId()) .singleResult(); // 查询资源文件 InputStream is = repositoryService.getProcessDiagram(def.getId()); // 将输入流转换为图片对象 BufferedImage image = ImageIO.read(is); // 保存为图片文件 File file = new File("resources/result.png"); if (!file.exists()) { file.createNewFile(); } FileOutputStream fos = new FileOutputStream(file); ImageIO.write(image, "png", fos); fos.close(); is.close(); // 关闭流程引擎 engine.close(); }
Example 9
Source File: ModelTest.java From opscenter with Apache License 2.0 | 5 votes |
@RequestMapping("create") public void createModel(HttpServletRequest request, HttpServletResponse response){ try{ String modelName = "modelName"; String modelKey = "modelKey"; String description = "description"; ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode editorNode = objectMapper.createObjectNode(); editorNode.put("id", "canvas"); editorNode.put("resourceId", "canvas"); ObjectNode stencilSetNode = objectMapper.createObjectNode(); stencilSetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); editorNode.put("stencilset", stencilSetNode); Model modelData = repositoryService.newModel(); ObjectNode modelObjectNode = objectMapper.createObjectNode(); modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, modelName); modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1); modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, description); modelData.setMetaInfo(modelObjectNode.toString()); modelData.setName(modelName); modelData.setKey(modelKey); //保存模型 repositoryService.saveModel(modelData); repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8")); response.sendRedirect(request.getContextPath() + "/modeler.html?modelId=" + modelData.getId()); }catch (Exception e){ } }
Example 10
Source File: App.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 5 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); // 存储服务 RepositoryService repositoryService = engine.getRepositoryService(); // 运行时服务 RuntimeService runtimeService = engine.getRuntimeService(); // 任务服务 TaskService taskService =engine.getTaskService(); // 部署服务 repositoryService.createDeployment().addClasspathResource("MyFirstProcess.bpmn").deploy(); // process的id属性 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess"); // 普通员工完成请假的任务 Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); System.out.println("当前流程节点:" + task.getName()); taskService.complete(task.getId()); // 经理审批任务 task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); System.out.println("当前流程节点:" + task.getName()); taskService.complete(task.getId()); // 流程结束 task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); System.out.println("流程结束:" + task); // 关闭流程引擎 engine.close(); }
Example 11
Source File: ProcessExecutionIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenBPMN_whenDeployProcess_thenDeployed() { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment() .addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml") .deploy(); Long count = repositoryService.createProcessDefinitionQuery().count(); assertTrue(count >= 1); }
Example 12
Source File: ParseHandlerTestDataGenerator.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void generateTestData(ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment().addClasspathResource("parseHandlerProcess.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("parseHandlerTestProcess"); }
Example 13
Source File: ProcessExecutionIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenProcessInstance_whenCompleteTask_thenProcessExecutionContinues() { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment() .addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml") .deploy(); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("employeeName", "Kermit"); variables.put("numberOfDays", new Integer(4)); variables.put("vacationMotivation", "I'm really tired!"); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService .startProcessInstanceByKey("vacationRequest", variables); TaskService taskService = processEngine.getTaskService(); List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("management").list(); Task task = tasks.get(0); Map<String, Object> taskVariables = new HashMap<String, Object>(); taskVariables.put("vacationApproved", "false"); taskVariables.put("comments", "We have a tight deadline!"); taskService.complete(task.getId(), taskVariables); Task currentTask = taskService.createTaskQuery().taskName("Modify vacation request").singleResult(); assertNotNull(currentTask); }
Example 14
Source File: AsyncFailingJobTestDataGenerator.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void generateTestData(ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment().addClasspathResource("async-failing-expression.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("asyncFailingExpression"); }
Example 15
Source File: JavaDelegateTestDataGenerator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void generateTestData(ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment().addClasspathResource("javaDelegateProcess.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("javaDelegateTestProcess"); }
Example 16
Source File: ParseHandlerTestDataGenerator.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void generateTestData(ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment().addClasspathResource("parseHandlerProcess.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); runtimeService.startProcessInstanceByKey("parseHandlerTestProcess"); }
Example 17
Source File: ServiceSpringModuleConfig.java From herd with Apache License 2.0 | 4 votes |
@Bean public RepositoryService activitiRepositoryService(ProcessEngine activitiProcessEngine) throws Exception { return activitiProcessEngine.getRepositoryService(); }
Example 18
Source File: ProcessDefinitionCacheTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() { // Setup both process engines StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration.setProcessEngineName("reboot-test-schema"); standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE); standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration.setActiviti5CompatibilityEnabled(true); ProcessEngine processEngine1 = standaloneProcessEngineConfiguration.buildProcessEngine(); RepositoryService repositoryService1 = processEngine1.getRepositoryService(); StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration2 = new StandaloneProcessEngineConfiguration(); standaloneProcessEngineConfiguration2.setProcessEngineName("reboot-test"); standaloneProcessEngineConfiguration2.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE); standaloneProcessEngineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000"); standaloneProcessEngineConfiguration2.setAsyncExecutorActivate(false); standaloneProcessEngineConfiguration2.setActiviti5CompatibilityEnabled(true); ProcessEngine processEngine2 = standaloneProcessEngineConfiguration2.buildProcessEngine(); RepositoryService repositoryService2 = processEngine2.getRepositoryService(); RuntimeService runtimeService2 = processEngine2.getRuntimeService(); TaskService taskService2 = processEngine2.getTaskService(); // Deploy first version of process: start->originalTask->end on first process engine String deploymentId = repositoryService1.createDeployment() .addClasspathResource("org/activiti5/engine/test/cache/originalProcess.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); // Start process instance on second engine String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceById(processDefinitionId); Task task = taskService2.createTaskQuery().singleResult(); assertEquals("original task", task.getName()); // Delete the deployment on second process engine repositoryService2.deleteDeployment(deploymentId, true); assertEquals(0, repositoryService2.createDeploymentQuery().count()); assertEquals(0, runtimeService2.createProcessInstanceQuery().count()); // deploy a revised version of the process: start->revisedTask->end on first process engine // // Before the bugfix, this would set the cache on the first process engine, // but the second process engine still has the original process definition in his cache. // Since there is a deployment delete in between, the new generated process definition id is the same // as in the original deployment, making the second process engine using the old cached process definition. deploymentId = repositoryService1.createDeployment() .addClasspathResource("org/activiti5/engine/test/cache/revisedProcess.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); // Start process instance on second process engine -> must use revised process definition repositoryService2.createProcessDefinitionQuery().singleResult().getId(); runtimeService2.startProcessInstanceByKey("oneTaskProcess"); task = taskService2.createTaskQuery().singleResult(); assertEquals("revised task", task.getName()); // cleanup repositoryService1.deleteDeployment(deploymentId, true); processEngine1.close(); processEngine2.close(); }
Example 19
Source File: Extender.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
private void checkBundle(Bundle bundle) { LOGGER.debug("Scanning bundle {} for activiti process", bundle.getSymbolicName()); try { List<URL> pathList = new ArrayList<URL>(); String activitiHeader = (String) bundle.getHeaders().get(BUNDLE_ACTIVITI_HEADER); if (activitiHeader == null) { activitiHeader = "OSGI-INF/activiti/"; } List<PathElement> paths = HeaderParser.parseHeader(activitiHeader); for (PathElement path : paths) { String name = path.getName(); if (name.endsWith("/")) { addEntries(bundle, name, "*.*", pathList); } else { String baseName; String filePattern; int pos = name.lastIndexOf('/'); if (pos < 0) { baseName = "/"; filePattern = name; } else { baseName = name.substring(0, pos + 1); filePattern = name.substring(pos + 1); } if (hasWildcards(filePattern)) { addEntries(bundle, baseName, filePattern, pathList); } else { addEntry(bundle, name, pathList); } } } if (!pathList.isEmpty()) { LOGGER.debug("Found activiti process in bundle {} with paths: {}", bundle.getSymbolicName(), pathList); ProcessEngine engine = (ProcessEngine) engineServiceTracker.waitForService(timeout); if (engine == null) { throw new IllegalStateException("Unable to find a ProcessEngine service"); } RepositoryService service = engine.getRepositoryService(); DeploymentBuilder builder = service.createDeployment(); builder.name(bundle.getSymbolicName()); for (URL url : pathList) { InputStream is = url.openStream(); if (is == null) { throw new IOException("Error opening url: " + url); } try { builder.addInputStream(getPath(url), is); } finally { is.close(); } } builder.enableDuplicateFiltering(); builder.deploy(); } else { LOGGER.debug("No activiti process found in bundle {}", bundle.getSymbolicName()); } } catch (Throwable t) { LOGGER.error("Unable to deploy activiti bundle", t); } }
Example 20
Source File: DeploymentActivity.java From MicroCommunity with Apache License 2.0 | 3 votes |
public static void deploymentProcess() { ProcessEngine processEngine = ApplicationContextFactory.getBean("processEngine", ProcessEngine.class); RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment() .name("采购申请流程") .addClasspathResource("processes/resourceEntryStore.bpmn").deploy(); }