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

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


    }
    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);
    }
   
    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
    ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager();
    ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
      throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class);
    } else if (!processInstance.isProcessInstanceType()) {
      throw new ActivitiIllegalArgumentException(
        "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();

    DeploymentManager deploymentCache = commandContext
      .getProcessEngineConfiguration()
      .getDeploymentManager();
    ProcessDefinitionEntity currentProcessDefinition;
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.getExecutionEntityManager()
            .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 {

        if(commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
          commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
              ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_COMPENSATE,
                  compensationHandler.getId(),
                  (String) compensationHandler.getProperty("name"),
                  compensatingExecution.getId(),
                  compensatingExecution.getProcessInstanceId(),
                  compensatingExecution.getProcessDefinitionId(),
                  (String) compensatingExecution.getActivity().getProperties().get("type"),
                  compensatingExecution.getActivity().getActivityBehavior().getClass().getCanonicalName()));
        }
        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

*/
public abstract class AbstractEventHandler implements EventHandler {

  public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {

    ExecutionEntity execution = eventSubscription.getExecution();
    ActivityImpl activity = eventSubscription.getActivity();

    if (activity == null) {
      throw new ActivitiException("Error while sending signal for event subscription '" + eventSubscription.getId() + "': "
              + "no activity associated with event subscription");
    }

    if (payload instanceof Map) {
      @SuppressWarnings("unchecked")
      Map<String, Object> processVariables = (Map<String, Object>) payload;
      execution.setVariables(processVariables);
    }

    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    if (activityBehavior instanceof BoundaryEventActivityBehavior
            || activityBehavior instanceof EventSubProcessStartEventActivityBehavior) {

      try {

        activityBehavior.execute(execution);

      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new ActivitiException("exception while sending signal for event subscription '" + eventSubscription + "':" + e.getMessage(), e);
      }

    } else { // not boundary
      if (!activity.equals( execution.getActivity() )) {
        execution.setActivity(activity);
      }
      execution.signal(eventSubscription.getEventName(), payload);
    }

  }
View Full Code Here

      ActivityImpl startActivity = processDefinition.findActivity(eventSubscription.getActivityId());
      if (startActivity == null) {
        throw new ActivitiException("Could no handle signal: no start activity found with id " + eventSubscription.getActivityId());
      }
      ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
      if (processInstance == null) {
        throw new ActivitiException("Could not handle signal: no process instance started");
      }
     
      if (payload != null) {
        if (payload instanceof Map) {
          Map<String, Object> variables = (Map<String, Object>) payload;
          processInstance.setVariables(variables);
        }
      }
     
      processInstance.start();
    } else {
      throw new ActivitiException("Invalid signal handling: no execution nor process definition set");
    }
  }
View Full Code Here

    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    List<Execution> list = runtimeService.createExecutionQuery().processDefinitionKey("process1").list();
    for (Execution execution : list) {
      ExecutionEntity entity = (ExecutionEntity) execution;
      System.out.println("executionId=" + execution.getId() + "\tPID=" + execution.getProcessInstanceId() + "\t"
          + entity.getProcessDefinitionId() + "\t execution-parnet_id=" + entity.getParentId());
    }

    List<ProcessInstance> list2 = runtimeService.createProcessInstanceQuery().processDefinitionKey("process1").list();
    System.out.println("processInstance.size=" + list2.size());
View Full Code Here

  public Map<String, Object> 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");
    }

    Map<String, Object> executionVariables;
    if (isLocal) {
      executionVariables = execution.getVariablesLocal();
    } else {
      executionVariables = execution.getVariables();
    }
   
    if (variableNames != null && variableNames.size() > 0) {
      // if variableNames is not empty, return only variable names mentioned in it
      Map<String, Object> tempVariables = new HashMap<String, Object>();
View Full Code Here

      throw new ActivitiException("Cannot start process instance. Process definition "
              + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }

    // Start the process instance
    ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey);
    if (variables!=null) {
      processInstance.setVariables(variables);
    }
    processInstance.start();
   
    return processInstance;
  }
View Full Code Here

    this.processEngine = processEngine;
  }

  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;
  }
View Full Code Here

    return proxyFactoryBean.getProxy(this.classLoader);
  }

  private void persistVariable(String variableName, Object scopedObject) {
    ProcessInstance processInstance = Context.getExecutionContext().getProcessInstance();
    ExecutionEntity executionEntity = (ExecutionEntity) processInstance;
    Assert.isTrue(scopedObject instanceof Serializable, "the scopedObject is not " + Serializable.class.getName() + "!");
    executionEntity.setVariable(variableName, scopedObject);
  }
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.