Search in sources :

Example 11 with ProcessDefinition

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);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 12 with ProcessDefinition

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;
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) ProcessDefinitionQueryImpl(org.camunda.bpm.engine.impl.ProcessDefinitionQueryImpl) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) List(java.util.List)

Example 13 with ProcessDefinition

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);
}
Also used : ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition)

Example 14 with ProcessDefinition

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);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with ProcessDefinition

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());
}
Also used : LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test)

Aggregations

ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1093 Test (org.junit.Test)761 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)415 Deployment (org.camunda.bpm.engine.test.Deployment)230 Job (org.camunda.bpm.engine.runtime.Job)148 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)119 Batch (org.camunda.bpm.engine.batch.Batch)95 Task (org.camunda.bpm.engine.task.Task)87 HashMap (java.util.HashMap)77 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)64 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)55 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)54 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)47 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)41 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)40 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)39 Date (java.util.Date)38 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)35