Search in sources :

Example 81 with ExecutionEntity

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

the class ExecutionCachedEntityStateTest method testProcessInstanceIncident.

@Deployment
public void testProcessInstanceIncident() {
    runtimeService.startProcessInstanceByKey("testProcess");
    ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
    assertEquals(0, processInstance.getCachedEntityStateRaw());
    final ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
    assertEquals(0, execution.getCachedEntityStateRaw());
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            IncidentContext incidentContext = new IncidentContext();
            incidentContext.setExecutionId(execution.getId());
            IncidentEntity.createAndInsertIncident("foo", incidentContext, null);
            return null;
        }
    });
    ExecutionEntity execution2 = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
    assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.INCIDENT_STATE_BIT), execution2.getCachedEntityStateRaw());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 82 with ExecutionEntity

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

the class ExecutionCachedEntityStateTest method testExecutionTasksMi.

@Deployment
public void testExecutionTasksMi() {
    runtimeService.startProcessInstanceByKey("testProcess");
    ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
    assertEquals(0, processInstance.getCachedEntityStateRaw());
    List<Execution> executions = runtimeService.createExecutionQuery().activityId("userTask").list();
    for (Execution execution : executions) {
        int cachedEntityStateRaw = ((ExecutionEntity) execution).getCachedEntityStateRaw();
        if (!((ExecutionEntity) execution).isScope()) {
            assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.TASKS_STATE_BIT) | BitMaskUtil.getMaskForBit(ExecutionEntity.VARIABLES_STATE_BIT), cachedEntityStateRaw);
        } else {
            assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.VARIABLES_STATE_BIT), cachedEntityStateRaw);
        }
    }
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 83 with ExecutionEntity

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

the class ExecutionCachedEntityStateTest method testExecutionJobsParallel.

@Deployment
public void testExecutionJobsParallel() {
    runtimeService.startProcessInstanceByKey("testProcess");
    ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
    assertEquals(0, processInstance.getCachedEntityStateRaw());
    ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("userTask").singleResult();
    assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.JOBS_STATE_BIT), execution.getCachedEntityStateRaw());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 84 with ExecutionEntity

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

the class ExecutionCachedEntityStateTest method testProcessInstanceEventSubscriptions.

@Deployment
public void testProcessInstanceEventSubscriptions() {
    runtimeService.startProcessInstanceByKey("testProcess");
    ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
    assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.EVENT_SUBSCRIPTIONS_STATE_BIT), processInstance.getCachedEntityStateRaw());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 85 with ExecutionEntity

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

the class ProcessScope method get.

public Object get(String name, ObjectFactory<?> objectFactory) {
    ExecutionEntity executionEntity = null;
    try {
        logger.fine("returning scoped object having beanName '" + name + "' for conversation ID '" + this.getConversationId() + "'. ");
        ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance();
        executionEntity = (ExecutionEntity) processInstance;
        Object scopedObject = executionEntity.getVariable(name);
        if (scopedObject == null) {
            scopedObject = objectFactory.getObject();
            if (scopedObject instanceof ScopedObject) {
                ScopedObject sc = (ScopedObject) scopedObject;
                scopedObject = sc.getTargetObject();
                logger.fine("de-referencing " + ScopedObject.class.getName() + "#targetObject before persisting variable");
            }
            persistVariable(name, scopedObject);
        }
        return createDirtyCheckingProxy(name, scopedObject);
    } catch (Throwable th) {
        logger.warning("couldn't return value from process scope! " + ExceptionUtils.getFullStackTrace(th));
    } finally {
        if (executionEntity != null) {
            logger.fine("set variable '" + name + "' on executionEntity# " + executionEntity.getId());
        }
    }
    return null;
}
Also used : ScopedObject(org.springframework.aop.scope.ScopedObject) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ScopedObject(org.springframework.aop.scope.ScopedObject)

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