Package org.jbpm.context.exe

Examples of org.jbpm.context.exe.ContextInstance


    this.engine = engine;
    this.id = id;
    log().t("instance",id,workflow.getName(),variables);
    processInstance = new ProcessInstance(workflow.getProcessDefinition());
       
    ContextInstance contextInstance = processInstance.getContextInstance();
    if (variables != null) contextInstance.setVariables(variables);
    contextInstance.setProcessInstance(processInstance);
//    contextInstance.setVariable(JBpmContext.VAR_ENGINE, engine.getBpm());
    contextInstance.setVariable(JBpmContext.VAR_INSTANCE_ID,id);
   
    myContext = new JBpmContext(getBpm(),contextInstance);
  }
View Full Code Here


      Token root = processInstance.getRootToken();
      if (!action.equals(root.getNode().getName()))
        throw new BpmException(this,"action is not current " + action);
    }
   
    ContextInstance contextInstance = processInstance.getContextInstance();
    if (parameters != null) contextInstance.setVariables(parameters);
    if (name == null) processInstance.signal(); else processInstance.signal(name);
  }
View Full Code Here

      Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));

      if (taskControllerDelegation != null) {
        TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
        ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
        Token token = taskInstance.getToken();

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerInitialization(taskControllerHandler, taskInstance, contextInstance, token);
        } else {
          taskControllerHandler.initializeTaskVariables(taskInstance, contextInstance, token);
        }

      } else {
        Token token = taskInstance.getToken();
        ProcessInstance processInstance = token.getProcessInstance();
        ContextInstance contextInstance = processInstance.getContextInstance();

        if (variableAccesses != null) {
          for (VariableAccess variableAccess : variableAccesses) {
            String mappedName = variableAccess.getMappedName();
            if (variableAccess.isReadable()) {
              String variableName = variableAccess.getVariableName();
              Object value = contextInstance.getVariable(variableName, token);
              log.debug("creating task instance variable '" + mappedName + "' from process variable '" + variableName + "', value '" + value + "'");
              taskInstance.setVariableLocally(mappedName, value);
            } else {
              log.debug("creating task instance local variable '" + mappedName + "'. initializing with null value.");
              taskInstance.setVariableLocally(mappedName, null);
View Full Code Here

      Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));

      if (taskControllerDelegation != null) {
        TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
        ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
        ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
        Token token = taskInstance.getToken();

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission(taskControllerHandler, taskInstance, contextInstance, token);
        } else {
          taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token);
        }

      } else {

        Token token = taskInstance.getToken();
        ProcessInstance processInstance = token.getProcessInstance();
        ContextInstance contextInstance = processInstance.getContextInstance();

        if (variableAccesses != null) {
          String missingTaskVariables = null;
          for (VariableAccess variableAccess : variableAccesses) {
            String mappedName = variableAccess.getMappedName();
            // first check if the required variableInstances are present
            if ((variableAccess.isRequired()) && (!taskInstance.hasVariableLocally(mappedName))) {
              if (missingTaskVariables == null) {
                missingTaskVariables = mappedName;
              } else {
                missingTaskVariables += ", " + mappedName;
              }
            }
          }

          // if there are missing, required parameters, throw an
          // IllegalArgumentException
          if (missingTaskVariables != null) {
            throw new IllegalArgumentException("missing task variables: " + missingTaskVariables);
          }

          for (VariableAccess variableAccess : variableAccesses) {
            String mappedName = variableAccess.getMappedName();
            String variableName = variableAccess.getVariableName();
            if (variableAccess.isWritable()) {
              Object value = taskInstance.getVariable(mappedName);
              if (value != null) {
                log.debug("submitting task variable '" + mappedName + "' to process variable '" + variableName + "', value '" + value + "'");
                contextInstance.setVariable(variableName, value, token);
              }
            }
          }
        }
      }
View Full Code Here

    inputMap.put("node", executionContext.getNode());
    inputMap.put("task", executionContext.getTask());
    inputMap.put("taskInstance", executionContext.getTaskInstance());

    // if no readable variableInstances are specified,
    ContextInstance contextInstance = executionContext.getContextInstance();
    if (!hasReadableVariable()) {
      // we copy all the variableInstances of the context into the interpreter
      Map<String, Object> variables = contextInstance.getVariables(token);
      if (variables != null) {
        for (Map.Entry<String, Object> entry : variables.entrySet()) {
          String variableName = entry.getKey();
          Object variableValue = entry.getValue();
          inputMap.put(variableName, variableValue);
        }
      }

    }
    else {
      // we only copy the specified variableInstances into the interpreter
      for (VariableAccess variableAccess : variableAccesses) {
        if (variableAccess.isReadable()) {
          String variableName = variableAccess.getVariableName();
          String mappedName = variableAccess.getMappedName();
          Object variableValue = contextInstance.getVariable(variableName, token);
          inputMap.put(mappedName, variableValue);
        }
      }
    }
View Full Code Here

  }

  void setVariables(Map<String, Object> outputMap, ExecutionContext executionContext) {
    if ((outputMap != null) && (!outputMap.isEmpty()) && (executionContext != null)) {
      Map<String, String> variableNames = getVariableNames();
      ContextInstance contextInstance = executionContext.getContextInstance();
      Token token = executionContext.getToken();

      for (Map.Entry<String, String> entry : variableNames.entrySet()) {
        String mappedName = entry.getKey();
        String variableName = entry.getValue();
        contextInstance.setVariable(variableName, outputMap.get(mappedName), token);
      }
    }
  }
View Full Code Here

      value = executionContext.getTaskInstance().getVariable(name);

    }
    else
    {
      ContextInstance contextInstance = executionContext.getContextInstance();
      TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
      Token token = executionContext.getToken();

      if ((contextInstance != null) && (contextInstance.hasVariable(name, token)))
      {
        value = contextInstance.getVariable(name, token);
      }
      else if ((contextInstance != null) && (contextInstance.hasTransientVariable(name)))
      {
        value = contextInstance.getTransientVariable(name);
      }
      else if ((taskMgmtInstance != null) && (taskMgmtInstance.getSwimlaneInstances() != null) && (taskMgmtInstance.getSwimlaneInstances().containsKey(name)))
      {
        SwimlaneInstance swimlaneInstance = taskMgmtInstance.getSwimlaneInstance(name);
        value = (swimlaneInstance != null ? swimlaneInstance.getActorId() : null);
View Full Code Here

                final TaskInstance task = (TaskInstance) entity;
                oldValue = task.getVariable(name);
                task.deleteVariable(name);
            } else if (entity instanceof Token) {
                final Token token = (Token) entity;
                final ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
                oldValue = contextInstance.getVariable(name, token);
                contextInstance.deleteVariable(name, token);
            } else if (entity instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) entity;
                final ContextInstance contextInstance = processInstance.getContextInstance();
                oldValue = contextInstance.getVariable(name);
                contextInstance.deleteVariable(name);
            } else {
                context.setError("Error removing variable", "The value given for the 'entity' attribute is not a task, token, or process instance");
                return;
            }
            if (oldValueTargetExpression != null) {
View Full Code Here

      // if there is no task controller
    }
    else if ((token != null) && (token.getProcessInstance() != null)) {
      // the default behaviour is that all task-local variables are flushed to the process
      if (variableInstances != null) {
        ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
        for (VariableInstance variableInstance : variableInstances.values()) {
          log.debug("flushing variable '"
              + variableInstance.getName()
              + "' from task '"
              + name
              + "' to process variables");
          // This might be optimized, but this was the simplest way to make a clone of the variable
          // instance.
          contextInstance.setVariable(variableInstance.getName(), variableInstance.getValue(), token);
        }
      }
    }
  }
View Full Code Here

  }

  // protected ////////////////////////////////////////////////////////////////

  protected VariableContainer getParentVariableContainer() {
    ContextInstance contextInstance = getContextInstance();
    return (contextInstance != null ? contextInstance.getOrCreateTokenVariableMap(token) : null);
  }
View Full Code Here

TOP

Related Classes of org.jbpm.context.exe.ContextInstance

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.