Java Code Examples for org.camunda.bpm.engine.ProcessEngine#getRuntimeService()
The following examples show how to use
org.camunda.bpm.engine.ProcessEngine#getRuntimeService() .
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: StartProcessIntanceWithInitialVariablesScenario.java From camunda-bpm-platform with Apache License 2.0 | 7 votes |
@DescribesScenario("startProcessIntanceWithInitialVariablesScenario") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { @Override public void execute(ProcessEngine engine, String scenarioName) { RuntimeService runtimeService = engine.getRuntimeService(); String businessKey = "712_ProcessIntanceExecuted"; runtimeService.startProcessInstanceByKey("asyncBeforeStartProcess_712", businessKey, Variables.createVariables() .putValue("initial1", "value1")); businessKey = "7120_ProcessIntanceWithoutExecute"; runtimeService.startProcessInstanceByKey("asyncBeforeStartProcess_712", businessKey, Variables.createVariables() .putValue("initial2", "value1")); businessKey = "7120_ProcessIntanceWithoutExecuteAndSetVariables"; runtimeService.startProcessInstanceByKey("asyncBeforeStartProcess_712", businessKey, Variables.createVariables() .putValue("initial3", "value1")); } }; }
Example 2
Source File: PrintServiceProcessApplication.java From camunda-bpm-mail with Apache License 2.0 | 5 votes |
@PostDeploy public void startService(ProcessEngine processEngine) throws Exception { RuntimeService runtimeService = processEngine.getRuntimeService(); configuration = MailConfigurationFactory.getConfiguration(); notificationService = new MailNotificationService(configuration); notificationService.registerMailHandler(mail -> { runtimeService.startProcessInstanceByKey("printProcess", Variables.createVariables() .putValue("mail", mail) .putValue("invoice", getInvoicePath())); }); notificationService.start(); }
Example 3
Source File: TestOrderingUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static NullTolerantComparator<Execution> executionByProcessDefinitionKey(ProcessEngine processEngine) { final RuntimeService runtimeService = processEngine.getRuntimeService(); final RepositoryService repositoryService = processEngine.getRepositoryService(); return propertyComparator(new PropertyAccessor<Execution, String>() { @Override public String getProperty(Execution obj) { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() .processInstanceId(obj.getProcessInstanceId()).singleResult(); ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); return processDefinition.getKey(); } }); }
Example 4
Source File: SetVariablesScenario.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@DescribesScenario("setVariablesScenario") public static ScenarioSetup createUserOperationLogEntries() { return new ScenarioSetup() { @Override public void execute(ProcessEngine engine, String scenarioName) { RuntimeService runtimeService = engine.getRuntimeService(); ProcessInstance processInstanceWithInitialVariables = runtimeService.createProcessInstanceQuery() .processDefinitionKey("asyncBeforeStartProcess_712") .processInstanceBusinessKey("712_ProcessIntanceExecuted") .singleResult(); ManagementService managementService = engine.getManagementService(); Job firstJob = managementService.createJobQuery() .processDefinitionKey("asyncBeforeStartProcess_712") .processInstanceId(processInstanceWithInitialVariables.getId()) .singleResult(); try { managementService.executeJob(firstJob.getId()); } catch (Exception e) { // ignore } ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() .processDefinitionKey("asyncBeforeStartProcess_712") .processInstanceBusinessKey("7120_ProcessIntanceWithoutExecute") .singleResult(); runtimeService.setVariable(processInstance.getId(), "foo", "value"); runtimeService.setVariableLocal(processInstance.getId(), "local", "foo1"); } }; }
Example 5
Source File: TestFixture.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public TestFixture(ProcessEngine processEngine) { this.processEngine = processEngine; repositoryService = processEngine.getRepositoryService(); runtimeService = processEngine.getRuntimeService(); managementService = processEngine.getManagementService(); taskService = processEngine.getTaskService(); }
Example 6
Source File: TestFixture.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public TestFixture(ProcessEngine processEngine) { this.processEngine = processEngine; repositoryService = processEngine.getRepositoryService(); runtimeService = processEngine.getRuntimeService(); managementService = processEngine.getManagementService(); taskService = processEngine.getTaskService(); }
Example 7
Source File: EngineDataGenerator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public EngineDataGenerator(final ProcessEngine processEngine, final int optimizePageSize) { this.processEngine = processEngine; this.identityService = processEngine.getIdentityService(); this.decisionService = processEngine.getDecisionService(); this.repositoryService = processEngine.getRepositoryService(); this.runtimeService = processEngine.getRuntimeService(); this.taskService = processEngine.getTaskService(); // we double the amount of instances to generate to make sure that there are at least two pages // of each entity available numberOfInstancesToGenerate = optimizePageSize * 2; }
Example 8
Source File: TestDataGenerator.java From camunda-bpm-elasticsearch with Apache License 2.0 | 4 votes |
public static HashMap<String, ProcessDataContainer> startInvoiceProcess(ProcessEngine processEngine, final int numberOfInstances, boolean addRandomTimeInterval) { RepositoryService repositoryService = processEngine.getRepositoryService(); RuntimeService runtimeService = processEngine.getRuntimeService(); TaskService taskService = processEngine.getTaskService(); Deployment deployment = repositoryService.createDeployment().addClasspathResource("invoice.bpmn").deploy(); Assert.assertNotNull(repositoryService.createDeploymentQuery().deploymentId(deployment.getId()).singleResult()); LOGGER.info("Creating " + numberOfInstances + " instances of 'invoice.bpmn' process."); HashMap<String, ProcessDataContainer> variablesByProcessIds = new HashMap<String, ProcessDataContainer>(numberOfInstances); for (int i = 0; i < numberOfInstances; i++) { if (addRandomTimeInterval) { ClockUtil.setCurrentTime(new Date(ClockUtil.getCurrentTime().getTime() + getRandomLong())); } HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put(TestDataGenerator.getRandomString(), TestDataGenerator.getRandomString()); variables.put("long", TestDataGenerator.getRandomLong()); variables.put("double", TestDataGenerator.getRandomDouble()); ProcessInstance pi = runtimeService.startProcessInstanceByKey("invoice", variables); Assert.assertNotNull(pi); List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list(); assertEquals(1, tasks.size()); assertEquals("assignApprover", tasks.get(0).getTaskDefinitionKey()); variables.clear(); String approver = TestDataGenerator.getRandomString(); variables.put("approver", approver); taskService.complete(tasks.get(0).getId(), variables); tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list(); assertEquals(1, tasks.size()); assertEquals("approveInvoice", tasks.get(0).getTaskDefinitionKey()); assertEquals(approver, tasks.get(0).getAssignee()); variables.clear(); variables.put("approved", Boolean.TRUE); taskService.complete(tasks.get(0).getId(), variables); tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list(); // retrieve all variables List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().processInstanceIdIn(pi.getProcessInstanceId()).list(); variablesByProcessIds.put(pi.getProcessInstanceId(), new ProcessDataContainer(pi.getProcessInstanceId(), pi.getBusinessKey(), variableInstances)); assertEquals(1, tasks.size()); assertEquals("prepareBankTransfer", tasks.get(0).getTaskDefinitionKey()); taskService.complete(tasks.get(0).getId()); ProcessEngineAssert.assertProcessEnded(processEngine, pi.getId()); } LOGGER.info("Created " + numberOfInstances + " instances of 'invoice.bpmn' process."); return variablesByProcessIds; }
Example 9
Source File: RepositoryServiceTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() { // Setup both process engines ProcessEngine processEngine1 = new StandaloneProcessEngineConfiguration() .setProcessEngineName("reboot-test-schema") .setDatabaseSchemaUpdate(org.camunda.bpm.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE) .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000") .setJobExecutorActivate(false) .buildProcessEngine(); RepositoryService repositoryService1 = processEngine1.getRepositoryService(); ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration() .setProcessEngineName("reboot-test") .setDatabaseSchemaUpdate(org.camunda.bpm.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE) .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000") .setJobExecutorActivate(false) .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/camunda/bpm/engine/test/api/repository/RepositoryServiceTest.testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.v1.bpmn20.xml") .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/camunda/bpm/engine/test/api/repository/RepositoryServiceTest.testDeployRevisedProcessAfterDeleteOnOtherProcessEngine.v2.bpmn20.xml") .deploy() .getId(); // Start process instance on second process engine -> must use revised process definition processDefinitionId = 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 10
Source File: ProcessEngineAwareStep.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public ProcessEngineAwareStep(ProcessEngine processEngine) { this.processEngine = processEngine; runtimeService = processEngine.getRuntimeService(); taskService = processEngine.getTaskService(); repositoryService = processEngine.getRepositoryService(); }