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

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


      return execution.getProcessInstance();
     
    } else {
     
      ActivityImpl currentActivity = execution.getActivity();     
      ExecutionEntity candiadateExecution = null;
      ExecutionEntity originalExecution = execution;
     
      while (execution != null) {
        currentActivity = execution.getActivity();
        if (scopeActivity.getActivities().contains(currentActivity) /* does not search rec*/
                || scopeActivity.equals(currentActivity)) {
          // found a candidate execution; lets still check whether we find an
          // execution which is also sitting in an activity part of this scope
          // higher up the hierarchy
          candiadateExecution = execution;       
        } else if (currentActivity!= null
                && currentActivity.contains((ActivityImpl)scopeActivity) /*searches rec*/) {
          // now we're too "high", the candidate execution is the one.
          break;
        }
         
        execution = execution.getParent();
      }
     
      // if activity is scope, we need to get the parent at least:
      if(originalExecution == candiadateExecution
              && originalExecution.getActivity().isScope()
              && !originalExecution.getActivity().equals(scopeActivity)) {
        candiadateExecution = originalExecution.getParent();
      }     
     
      return candiadateExecution;
    }
  }
View Full Code Here


   */
  public static void throwCompensationEvent(List<CompensateEventSubscriptionEntity> eventSubscriptions, ActivityExecution execution, boolean async) {

    // first spawn the compensating executions
    for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
      ExecutionEntity compensatingExecution = null;
      // check whether compensating execution is already created
      // (which is the case when compensating an embedded subprocess,
      // where the compensating execution is created when leaving the subprocess
      // and holds snapshot data).
      if(eventSubscription.getConfiguration() !=null) {
        compensatingExecution = Context.getCommandContext()
          .getExecutionEntityManager()
          .findExecutionById(eventSubscription.getConfiguration());
        // move the compensating execution under this execution:
        compensatingExecution.setParent((InterpretableExecution) execution);       
        compensatingExecution.setEventScope(false);
      } else {
        compensatingExecution = (ExecutionEntity) execution.createExecution();
        eventSubscription.setConfiguration(compensatingExecution.getId());
      }
      compensatingExecution.setConcurrent(true);  
    }
   
    // signal compensation events in reverse order of their 'created' timestamp
    Collections.sort(eventSubscriptions, new Comparator<EventSubscriptionEntity>() {
      public int compare(EventSubscriptionEntity o1, EventSubscriptionEntity o2) {
View Full Code Here

   * this allows us to "remember" the event subscriptions after finishing a
   * scope
   */
  public static void createEventScopeExecution(ExecutionEntity execution) {

    ExecutionEntity eventScope = ScopeUtil.findScopeExecutionForScope(execution, execution.getActivity().getParent());
   
    List<CompensateEventSubscriptionEntity> eventSubscriptions = execution.getCompensateEventSubscriptions();
   
    if(!eventSubscriptions.isEmpty()) {
     
      ExecutionEntity eventScopeExecution = eventScope.createExecution();
      eventScopeExecution.setActive(false);     
      eventScopeExecution.setConcurrent(false);
      eventScopeExecution.setEventScope(true);     
      eventScopeExecution.setActivity((ActivityImpl) execution.getActivity());
     
      execution.setConcurrent(false);
     
      // copy local variables to eventScopeExecution by value. This way,
      // the eventScopeExecution references a 'snapshot' of the local variables     
      Map<String, Object> variables = execution.getVariablesLocal();
      for (Entry<String, Object> variable : variables.entrySet()) {
        eventScopeExecution.setVariableLocal(variable.getKey(), variable.getValue());       
      }
     
      // set event subscriptions to the event scope execution:
      for (CompensateEventSubscriptionEntity eventSubscriptionEntity : eventSubscriptions) {
        eventSubscriptionEntity = eventSubscriptionEntity.moveUnder(eventScopeExecution);       
      }
           
      CompensateEventSubscriptionEntity eventSubscription = CompensateEventSubscriptionEntity.createAndInsert(eventScope);
      eventSubscription.setActivity(execution.getActivity());
      eventSubscription.setConfiguration(eventScopeExecution.getId());
     
    }
  }
View Full Code Here

  protected String errorCode;

  @Override
  public void onEvent(ActivitiEvent event) {
    if(isValidEvent(event)) {
      ExecutionEntity execution = null;
     
      if (Context.isExecutionContextActive()) {
        execution = Context.getExecutionContext().getExecution();
      } else if(event.getExecutionId() != null){
        // Get the execution based on the event's execution ID instead
View Full Code Here

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

  }

  public Void execute(CommandContext commandContext) {

    ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);

    if (processInstance == null) {
      throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
    }

    processInstance.addIdentityLink(userId, groupId, type);

    commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, true);

    return null;
View Full Code Here

  public Void execute(CommandContext commandContext) {
    if(processInstanceId == null) {
      throw new ActivitiIllegalArgumentException("processInstanceId is null");
    }
   
    ExecutionEntity execution = commandContext
      .getExecutionEntityManager()
      .findExecutionById(processInstanceId);
   
    if (execution==null) {
      throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
    }
   
    if(!execution.isProcessInstanceType()) {
      throw new ActivitiObjectNotFoundException("process instance " + processInstanceId +
          " doesn't exist, the given ID references an execution, though", ProcessInstance.class);
    }
   
    if (execution.isSuspended()) {
      throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");
    }
   
    // Actually set the name
    execution.setName(name);
   
    // Record the change in history
    commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstanceId, name);
   
    return null;
View Full Code Here

    this.processInstanceId = processInstanceId;
  }
 
  @SuppressWarnings({"unchecked", "rawtypes"})
  public List<IdentityLink> execute(CommandContext commandContext) {
    ExecutionEntity processInstance = commandContext
        .getExecutionEntityManager()
        .findExecutionById(processInstanceId);
     
    if (processInstance == null) {
      throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processInstanceId, ExecutionEntity.class);
    }
   
    return (List) processInstance.getIdentityLinks();
  }
View Full Code Here

      log.debug("Executing lock exclusive job {} {}", job.getId(), job.getExecutionId());
    }
   
    if (job.isExclusive()) {
      if (job.getExecutionId() != null) {
        ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(job.getExecutionId());
        if (execution != null) {
          commandContext.getExecutionEntityManager().updateProcessInstanceLockTime(execution.getProcessInstanceId());
        }
      }
    }
   
    return null;
View Full Code Here

    }
    if(variableName == null) {
      throw new ActivitiIllegalArgumentException("variableName is null");
    }
   
    ExecutionEntity execution = commandContext
      .getExecutionEntityManager()
      .findExecutionById(executionId);
   
    if (execution==null) {
      throw new ActivitiObjectNotFoundException("execution "+executionId+" doesn't exist", Execution.class);
    }
   
    boolean hasVariable = false;
   
    if (isLocal) {
      hasVariable = execution.hasVariableLocal(variableName);
    } else {
      hasVariable = execution.hasVariable(variableName);
    }
   
    return hasVariable;
  }
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.