Java Code Examples for org.camunda.bpm.engine.ProcessEngine#getRepositoryService()
The following examples show how to use
org.camunda.bpm.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: InvoiceProcessApplication.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public void createDeployment(String processArchiveName, DeploymentBuilder deploymentBuilder) { ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getProcessEngine("default"); // Hack: deploy the first version of the invoice process once before the process application // is deployed the first time if (processEngine != null) { RepositoryService repositoryService = processEngine.getRepositoryService(); if (!isProcessDeployed(repositoryService, "invoice")) { ClassLoader classLoader = getProcessApplicationClassloader(); repositoryService.createDeployment(this.getReference()) .addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn")) .addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn")) .addInputStream("reviewInvoice.bpmn", classLoader.getResourceAsStream("reviewInvoice.bpmn")) .deploy(); } } }
Example 2
Source File: UpgradedDBDropper.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void cleanDatabase(ProcessEngine engine) { // delete all deployments RepositoryService repositoryService = engine.getRepositoryService(); List<Deployment> deployments = repositoryService .createDeploymentQuery() .list(); for (Deployment deployment : deployments) { repositoryService.deleteDeployment(deployment.getId(), true); } // drop DB ((ProcessEngineImpl)engine).getProcessEngineConfiguration() .getCommandExecutorTxRequired() .execute(new Command<Void>() { public Void execute(CommandContext commandContext) { commandContext.getDbSqlSession().dbSchemaDrop(); return null; } }); engine.close(); }
Example 3
Source File: TestFoxPlatformClientAsEjbModule_onePaAsLib.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testOnePaAsLib() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); long count = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("testDeployProcessArchive") .count(); Assert.assertEquals(1, count); }
Example 4
Source File: TestFoxPlatformClientAsEjbModule_pasAsEjbModule.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testPaAsEjbModule() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); long count = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("paAsEjbModule-process") .count(); Assert.assertEquals(1, count); }
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: SpringTransactionsProcessEngineConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void autoDeployResources(ProcessEngine processEngine) { if (deploymentResources!=null && deploymentResources.length>0) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeploymentBuilder deploymentBuilder = repositoryService .createDeployment() .enableDuplicateFiltering(deployChangedOnly) .name(deploymentName) .tenantId(deploymentTenantId); for (Resource resource : deploymentResources) { String resourceName = null; if (resource instanceof ContextResource) { resourceName = ((ContextResource) resource).getPathWithinContext(); } else if (resource instanceof ByteArrayResource) { resourceName = resource.getDescription(); } else { resourceName = getFileResourceName(resource); } try { if ( resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar") ) { deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream())); } else { deploymentBuilder.addInputStream(resourceName, resource.getInputStream()); } } catch (IOException e) { throw new ProcessEngineException("couldn't auto deploy resource '"+resource+"': "+e.getMessage(), e); } } deploymentBuilder.deploy(); } }
Example 7
Source File: TestMultipleClasspathRoots.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testMultipleClasspathRoots() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery(); long count = query.count(); Assert.assertEquals(1, count); }
Example 8
Source File: HalCaseDefinitionResolver.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); List<CaseDefinition> caseDefinitions = repositoryService.createCaseDefinitionQuery() .caseDefinitionIdIn(linkedIds) .listPage(0, linkedIds.length); List<HalResource<?>> resolved = new ArrayList<HalResource<?>>(); for (CaseDefinition caseDefinition : caseDefinitions) { resolved.add(HalCaseDefinition.fromCaseDefinition(caseDefinition, processEngine)); } return resolved; }
Example 9
Source File: HalProcessDefinitionResolver.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<HalResource<?>> resolveNotCachedLinks(String[] linkedIds, ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery() .processDefinitionIdIn(linkedIds) .listPage(0, linkedIds.length); List<HalResource<?>> resolved = new ArrayList<HalResource<?>>(); for (ProcessDefinition procDef : processDefinitions) { resolved.add(HalProcessDefinition.fromProcessDefinition(procDef, processEngine)); } return resolved; }
Example 10
Source File: TestFoxPlatformClientAsEjbModule_twoPasAsLib.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testTwoPasAsLib() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); long count = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("process1") .count(); Assert.assertEquals(1, count); count = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("process2") .count(); Assert.assertEquals(1, count); }
Example 11
Source File: TestHelper.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static void assertDiagramIsDeployed(boolean deployed, Class<?> clazz, String expectedDiagramResource, String processDefinitionKey) throws IOException { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionKey(processDefinitionKey) .singleResult(); assertNotNull(processDefinition); InputStream actualStream = null; InputStream expectedStream = null; try { actualStream = repositoryService.getProcessDiagram(processDefinition.getId()); if (deployed) { byte[] actualDiagram = IoUtil.readInputStream(actualStream, "actualStream"); assertNotNull(actualDiagram); assertTrue(actualDiagram.length > 0); expectedStream = clazz.getResourceAsStream(expectedDiagramResource); byte[] expectedDiagram = IoUtil.readInputStream(expectedStream, "expectedSteam"); assertNotNull(expectedDiagram); assertTrue(isEqual(expectedStream, actualStream)); } else { assertNull(actualStream); } } finally { IoUtil.closeSilently(actualStream); IoUtil.closeSilently(expectedStream); } }
Example 12
Source File: TestFoxPlatformClientAsLibInWebModule.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testDeployProcessArchive() { ProcessEngine processEngine = ProgrammaticBeanLookup.lookup(ProcessEngine.class); Assert.assertNotNull(processEngine); RepositoryService repositoryService = processEngine.getRepositoryService(); long count = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("testDeployProcessArchive") .count(); Assert.assertEquals(1, count); }
Example 13
Source File: TestOrderingUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static NullTolerantComparator<DecisionDefinition> decisionDefinitionByDeployTime(ProcessEngine processEngine) { RepositoryService repositoryService = processEngine.getRepositoryService(); return propertyComparator(new PropertyAccessor<DecisionDefinition, Date>() { @Override public Date getProperty(DecisionDefinition obj) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(obj.getDeploymentId()).singleResult(); return deployment.getDeploymentTime(); } }); }
Example 14
Source File: TestOrderingUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static NullTolerantComparator<ProcessDefinition> processDefinitionByDeployTime(ProcessEngine processEngine){ RepositoryService repositoryService = processEngine.getRepositoryService(); return propertyComparator(new PropertyAccessor<ProcessDefinition, Date>() { @Override public Date getProperty(ProcessDefinition obj) { Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(obj.getDeploymentId()).singleResult(); return deployment.getDeploymentTime(); } }); }
Example 15
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 16
Source File: VersionedDeploymentHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public VersionedDeploymentHandler(ProcessEngine processEngine) { this.processEngine = processEngine; this.repositoryService = processEngine.getRepositoryService(); }
Example 17
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 18
Source File: DeployProcessArchiveStep.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void performOperationStep(DeploymentOperation operationContext) { final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer(); final AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION); final ClassLoader processApplicationClassloader = processApplication.getProcessApplicationClassloader(); ProcessEngine processEngine = getProcessEngine(serviceContainer, processApplication.getDefaultDeployToEngineName()); // start building deployment map Map<String, byte[]> deploymentMap = new HashMap<String, byte[]>(); // add all processes listed in the processes.xml List<String> listedProcessResources = processArchive.getProcessResourceNames(); for (String processResource : listedProcessResources) { InputStream resourceAsStream = null; try { resourceAsStream = processApplicationClassloader.getResourceAsStream(processResource); byte[] bytes = IoUtil.readInputStream(resourceAsStream, processResource); deploymentMap.put(processResource, bytes); } finally { IoUtil.closeSilently(resourceAsStream); } } // scan for additional process definitions if not turned off if(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS, true)) { String paResourceRoot = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESOURCE_ROOT_PATH); String[] additionalResourceSuffixes = StringUtil.split(processArchive.getProperties().get(ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES), ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES_SEPARATOR); deploymentMap.putAll(findResources(processApplicationClassloader, paResourceRoot, additionalResourceSuffixes)); } // perform process engine deployment RepositoryService repositoryService = processEngine.getRepositoryService(); ProcessApplicationDeploymentBuilder deploymentBuilder = repositoryService.createDeployment(processApplication.getReference()); // set the name for the deployment String deploymentName = processArchive.getName(); if(deploymentName == null || deploymentName.isEmpty()) { deploymentName = processApplication.getName(); } deploymentBuilder.name(deploymentName); // set the tenant id for the deployment String tenantId = processArchive.getTenantId(); if(tenantId != null && !tenantId.isEmpty()) { deploymentBuilder.tenantId(tenantId); } // enable duplicate filtering deploymentBuilder.enableDuplicateFiltering(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DEPLOY_CHANGED_ONLY, false)); if (PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_RESUME_PREVIOUS_VERSIONS, true)) { enableResumingOfPreviousVersions(deploymentBuilder); } // add all resources obtained through the processes.xml and through scanning for (Entry<String, byte[]> deploymentResource : deploymentMap.entrySet()) { deploymentBuilder.addInputStream(deploymentResource.getKey(), new ByteArrayInputStream(deploymentResource.getValue())); } // allow the process application to add additional resources to the deployment processApplication.createDeployment(processArchive.getName(), deploymentBuilder); Collection<String> deploymentResourceNames = deploymentBuilder.getResourceNames(); if(!deploymentResourceNames.isEmpty()) { LOG.deploymentSummary(deploymentResourceNames, deploymentName); // perform the process engine deployment deployment = deploymentBuilder.deploy(); // add attachment Map<String, DeployedProcessArchive> processArchiveDeploymentMap = operationContext.getAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP); if(processArchiveDeploymentMap == null) { processArchiveDeploymentMap = new HashMap<String, DeployedProcessArchive>(); operationContext.addAttachment(Attachments.PROCESS_ARCHIVE_DEPLOYMENT_MAP, processArchiveDeploymentMap); } processArchiveDeploymentMap.put(processArchive.getName(), new DeployedProcessArchive(deployment)); } else { LOG.notCreatingPaDeployment(processApplication.getName()); } }
Example 19
Source File: DefaultDeploymentHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public DefaultDeploymentHandler(ProcessEngine processEngine) { this.processEngine = processEngine; this.repositoryService = processEngine.getRepositoryService(); }
Example 20
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; }