Package org.activiti.engine.impl.persistence.entity

Examples of org.activiti.engine.impl.persistence.entity.ExecutionEntity


 
  @Override
  public void execute(ActivityExecution execution) throws Exception {
    final String activityRef = compensateEventDefinition.getActivityRef();
           
    ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope((ExecutionEntity)execution, (ActivityImpl)execution.getActivity());
   
    List<CompensateEventSubscriptionEntity> eventSubscriptions;
   
    if(activityRef != null) {         
      eventSubscriptions = scopeExecution.getCompensateEventSubscriptions(activityRef);
    } else {
      eventSubscriptions = scopeExecution.getCompensateEventSubscriptions();
    }
       
    if(eventSubscriptions.isEmpty()) {
      leave(execution);
    } else {
View Full Code Here


    }
    if(variableName == null) {
      throw new ActivitiException("variableName is null");
    }
   
    ExecutionEntity execution = commandContext
      .getExecutionManager()
      .findExecutionById(executionId);
   
    if (execution==null) {
      throw new ActivitiException("execution "+executionId+" doesn't exist");
    }
   
    Object value;
   
    if (isLocal) {
      value = execution.getVariableLocal(variableName);
    } else {
      value = execution.getVariable(variableName);
    }
   
    return value;
  }
View Full Code Here

  public Void execute(CommandContext commandContext) {
    // check that the new process definition is just another version of the same
    // process definition that the process instance is using
    ExecutionManager executionManager = commandContext.getExecutionManager();
    ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
      throw new ActivitiException("No process instance found for id = '" + processInstanceId + "'.");
    } else if (!processInstance.isProcessInstance()) {
      throw new ActivitiException(
        "A process instance id is required, but the provided id " +
        "'"+processInstanceId+"' " +
        "points to a child execution of process instance " +
        "'"+processInstance.getProcessInstanceId()+"'. " +
        "Please invoke the "+getClass().getSimpleName()+" with a root execution id.");
    }
    ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();

    DeploymentCache deploymentCache = Context
      .getProcessEngineConfiguration()
      .getDeploymentCache();
    ProcessDefinitionEntity currentProcessDefinition;
View Full Code Here

    int nrOfCompletedInstances = getLoopVariable(execution, NUMBER_OF_COMPLETED_INSTANCES) + 1;
    int nrOfActiveInstances = getLoopVariable(execution, NUMBER_OF_ACTIVE_INSTANCES) - 1;
   
    if (isExtraScopeNeeded()) {
      // In case an extra scope was created, it must be destroyed first before going further
      ExecutionEntity extraScope = (ExecutionEntity) execution;
      execution = execution.getParent();
      extraScope.remove();
    }
   
    setLoopVariable(execution.getParent(), NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
    setLoopVariable(execution.getParent(), NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances);
    logLoopDetails(execution, "instance completed", loopCounter, nrOfCompletedInstances, nrOfActiveInstances, nrOfInstances);
   
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    executionEntity.inactivate();
    executionEntity.getParent().forceUpdate();
   
    List<ActivityExecution> joinedExecutions = executionEntity.findInactiveConcurrentExecutions(execution.getActivity());
    if (joinedExecutions.size() == nrOfInstances || completionConditionSatisfied(execution)) {
     
      // Removing all active child executions (ie because completionCondition is true)
      List<ExecutionEntity> executionsToRemove = new ArrayList<ExecutionEntity>();
      for (ActivityExecution childExecution : executionEntity.getParent().getExecutions()) {
        if (childExecution.isActive()) {
          executionsToRemove.add((ExecutionEntity) childExecution);
        }
      }
      for (ExecutionEntity executionToRemove : executionsToRemove) {
        if (LOGGER.isLoggable(Level.FINE)) {
          LOGGER.fine("Execution " + executionToRemove + " still active, "
                  + "but multi-instance is completed. Removing this execution.");
        }
        executionToRemove.inactivate();
        executionToRemove.deleteCascade("multi-instance completed");
      }
      executionEntity.takeAll(executionEntity.getActivity().getOutgoingTransitions(), joinedExecutions);
    }
  }
View Full Code Here

      }
    }
  }
 
  private static ActivityExecution getSuperExecution(ActivityExecution execution) {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ExecutionEntity superExecution = executionEntity.getProcessInstance().getSuperExecution();
    if (superExecution != null && !superExecution.isScope()) {
      return superExecution.getParent();
    }
    return superExecution;
  }
View Full Code Here

    this.activityId = activityId;
  }
 
  @SuppressWarnings("unchecked")
  public void execute(ActivityExecution execution) throws Exception {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    ActivityImpl boundaryActivity = executionEntity.getProcessDefinition().findActivity(activityId);
    ActivityImpl interruptedActivity = executionEntity.getActivity();
   
    executionEntity.setActivity(boundaryActivity);
   
    List<PvmTransition> outgoingTransitions = boundaryActivity.getOutgoingTransitions();
    List<ExecutionEntity> interruptedExecutions = null;
   
    if (interrupting) {
      if (executionEntity.getSubProcessInstance()!=null) {
        executionEntity.getSubProcessInstance().deleteCascade(executionEntity.getDeleteReason());
      }
     
      interruptedExecutions = new ArrayList<ExecutionEntity>(executionEntity.getExecutions());
      for (ExecutionEntity interruptedExecution: interruptedExecutions) {
        interruptedExecution.deleteCascade("interrupting boundary event '"+execution.getActivity().getId()+"' fired");
      }
     
      execution.takeAll(outgoingTransitions, (List) interruptedExecutions);
    }
    else {
      // non interrupting event, introduced with BPMN 2.0, we need to create a new execution in this case
     
      // create a new execution and move it out from the timer activity
      ExecutionEntity concurrentRoot = executionEntity.getParent().isConcurrent() ? executionEntity.getParent() : executionEntity;
      ExecutionEntity outgoingExecution = concurrentRoot.createExecution();
   
      outgoingExecution.setActive(true);
      outgoingExecution.setScope(false);
      outgoingExecution.setConcurrent(true);
     
      outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
      outgoingExecution.remove();
      // now we have to move the execution back to the real activity
      // since the execution stays there (non interrupting) and it was
      // set to the boundary event before
      executionEntity.setActivity(interruptedActivity);     
    }
View Full Code Here

  public T execute(CommandContext commandContext) {
    if(executionId == null) {
      throw new ActivitiException("executionId is null");
    }
   
    ExecutionEntity execution = commandContext
      .getExecutionManager()
      .findExecutionById(executionId);
   
    if (execution==null) {
      throw new ActivitiException("execution "+executionId+" doesn't exist");
    }
   
    if (execution.isSuspended()) {
      throw new ActivitiException(getSuspendedExceptionMessage());
    }
   
    return execute(commandContext, execution);
  }
View Full Code Here

  }

  protected void createCompensateEventSubscription(ActivityExecution execution) {
    String compensationHandlerId = (String) execution.getActivity().getProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID);
   
    ExecutionEntity executionEntity = (ExecutionEntity) execution;   
    ActivityImpl compensationHandlder = executionEntity.getProcessDefinition().findActivity(compensationHandlerId);
    PvmScope scopeActivitiy = compensationHandlder.getParent();
    ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope(executionEntity, scopeActivitiy);     

    CompensateEventSubscriptionEntity compensateEventSubscriptionEntity = CompensateEventSubscriptionEntity.createAndInsert(scopeExecution);
    compensateEventSubscriptionEntity.setActivity(compensationHandlder);       
  }
View Full Code Here

  /**
   * Record the id of a the task associated with a historic activity, if activity history is enabled.
   */
  public void recordTaskId(TaskEntity task) {
    if(isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
      ExecutionEntity execution = task.getExecution();
      if (execution != null) {
        HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(execution);
        if(historicActivityInstance != null) {
          historicActivityInstance.setTaskId(task.getId());
        }
View Full Code Here

    String configuration = eventSubscription.getConfiguration();
    if(configuration == null) {
      throw new ActivitiException("Compensating execution not set for compensate event subscription with id "+eventSubscription.getId());     
    }
   
    ExecutionEntity compensatingExecution = commandContext.getExecutionManager()
            .findExecutionById(configuration);
  
    ActivityImpl compensationHandler = eventSubscription.getActivity();
   
    if((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null
        ||!(Boolean)compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION))
            && compensationHandler.isScope()) {     
  
      // descend into scope:
      List<CompensateEventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();     
      ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
                 
    } else {
      try {

        compensatingExecution.setActivity(compensationHandler);
       
        // executing the atomic operation makes sure activity start events are fired
        compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);
       
      }catch (Exception e) {
        throw new ActivitiException("Error while handling compensation event "+eventSubscription, e);
      }
           
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.persistence.entity.ExecutionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.