use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml.
@Test
public void testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml() {
// given the asyncBefore is set in the xml
String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore and asyncAfter is set to true in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists two job definitions
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
List<JobDefinition> definitions = query.orderByJobConfiguration().asc().list();
assertEquals(definitions.size(), 2);
// asyncAfter
JobDefinition asyncAfterAfter = definitions.get(0);
assertEquals(asyncAfterAfter.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(asyncAfterAfter.getActivityId(), "servicetask1");
assertEquals(asyncAfterAfter.getJobConfiguration(), MessageJobDeclaration.ASYNC_AFTER);
// asyncBefore
JobDefinition asyncAfterBefore = definitions.get(1);
assertEquals(asyncAfterBefore.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(asyncAfterBefore.getActivityId(), "servicetask1");
assertEquals(asyncAfterBefore.getJobConfiguration(), MessageJobDeclaration.ASYNC_BEFORE);
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionDeletionWithParseListenerTest method testDeleteJobDefinitionWithParseListenerAndAsyncInXml.
@Test
public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() {
// given the asyncBefore is set in the xml
String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore is set to false in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists no job definition
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
assertNull(query.singleResult());
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class DeployModelInstancesTask method run.
public void run() {
DeploymentBuilder deploymentbuilder = engine.getRepositoryService().createDeployment();
for (int i = 0; i < modelInstances.size(); i++) {
deploymentbuilder.addModelInstance("process" + i + ".bpmn", modelInstances.get(i));
}
deploymentbuilder.deploy();
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class SpringTransactionsProcessEngineConfiguration method autoDeployResources.
protected void autoDeployResources(ProcessEngine processEngine) {
if (deploymentResources != null && deploymentResources.length > 0) {
RepositoryService repositoryService = processEngine.getRepositoryService();
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering(false).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 {
try {
resourceName = resource.getFile().getAbsolutePath();
} catch (IOException e) {
resourceName = resource.getFilename();
}
}
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();
}
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationInTransactionTest method deployModelInstance.
private void deployModelInstance(BpmnModelInstance modelInstance) {
DeploymentBuilder deploymentbuilder = repositoryService.createDeployment();
deploymentbuilder.addModelInstance("process0.bpmn", modelInstance);
Deployment deployment = deploymentbuilder.deploy();
rule.manageDeployment(deployment);
}
Aggregations