Search in sources :

Example 56 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class MigrationCompensationInstanceVisitor method instantiateScopes.

@Override
protected void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, List<ScopeImpl> scopesToInstantiate) {
    if (scopesToInstantiate.isEmpty()) {
        return;
    }
    ExecutionEntity ancestorScopeExecution = ancestorScopeInstance.resolveRepresentativeExecution();
    ExecutionEntity parentExecution = ancestorScopeExecution;
    for (ScopeImpl scope : scopesToInstantiate) {
        ExecutionEntity compensationScopeExecution = parentExecution.createExecution();
        compensationScopeExecution.setScope(true);
        compensationScopeExecution.setEventScope(true);
        compensationScopeExecution.setActivity((PvmActivity) scope);
        compensationScopeExecution.setActive(false);
        compensationScopeExecution.activityInstanceStarting();
        compensationScopeExecution.enterActivityInstance();
        EventSubscriptionEntity eventSubscription = EventSubscriptionEntity.createAndInsert(parentExecution, EventType.COMPENSATE, (ActivityImpl) scope);
        eventSubscription.setConfiguration(compensationScopeExecution.getId());
        executionBranch.visited(new MigratingEventScopeInstance(eventSubscription, compensationScopeExecution, scope));
        parentExecution = compensationScopeExecution;
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)

Example 57 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class MigratingActivityInstanceVisitor method instantiateScopes.

protected void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, List<ScopeImpl> scopesToInstantiate) {
    if (scopesToInstantiate.isEmpty()) {
        return;
    }
    // must always be an activity instance
    MigratingActivityInstance ancestorActivityInstance = (MigratingActivityInstance) ancestorScopeInstance;
    ExecutionEntity newParentExecution = ancestorActivityInstance.createAttachableExecution();
    Map<PvmActivity, PvmExecutionImpl> createdExecutions = newParentExecution.instantiateScopes((List) scopesToInstantiate, skipCustomListeners, skipIoMappings);
    for (ScopeImpl scope : scopesToInstantiate) {
        ExecutionEntity createdExecution = (ExecutionEntity) createdExecutions.get(scope);
        createdExecution.setActivity(null);
        createdExecution.setActive(false);
        executionBranch.visited(new MigratingActivityInstance(scope, createdExecution));
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 58 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class IncidentTest method testShouldDeleteIncidentAfterJobWasSuccessfully.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/IncidentTest.testShouldDeleteIncidentAfterJobWasSuccessfully.bpmn" })
public void testShouldDeleteIncidentAfterJobWasSuccessfully() {
    // Start process instance
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("fail", true);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcessWithUserTask", parameters);
    executeAvailableJobs();
    // job exists
    Job job = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(job);
    // incident was created
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(incident);
    // set execution variable from "true" to "false"
    runtimeService.setVariable(processInstance.getId(), "fail", new Boolean(false));
    // set retries of failed job to 1, with the change of the fail variable the job
    // will be executed successfully
    managementService.setJobRetries(job.getId(), 1);
    executeAvailableJobs();
    // Update process instance
    processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
    assertTrue(processInstance instanceof ExecutionEntity);
    // should stay in the user task
    ExecutionEntity exec = (ExecutionEntity) processInstance;
    assertEquals("theUserTask", exec.getActivityId());
    // there does not exist any incident anymore
    incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNull(incident);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 59 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class MessageCorrelationTest method checkExecutionMessageCorrelationResult.

protected void checkExecutionMessageCorrelationResult(MessageCorrelationResult result, ProcessInstance processInstance, String activityId) {
    assertNotNull(result);
    assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
    assertEquals(processInstance.getId(), result.getExecution().getProcessInstanceId());
    ExecutionEntity entity = (ExecutionEntity) result.getExecution();
    assertEquals(activityId, entity.getActivityId());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 60 with ExecutionEntity

use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.

the class MessageCorrelationByLocalVariablesTest method checkExecutionMessageCorrelationResult.

protected void checkExecutionMessageCorrelationResult(MessageCorrelationResult result, ProcessInstance processInstance, String activityId) {
    assertNotNull(result);
    assertEquals(MessageCorrelationResultType.Execution, result.getResultType());
    assertEquals(processInstance.getId(), result.getExecution().getProcessInstanceId());
    ExecutionEntity entity = (ExecutionEntity) result.getExecution();
    assertEquals(activityId, entity.getActivityId());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Aggregations

ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)170 Deployment (org.camunda.bpm.engine.test.Deployment)42 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)17 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)16 Execution (org.camunda.bpm.engine.runtime.Execution)14 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)12 Task (org.camunda.bpm.engine.task.Task)12 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ArrayList (java.util.ArrayList)9 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)9 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)7 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5