Java Code Examples for org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getSuperExecution()

The following examples show how to use org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity#getSuperExecution() . 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: ModificationUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void handleChildRemovalInScope(ExecutionEntity removedExecution) {
  ActivityImpl activity = removedExecution.getActivity();
  if (activity == null) {
    if (removedExecution.getSuperExecution() != null) {
      removedExecution = removedExecution.getSuperExecution();
      activity = removedExecution.getActivity();
      if (activity == null) {
        return;
      }
    } else {
      return;
    }
  }
  ScopeImpl flowScope = activity.getFlowScope();

  PvmExecutionImpl scopeExecution = removedExecution.getParentScopeExecution(false);
  PvmExecutionImpl executionInParentScope = removedExecution.isConcurrent() ? removedExecution : removedExecution.getParent();

  if (flowScope.getActivityBehavior() != null && flowScope.getActivityBehavior() instanceof ModificationObserverBehavior) {
    // let child removal be handled by the scope itself
    ModificationObserverBehavior behavior = (ModificationObserverBehavior) flowScope.getActivityBehavior();
    behavior.destroyInnerInstance(executionInParentScope);
  }
  else {
    if (executionInParentScope.isConcurrent()) {
      executionInParentScope.remove();
      scopeExecution.tryPruneLastConcurrentChild();
      scopeExecution.forceUpdate();
    }
  }
}
 
Example 2
Source File: AbstractInstanceCancellationCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ExecutionEntity findSuperExecution(ExecutionEntity parentScopeExecution, ExecutionEntity topmostCancellableExecution){
  ExecutionEntity superExecution = null;
  if(parentScopeExecution == null) {
    superExecution = topmostCancellableExecution.getSuperExecution();

  }
  return superExecution;
}
 
Example 3
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initProcessInstanceEvent(HistoricProcessInstanceEventEntity evt, ExecutionEntity execution, HistoryEventType eventType) {

    String processDefinitionId = execution.getProcessDefinitionId();
    String processInstanceId = execution.getProcessInstanceId();
    String executionId = execution.getId();
    // the given execution is the process instance!
    String caseInstanceId = execution.getCaseInstanceId();
    String tenantId = execution.getTenantId();

    ProcessDefinitionEntity definition = execution.getProcessDefinition();
    String processDefinitionKey = null;
    if (definition != null) {
      processDefinitionKey = definition.getKey();
    }

    evt.setId(processInstanceId);
    evt.setEventType(eventType.getEventName());
    evt.setProcessDefinitionKey(processDefinitionKey);
    evt.setProcessDefinitionId(processDefinitionId);
    evt.setProcessInstanceId(processInstanceId);
    evt.setExecutionId(executionId);
    evt.setBusinessKey(execution.getProcessBusinessKey());
    evt.setCaseInstanceId(caseInstanceId);
    evt.setTenantId(tenantId);
    evt.setRootProcessInstanceId(execution.getRootProcessInstanceId());

    if (execution.getSuperCaseExecution() != null) {
      evt.setSuperCaseInstanceId(execution.getSuperCaseExecution().getCaseInstanceId());
    }
    if (execution.getSuperExecution() != null) {
      evt.setSuperProcessInstanceId(execution.getSuperExecution().getProcessInstanceId());
    }
  }
 
Example 4
Source File: DefaultHistoryEventProducer.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) {
  final ExecutionEntity executionEntity = (ExecutionEntity) execution;

  // create event instance
  HistoricProcessInstanceEventEntity evt = newProcessInstanceEventEntity(executionEntity);

  // initialize event
  initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_START);

  evt.setStartActivityId(executionEntity.getActivityId());
  evt.setStartTime(ClockUtil.getCurrentTime());

  // set super process instance id
  ExecutionEntity superExecution = executionEntity.getSuperExecution();
  if (superExecution != null) {
    evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId());
  }

  //state
  evt.setState(HistoricProcessInstance.STATE_ACTIVE);

  // set start user Id
  evt.setStartUserId(Context.getCommandContext().getAuthenticatedUserId());

  if (isHistoryRemovalTimeStrategyStart()) {
    if (isRootProcessInstance(evt)) {
      Date removalTime = calculateRemovalTime(evt);
      evt.setRemovalTime(removalTime);
    } else {
      provideRemovalTime(evt);
    }
  }

  return evt;
}
 
Example 5
Source File: AbstractDeleteProcessInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void deleteProcessInstance(
    final CommandContext commandContext,
    String processInstanceId,
    final String deleteReason,
    final boolean skipCustomListeners,
    final boolean externallyTerminated,
    final boolean skipIoMappings,
    boolean skipSubprocesses) {
  ensureNotNull(BadUserRequestException.class, "processInstanceId is null", "processInstanceId", processInstanceId);

  // fetch process instance
  ExecutionManager executionManager = commandContext.getExecutionManager();
  final ExecutionEntity execution = executionManager.findExecutionById(processInstanceId);

  if(!failIfNotExists && execution == null) {
    return;
  }

  ensureNotNull(BadUserRequestException.class, "No process instance found for id '" + processInstanceId + "'", "processInstance", execution);

  checkDeleteProcessInstance(execution, commandContext);

  // delete process instance
  commandContext
      .getExecutionManager()
      .deleteProcessInstance(processInstanceId, deleteReason, false, skipCustomListeners, externallyTerminated, skipIoMappings, skipSubprocesses);

  if (skipSubprocesses) {
    List<ProcessInstance> superProcesslist = commandContext.getProcessEngineConfiguration().getRuntimeService().createProcessInstanceQuery()
        .superProcessInstanceId(processInstanceId).list();
    triggerHistoryEvent(superProcesslist);
  }

  final ExecutionEntity superExecution = execution.getSuperExecution();
  if (superExecution != null) {
    commandContext.runWithoutAuthorization(new Callable<Void>() {
      public Void call() {
        ProcessInstanceModificationBuilderImpl builder = (ProcessInstanceModificationBuilderImpl) new ProcessInstanceModificationBuilderImpl(commandContext, superExecution.getProcessInstanceId(), deleteReason)
          .cancellationSourceExternal(externallyTerminated).cancelActivityInstance(superExecution.getActivityInstanceId());
        builder.execute(false, skipCustomListeners, skipIoMappings);
        return null;
      }
    });

  }

  // create user operation log
  commandContext.getOperationLogManager()
      .logProcessInstanceOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, processInstanceId,
          null, null, Collections.singletonList(PropertyChange.EMPTY_CHANGE));
}