Examples of ContextInstance


Examples of org.jbpm.context.exe.ContextInstance

      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

Examples of org.jbpm.context.exe.ContextInstance

      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

Examples of org.jbpm.context.exe.ContextInstance

    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

Examples of org.jbpm.context.exe.ContextInstance

  }

  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

Examples of org.jbpm.context.exe.ContextInstance

      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

Examples of org.jbpm.context.exe.ContextInstance

                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

Examples of org.jbpm.context.exe.ContextInstance

      // 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

Examples of org.jbpm.context.exe.ContextInstance

  }

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

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

Examples of org.jbpm.context.exe.ContextInstance

            boolean updated = false;

            final Object targetValue = targetExpression.getValue(elContext);
            if (targetValue instanceof ProcessInstance) {
                final ProcessInstance processInstance = (ProcessInstance) targetValue;
                final ContextInstance contextInstance = processInstance.getContextInstance();
                for (String name : deletes) {
                    contextInstance.deleteVariable(name);
                    updated = true;
                }
                for (String name : updates) {
                    contextInstance.setVariable(name, updatesHashMap.get(name));
                    updated = true;
                }
            } else if (targetValue instanceof Token) {
                final Token token = (Token) targetValue;
                final ProcessInstance processInstance = token.getProcessInstance();
                final ContextInstance contextInstance = processInstance.getContextInstance();
                for (String name : deletes) {
                    contextInstance.deleteVariable(name, token);
                    updated = true;
                }
                for (String name : updates) {
                    contextInstance.setVariable(name, updatesHashMap.get(name), token);
                    updated = true;
                }
            } else if (targetValue instanceof TaskInstance) {
                final TaskInstance task = (TaskInstance) targetValue;
                for (String name : deletes) {
View Full Code Here

Examples of org.jbpm.context.exe.ContextInstance

    // feed the readable variableInstances
    if ((variableAccesses != null) && (!variableAccesses.isEmpty()))
    {

      ContextInstance superContextInstance = executionContext.getContextInstance();
      ContextInstance subContextInstance = subProcessInstance.getContextInstance();
      subContextInstance.setTransientVariables(superContextInstance.getTransientVariables());

      // loop over all the variable accesses
      for (VariableAccess variableAccess : variableAccesses)
      {
        // if this variable access is readable
        if (variableAccess.isReadable())
        {
          // the variable is copied from the super process variable name
          // to the sub process mapped name
          String variableName = variableAccess.getVariableName();
          Object value = superContextInstance.getVariable(variableName, superProcessToken);
          String mappedName = variableAccess.getMappedName();
          log.debug("copying super process var '" + variableName + "' to sub process var '" + mappedName + "': " + value);
          if (value != null)
          {
            subContextInstance.setVariable(mappedName, value);
          }
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.