org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public HistoryEvent createCaseActivityInstanceUpdateEvt(DelegateCaseExecution caseExecution) {
  final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;

  // create event instance
  HistoricCaseActivityInstanceEventEntity evt = loadCaseActivityInstanceEventEntity(caseExecutionEntity);

  // initialize event
  initCaseActivityInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_ACTIVITY_INSTANCE_UPDATE);

  if (caseExecutionEntity.getTask() != null) {
    evt.setTaskId(caseExecutionEntity.getTask().getId());
  }

  if (caseExecutionEntity.getSubProcessInstance() != null) {
    evt.setCalledProcessInstanceId(caseExecutionEntity.getSubProcessInstance().getId());
  }

  if (caseExecutionEntity.getSubCaseInstance() != null) {
    evt.setCalledCaseInstanceId(caseExecutionEntity.getSubCaseInstance().getId());
  }

  return evt;
}
 
Example #2
Source File: CommandContext.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void performOperation(final CmmnAtomicOperation executionOperation, final CaseExecutionEntity execution) {
  ProcessApplicationReference targetProcessApplication = getTargetProcessApplication(execution);

  if(requiresContextSwitch(targetProcessApplication)) {
    Context.executeWithinProcessApplication(new Callable<Void>() {
      public Void call() throws Exception {
        performOperation(executionOperation, execution);
        return null;
      }

    }, targetProcessApplication, new InvocationContext(execution));

  } else {
    try {
      Context.setExecutionContext(execution);
      LOG.debugExecutingAtomicOperation(executionOperation, execution);

      executionOperation.execute(execution);
    } finally {
      Context.removeExecutionContext();
    }
  }
}
 
Example #3
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
  "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseWithCompositeExpression.bpmn20.xml",
  "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
})
public void testCallCaseWithCompositeExpression() {
  // given
  // a deployed process definition and case definition

  // when
  String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();

  // then
  String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());

  // complete
  String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();

  complete(humanTaskId);
  close(subCaseInstance.getId());
  assertProcessEnded(superProcessInstanceId);
}
 
Example #4
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public HistoryEvent createCaseInstanceCloseEvt(DelegateCaseExecution caseExecution) {
  final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;

  // create event instance
  HistoricCaseInstanceEventEntity evt = loadCaseInstanceEventEntity(caseExecutionEntity);

  // initialize event
  initCaseInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_INSTANCE_CLOSE);

  // set end time
  evt.setEndTime(ClockUtil.getCurrentTime());

  if (evt.getStartTime() != null) {
    evt.setDurationInMillis(evt.getEndTime().getTime() - evt.getStartTime().getTime());
  }

  return evt;
}
 
Example #5
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsExpressionStartsWithHash.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testCallCaseAsExpressionStartsWithHash() {
  // given
  // a deployed process definition and case definition

  // when
  String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, Variables.createVariables().putValue(ONE_TASK_CASE, ONE_TASK_CASE)).getId();

  // then
  String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());

  // complete
  String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();

  complete(humanTaskId);
  close(subCaseInstance.getId());
  assertProcessEnded(superProcessInstanceId);
}
 
Example #6
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public CaseExecutionEntity createSubCaseInstance(CmmnCaseDefinition caseDefinition, String businessKey) {
  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) caseDefinition.createCaseInstance(businessKey);

  // inherit the tenant-id from the case definition
  String tenantId = ((CaseDefinitionEntity) caseDefinition).getTenantId();
  if (tenantId != null) {
    subCaseInstance.setTenantId(tenantId);
  }
  else {
    // if case definition has no tenant id, inherit this process instance's tenant id
    subCaseInstance.setTenantId(this.tenantId);
  }

  // manage bidirectional super-process-sub-case-instances relation
  subCaseInstance.setSuperExecution(this);
  setSubCaseInstance(subCaseInstance);

  fireHistoricActivityInstanceUpdate();

  return subCaseInstance;
}
 
Example #7
Source File: VariableInstanceEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Class> getReferencedEntitiesIdAndClass() {
  Map<String, Class> referenceIdAndClass = new HashMap<>();

  if (processInstanceId != null){
    referenceIdAndClass.put(processInstanceId, ExecutionEntity.class);
  }
  if (executionId != null){
    referenceIdAndClass.put(executionId, ExecutionEntity.class);
  }
  if (caseInstanceId != null){
    referenceIdAndClass.put(caseInstanceId, CaseExecutionEntity.class);
  }
  if (caseExecutionId != null){
    referenceIdAndClass.put(caseExecutionId, CaseExecutionEntity.class);
  }
  if (getByteArrayValueId() != null){
    referenceIdAndClass.put(getByteArrayValueId(), ByteArrayEntity.class);
  }

  return referenceIdAndClass;
}
 
Example #8
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testCallCaseAsConstant.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testCallCaseAsConstant() {
  // given
  // a deployed process definition and case definition

  // when
  String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY).getId();

  // then
  String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());

  // complete
  String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();

  complete(humanTaskId);
  close(subCaseInstance.getId());
  assertProcessEnded(superProcessInstanceId);
}
 
Example #9
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initCaseActivityInstanceEvent(HistoricCaseActivityInstanceEventEntity evt, CaseExecutionEntity caseExecutionEntity, HistoryEventTypes eventType) {
  evt.setId(caseExecutionEntity.getId());
  evt.setParentCaseActivityInstanceId(caseExecutionEntity.getParentId());
  evt.setEventType(eventType.getEventName());
  evt.setCaseDefinitionId(caseExecutionEntity.getCaseDefinitionId());
  evt.setCaseInstanceId(caseExecutionEntity.getCaseInstanceId());
  evt.setCaseExecutionId(caseExecutionEntity.getId());
  evt.setCaseActivityInstanceState(caseExecutionEntity.getState());

  evt.setRequired(caseExecutionEntity.isRequired());

  evt.setCaseActivityId(caseExecutionEntity.getActivityId());
  evt.setCaseActivityName(caseExecutionEntity.getActivityName());
  evt.setCaseActivityType(caseExecutionEntity.getActivityType());

  evt.setTenantId(caseExecutionEntity.getTenantId());
}
 
Example #10
Source File: GetCaseExecutionVariableCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
  ensureNotNull("caseExecutionId", caseExecutionId);
  ensureNotNull("variableName", variableName);

  CaseExecutionEntity caseExecution = commandContext
    .getCaseExecutionManager()
    .findCaseExecutionById(caseExecutionId);

  ensureNotNull(CaseExecutionNotFoundException.class, "case execution " + caseExecutionId + " doesn't exist", "caseExecution", caseExecution);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadCaseInstance(caseExecution);
  }

  Object value;

  if (isLocal) {
    value = caseExecution.getVariableLocal(variableName);
  } else {
    value = caseExecution.getVariable(variableName);
  }

  return value;
}
 
Example #11
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void setCaseExecution(CaseExecutionEntity caseExecution) {
  if (caseExecution!=null) {

    this.caseExecution = caseExecution;
    this.caseExecutionId = this.caseExecution.getId();
    this.caseInstanceId = this.caseExecution.getCaseInstanceId();
    this.caseDefinitionId = this.caseExecution.getCaseDefinitionId();
    this.tenantId = this.caseExecution.getTenantId();

  } else {
    this.caseExecution = null;
    this.caseExecutionId = null;
    this.caseInstanceId = null;
    this.caseDefinitionId = null;
    this.tenantId = null;

  }
}
 
Example #12
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Class> getReferencedEntitiesIdAndClass() {
  Map<String, Class> referenceIdAndClass = new HashMap<>();

  if (processDefinitionId != null) {
    referenceIdAndClass.put(processDefinitionId, ProcessDefinitionEntity.class);
  }
  if (processInstanceId != null) {
    referenceIdAndClass.put(processInstanceId, ExecutionEntity.class);
  }
  if (executionId != null) {
    referenceIdAndClass.put(executionId, ExecutionEntity.class);
  }
  if (caseDefinitionId != null) {
    referenceIdAndClass.put(caseDefinitionId, CaseDefinitionEntity.class);
  }
  if (caseExecutionId != null) {
    referenceIdAndClass.put(caseExecutionId, CaseExecutionEntity.class);
  }

  return referenceIdAndClass;
}
 
Example #13
Source File: CaseDefinitionIdHistoryUpdateTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void createCaseExecution(final CaseExecutionEntity caseExecutionEntity) {
  processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<Void>() {
    @Override
    public Void execute(CommandContext commandContext) {
      commandContext.getCaseExecutionManager().insertCaseExecution(caseExecutionEntity);
      return null;
    }
  });
}
 
Example #14
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputDifferentBusinessKey.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testInputDifferentBusinessKey() {
  // given
  String myBusinessKey = "myBusinessKey";
  String myOwnBusinessKey = "myOwnBusinessKey";

  VariableMap variables = Variables.createVariables().putValue(myOwnBusinessKey, myOwnBusinessKey);

  // when
  String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, variables, myBusinessKey).getId();

  // then
  String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
  assertEquals(myOwnBusinessKey, subCaseInstance.getBusinessKey());

  // complete ////////////////////////////////////////////////////////
  String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();

  complete(humanTaskId);
  close(subCaseInstance.getId());
  assertProcessEnded(superProcessInstanceId);
}
 
Example #15
Source File: CaseTaskTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * variable passed in manual activation - change process definition
 */
@Deployment(resources = {
    "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testInputDifferentBusinessKey.cmmn",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testInputDifferentBusinessKey() {
  // given
  String businessKey = "myBusinessKey";
  String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, businessKey).getId();
  String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();

  // when
  caseService
    .withCaseExecution(caseTaskId)
    .setVariable("myOwnBusinessKey", "myOwnBusinessKey")
    .manualStart();

  // then

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  String superCaseExecutionId = subCaseInstance.getSuperCaseExecutionId();
  CaseExecution superCaseExecution = queryCaseExecutionById(superCaseExecutionId);

  assertEquals(caseTaskId, superCaseExecutionId);
  assertEquals(superCaseInstanceId, superCaseExecution.getCaseInstanceId());
  assertEquals("myOwnBusinessKey", subCaseInstance.getBusinessKey());

  // complete ////////////////////////////////////////////////////////

  terminate(subCaseInstance.getId());
  close(subCaseInstance.getId());
  assertCaseEnded(subCaseInstance.getId());

  terminate(caseTaskId);
  close(superCaseInstanceId);
  assertCaseEnded(superCaseInstanceId);

}
 
Example #16
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void setSuperCaseExecution(CmmnExecution superCaseExecution) {
  this.superCaseExecution = (CaseExecutionEntity) superCaseExecution;

  if (superCaseExecution != null) {
    this.superCaseExecutionId = superCaseExecution.getId();
    this.caseInstanceId = superCaseExecution.getCaseInstanceId();
  } else {
    this.superCaseExecutionId = null;
    this.caseInstanceId = null;
  }
}
 
Example #17
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public HistoryEvent createCaseActivityInstanceCreateEvt(DelegateCaseExecution caseExecution) {
  final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;

  // create event instance
  HistoricCaseActivityInstanceEventEntity evt = newCaseActivityInstanceEventEntity(caseExecutionEntity);

  // initialize event
  initCaseActivityInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_ACTIVITY_INSTANCE_CREATE);

  // set start time
  evt.setCreateTime(ClockUtil.getCurrentTime());

  return evt;
}
 
Example #18
Source File: ProcessApplicationContextUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private static void loggContextSwitchDetails(CaseExecutionEntity execution) {

    final CoreExecutionContext<? extends CoreExecution> executionContext = Context.getCoreExecutionContext();
    // only log for first atomic op:
    if(executionContext == null ||( executionContext.getExecution() != execution) ) {
      ProcessApplicationManager processApplicationManager = Context.getProcessEngineConfiguration().getProcessApplicationManager();
      LOG.debugNoTargetProcessApplicationFoundForCaseExecution(execution, processApplicationManager);
    }

  }
 
Example #19
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public HistoryEvent createCaseInstanceUpdateEvt(DelegateCaseExecution caseExecution) {
  final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution;

  // create event instance
  HistoricCaseInstanceEventEntity evt = loadCaseInstanceEventEntity(caseExecutionEntity);

  // initialize event
  initCaseInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_INSTANCE_UPDATE);

  return evt;
}
 
Example #20
Source File: ProcessApplicationContextUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static ProcessApplicationReference getTargetProcessApplication(CoreExecution execution) {
  if (execution instanceof ExecutionEntity) {
    return getTargetProcessApplication((ExecutionEntity) execution);
  } else {
    return getTargetProcessApplication((CaseExecutionEntity) execution);
  }
}
 
Example #21
Source File: CaseDefinitionIdUpdateTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testUpdateCaseDefinitionIdInCaseExecutionEntity() {
  // given
  final CaseDefinitionEntity caseDefinitionEntity1 = prepareCaseDefinition(UUID.randomUUID().toString());
  final CaseDefinitionEntity caseDefinitionEntity2 = prepareCaseDefinition(UUID.randomUUID().toString());

  final CaseExecutionEntity caseExecutionEntity = prepareCaseExecution(caseDefinitionEntity1);

  assertThat(caseExecutionEntity.getCaseDefinitionId()).isEqualTo(caseDefinitionEntity1.getId());

  createCaseExecution(caseExecutionEntity);
  final CaseExecutionEntity createdCaseExecution = findCaseExecution(caseExecutionEntity.getId());

  assertThat(createdCaseExecution).isNotNull();

  createdCaseExecution.setCaseDefinition(caseDefinitionEntity2);

  assertThat(createdCaseExecution.getCaseDefinitionId()).isEqualTo(caseDefinitionEntity2.getId());

  // when
  update(createdCaseExecution);

  // then
  final CaseExecutionEntity updatedCaseExecution = findCaseExecution(createdCaseExecution.getId());
  assertThat(updatedCaseExecution.getCaseDefinitionId()).isEqualTo(caseDefinitionEntity2.getId());

  deleteCaseExecution(updatedCaseExecution);
  deleteCaseDefinition(caseDefinitionEntity1);
  deleteCaseDefinition(caseDefinitionEntity2);
}
 
Example #22
Source File: VariableScopeElResolver.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public Object getValue(ELContext context, Object base, Object property)  {

    Object object = context.getContext(VariableScope.class);
    if(object != null) {
      VariableScope variableScope = (VariableScope) object;
      if (base == null) {
        String variable = (String) property; // according to javadoc, can only be a String

        if( (EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity)
                || (TASK_KEY.equals(property) && variableScope instanceof TaskEntity)
                || (variableScope instanceof CaseExecutionEntity
                && (CASE_EXECUTION_KEY.equals(property) || EXECUTION_KEY.equals(property))) ) {
          context.setPropertyResolved(true);
          return variableScope;
        } else if (EXECUTION_KEY.equals(property) && variableScope instanceof TaskEntity) {
          context.setPropertyResolved(true);
          return ((TaskEntity) variableScope).getExecution();
        } else if(LOGGED_IN_USER_KEY.equals(property)){
          context.setPropertyResolved(true);
          return Context.getCommandContext().getAuthenticatedUserId();
        } else {
          if (variableScope.hasVariable(variable)) {
            context.setPropertyResolved(true); // if not set, the next elResolver in the CompositeElResolver will be called
            return variableScope.getVariable(variable);
          }
        }
      }
    }

    // property resolution (eg. bean.value) will be done by the BeanElResolver (part of the CompositeElResolver)
    // It will use the bean resolved in this resolver as base.

    return null;
  }
 
Example #23
Source File: VariableInstanceEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public CaseExecutionEntity getCaseExecution() {
  if (caseExecutionId != null) {
    return Context
        .getCommandContext()
        .getCaseExecutionManager()
        .findCaseExecutionById(caseExecutionId);
  }
  return null;
}
 
Example #24
Source File: DefaultCallableElementTenantIdProvider.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Object getValue(VariableScope execution) {
  if (execution instanceof ExecutionEntity) {
    return getProcessDefinitionTenantId((ExecutionEntity) execution);

  } else if (execution instanceof CaseExecutionEntity) {
    return getCaseDefinitionTenantId((CaseExecutionEntity) execution);

  } else {
    throw new ProcessEngineException("Unexpected execution of type " + execution.getClass().getName());
  }
}
 
Example #25
Source File: CaseCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {
    "org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testInputBusinessKey.bpmn20.xml",
    "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn"
  })
public void testInputBusinessKey() {
  // given
  String businessKey = "myBusinessKey";

  // when
  String superProcessInstanceId = startProcessInstanceByKey(PROCESS_DEFINITION_KEY, null, businessKey).getId();

  // then
  String callActivityId = queryExecutionByActivityId(CALL_ACTIVITY_ID).getId();

  CaseExecutionEntity subCaseInstance = (CaseExecutionEntity) queryOneTaskCaseInstance();
  assertNotNull(subCaseInstance);

  assertEquals(callActivityId, subCaseInstance.getSuperExecutionId());
  assertEquals(businessKey, subCaseInstance.getBusinessKey());

  // complete ////////////////////////////////////////////////////////
  String humanTaskId = queryCaseExecutionByActivityId(HUMAN_TASK_ID).getId();

  complete(humanTaskId);
  close(subCaseInstance.getId());
  assertProcessEnded(superProcessInstanceId);
}
 
Example #26
Source File: CaseCallActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
  ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope();

  // A call activity is typically scope and since we guarantee stability of scope executions during migration,
  // the superExecution link does not have to be maintained during migration.
  // There are some exceptions, though: A multi-instance call activity is not scope and therefore
  // does not have a dedicated scope execution. In this case, the link to the super execution
  // must be maintained throughout migration
  if (!callActivity.isScope()) {
    ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution();
    CaseExecutionEntity calledCaseInstance = callActivityExecution.getSubCaseInstance();
    migratingInstance.addMigratingDependentInstance(new MigratingCalledCaseInstance(calledCaseInstance));
  }
}
 
Example #27
Source File: VariableInstanceEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void setCaseExecution(CaseExecutionEntity caseExecution) {
  if (caseExecution != null) {
    this.caseInstanceId = caseExecution.getCaseInstanceId();
    this.caseExecutionId = caseExecution.getId();
    this.tenantId = caseExecution.getTenantId();
  }
  else {
    this.caseInstanceId = null;
    this.caseExecutionId = null;
    this.tenantId = null;
  }
}
 
Example #28
Source File: DefaultCmmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initCaseInstanceEvent(HistoricCaseInstanceEventEntity evt, CaseExecutionEntity caseExecutionEntity, HistoryEventTypes eventType) {
  evt.setId(caseExecutionEntity.getCaseInstanceId());
  evt.setEventType(eventType.getEventName());
  evt.setCaseDefinitionId(caseExecutionEntity.getCaseDefinitionId());
  evt.setCaseInstanceId(caseExecutionEntity.getCaseInstanceId());
  evt.setCaseExecutionId(caseExecutionEntity.getId());
  evt.setBusinessKey(caseExecutionEntity.getBusinessKey());
  evt.setState(caseExecutionEntity.getState());
  evt.setTenantId(caseExecutionEntity.getTenantId());
}
 
Example #29
Source File: DefaultDmnHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected HistoricDecisionInstanceEntity createDecisionEvaluatedEvt(DmnDecisionLogicEvaluationEvent evaluationEvent, CaseExecutionEntity execution) {
  // create event instance
  HistoricDecisionInstanceEntity event = newDecisionInstanceEventEntity(execution, evaluationEvent);
  // initialize event
  initDecisionInstanceEvent(event, evaluationEvent, HistoryEventTypes.DMN_DECISION_EVALUATE);
  setReferenceToCaseInstance(event, execution);

  DecisionDefinition decisionDefinition = (DecisionDefinition) evaluationEvent.getDecision();
  String tenantId = execution.getTenantId();
  if (tenantId == null) {
    tenantId = provideTenantId(decisionDefinition, event);
  }
  event.setTenantId(tenantId);
  return event;
}
 
Example #30
Source File: CaseDefinitionIdUpdateTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private CaseExecutionEntity findCaseExecution(final String id) {
  return processEngineConfiguration.getCommandExecutorTxRequiresNew().execute(new Command<CaseExecutionEntity>() {
    @Override
    public CaseExecutionEntity execute(CommandContext commandContext) {
      return commandContext.getCaseExecutionManager().findCaseExecutionById(id);
    }
  });
}