Java Code Examples for org.activiti.engine.ProcessEngines#getDefaultProcessEngine()
The following examples show how to use
org.activiti.engine.ProcessEngines#getDefaultProcessEngine() .
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: 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 2
Source File: ActivitiTestBase.java From crnk-framework with Apache License 2.0 | 6 votes |
@Before public void setup() { processEngine = ProcessEngines.getDefaultProcessEngine(); processEngine.getRepositoryService().createDeployment() .addClasspathResource("approval.bpmn20.xml") .deploy(); boot = new CrnkBoot(); boot.addModule(new TestModule()); boot.addModule(createActivitiModule()); boot.boot(); taskRepository = (TaskResourceRepository<ApproveTask>) boot.getResourceRegistry().getEntry(ApproveTask.class) .getResourceRepository().getImplementation(); }
Example 3
Source File: MuleHttpTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void http() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttp.bpmn20.xml").deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(20, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
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: 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 6
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 7
Source File: MuleHttpBasicAuthTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void httpWithBasicAuth() throws Exception { Assert.assertTrue(muleContext.isStarted()); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); Deployment deployment = processEngine.getRepositoryService() .createDeployment() .addClasspathResource("org/activiti5/mule/testHttpBasicAuth.bpmn20.xml") .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE) .deploy(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess"); Assert.assertFalse(processInstance.isEnded()); Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable"); Assert.assertEquals(10, result); runtimeService.deleteProcessInstance(processInstance.getId(), "test"); processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId()); processEngine.getRepositoryService().deleteDeployment(deployment.getId()); assertAndEnsureCleanDb(processEngine); ProcessEngines.destroy(); }
Example 8
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 9
Source File: ListPageGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); List<Group> groups = identityService.createGroupQuery().listPage(1, 5); for (Group group : groups) { System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType()); } // 关闭流程引擎 engine.close(); }
Example 10
Source File: AddZipInputStreamTest.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(); // 新建文件输入流 FileInputStream fileInputStream = new FileInputStream(new File("resources/datas.zip")); // 新建Zip输入流 ZipInputStream zipInputStream = new ZipInputStream(fileInputStream); // 将Zip输入流添加到部署构造器中 deploymentBuilder.addZipInputStream(zipInputStream); // 发布部署构造器 deploymentBuilder.deploy(); // 关闭流程引擎 engine.close(); }
Example 11
Source File: SortMultiGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); // 先按名称降序,再按类型降序 List<Group> groups = identityService.createGroupQuery() .orderByGroupName().desc().orderByGroupType().desc().list(); for (Group group : groups) { System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType()); } // 关闭流程引擎 engine.close(); }
Example 12
Source File: ApprovalTestApplication.java From crnk-framework with Apache License 2.0 | 6 votes |
public ApprovalTestApplication() { property(CrnkProperties.RESOURCE_DEFAULT_DOMAIN, "http://test.local"); CrnkFeature feature = new CrnkFeature(); initObjectMapper(feature); ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RuntimeService runtimeService = processEngine.getRuntimeService(); TaskService taskService = processEngine.getTaskService(); ModuleRegistry moduleRegistry = feature.getBoot().getModuleRegistry(); processEngine.getRepositoryService().createDeployment() .addClasspathResource("approval.bpmn20.xml") .deploy(); ActivitiResourceMapper resourceMapper = new ActivitiResourceMapper(moduleRegistry.getTypeParser(), new DefaultDateTimeMapper()); ApprovalMapper mapper = new ApprovalMapper(); ApprovalManager approvalManager = new ApprovalManagerFactory().getInstance(); approvalManager.init(runtimeService, taskService, resourceMapper, mapper, moduleRegistry); feature.addModule(createApprovalModule(approvalManager)); feature.addModule(createActivitiModule(processEngine)); feature.addModule(new TestModule()); registerInstances(feature); }
Example 13
Source File: PluggableActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void initializeProcessEngine() { if (cachedProcessEngine == null) { pluggableActivitiTestCaseLogger.info("No cached process engine found for test. Retrieving the default engine."); ProcessEngines.destroy(); // Just to be sure we're not getting any previously cached version cachedProcessEngine = ProcessEngines.getDefaultProcessEngine(); if (cachedProcessEngine == null) { throw new ActivitiException("no default process engine available"); } } processEngine = cachedProcessEngine; processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration(); // Enable verbose execution tree debugging if needed if (this.getClass().isAnnotationPresent(EnableVerboseExecutionTreeLogging.class)) { swapCommandInvoker(true); } }
Example 14
Source File: SortGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); List<Group> groups = identityService.createGroupQuery() .orderByGroupName().desc().list(); for (Group group : groups) { System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType()); } // 关闭流程引擎 engine.close(); }
Example 15
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 16
Source File: SingleResult.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 5 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); // Group group = identityService.createGroupQuery().groupName("Group_5") .singleResult(); System.out.println(group.getId() + "---" + group.getName() + "---" + group.getType()); // 关闭流程引擎 engine.close(); }
Example 17
Source File: CountGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 5 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); // Long count = identityService.createGroupQuery().count(); System.out.println(count); // 关闭流程引擎 engine.close(); }
Example 18
Source File: CountGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 5 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); // Long count = identityService.createGroupQuery().count(); System.out.println(count); // 关闭流程引擎 engine.close(); }
Example 19
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 20
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(); }