use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class DeploymentManager method deleteDeployment.
public void deleteDeployment(String deploymentId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) {
List<ProcessDefinition> processDefinitions = getProcessDefinitionManager().findProcessDefinitionsByDeploymentId(deploymentId);
if (cascade) {
// we can cleanly remove the process definitions.
for (ProcessDefinition processDefinition : processDefinitions) {
String processDefinitionId = processDefinition.getId();
getProcessInstanceManager().deleteProcessInstancesByProcessDefinition(processDefinitionId, "deleted deployment", true, skipCustomListeners, skipIoMappings);
}
// delete historic job logs (for example for timer start event jobs)
getHistoricJobLogManager().deleteHistoricJobLogsByDeploymentId(deploymentId);
}
for (ProcessDefinition processDefinition : processDefinitions) {
String processDefinitionId = processDefinition.getId();
// Process definition cascade true deletes the history and
// process instances if instances flag is set as well to true.
// Problem as described above, redeployes the deployment.
// Represents no problem if only one process definition is deleted
// in a transaction! We have to set the instances flag to false.
getProcessDefinitionManager().deleteProcessDefinition(processDefinition, processDefinitionId, cascade, false, skipCustomListeners);
}
deleteCaseDeployment(deploymentId, cascade);
deleteDecisionDeployment(deploymentId, cascade);
deleteDecisionRequirementDeployment(deploymentId);
getResourceManager().deleteResourcesByDeploymentId(deploymentId);
deleteAuthorizations(Resources.DEPLOYMENT, deploymentId);
getDbEntityManager().delete(DeploymentEntity.class, "deleteDeployment", deploymentId);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class BpmnModelInstanceCache method getAllDefinitionsForDeployment.
@Override
protected List<ProcessDefinition> getAllDefinitionsForDeployment(final String deploymentId) {
final CommandContext commandContext = Context.getCommandContext();
List<ProcessDefinition> allDefinitionsForDeployment = commandContext.runWithoutAuthorization(new Callable<List<ProcessDefinition>>() {
public List<ProcessDefinition> call() throws Exception {
return new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list();
}
});
return allDefinitionsForDeployment;
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class CmmnDisabledTest method testCmmnDisabled.
public void testCmmnDisabled() {
ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()).addClasspathResource("org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml").deploy();
// process is deployed:
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertNotNull(processDefinition);
assertEquals(1, processDefinition.getVersion());
try {
repositoryService.createCaseDefinitionQuery().singleResult();
fail("Cmmn Disabled: It should not be possible to query for a case definition.");
} catch (Exception e) {
// expected
}
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ExternalTaskQueryTest method testQueryByProcessDefinitionId.
@Deployment(resources = "org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml")
public void testQueryByProcessDefinitionId() {
// given
org.camunda.bpm.engine.repository.Deployment secondDeployment = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/externaltask/oneExternalTaskProcess.bpmn20.xml").deploy();
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list();
startInstancesById(processDefinitions.get(0).getId(), 3);
startInstancesById(processDefinitions.get(1).getId(), 2);
// when
List<ExternalTask> definition1Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions.get(0).getId()).list();
List<ExternalTask> definition2Tasks = externalTaskService.createExternalTaskQuery().processDefinitionId(processDefinitions.get(1).getId()).list();
// then
assertEquals(3, definition1Tasks.size());
for (ExternalTask task : definition1Tasks) {
assertEquals(processDefinitions.get(0).getId(), task.getProcessDefinitionId());
}
assertEquals(2, definition2Tasks.size());
for (ExternalTask task : definition2Tasks) {
assertEquals(processDefinitions.get(1).getId(), task.getProcessDefinitionId());
}
// cleanup
repositoryService.deleteDeployment(secondDeployment.getId(), true);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ExternalTaskSupportTest method testExternalTaskSupport.
@Test
public void testExternalTaskSupport() {
// given
ProcessDefinition processDefinition = rule.getRepositoryService().createProcessDefinitionQuery().singleResult();
// when
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(processDefinition.getId());
// then
List<LockedExternalTask> externalTasks = rule.getExternalTaskService().fetchAndLock(1, "aWorker").topic("externalTaskTopic", 5000L).execute();
Assert.assertEquals(1, externalTasks.size());
Assert.assertEquals(processInstance.getId(), externalTasks.get(0).getProcessInstanceId());
// and it is possible to complete the external task successfully and end the process instance
rule.getExternalTaskService().complete(externalTasks.get(0).getId(), "aWorker");
Assert.assertEquals(0L, rule.getRuntimeService().createProcessInstanceQuery().count());
}
Aggregations