Package org.jbpm.process.instance.context.variable

Examples of org.jbpm.process.instance.context.variable.VariableScopeInstance


            // - Marshalled Object
    int nbVariables = stream.readInt();
    if (nbVariables > 0) {
      Context variableScope = ((org.jbpm.process.core.Process) process)
          .getDefaultContext(VariableScope.VARIABLE_SCOPE);
      VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance
          .getContextInstance(variableScope);
      for (int i = 0; i < nbVariables; i++) {
        String name = stream.readUTF();
        try {
          int index = stream.readInt();
          ObjectMarshallingStrategy strategy = context.resolverStrategyFactory
              .getStrategy(index);

          Object value = strategy.read(stream);
          variableScopeInstance.internalSetVariable(name, value);
        } catch (ClassNotFoundException e) {
          throw new IllegalArgumentException(
              "Could not reload variable " + name);
        }
      }
View Full Code Here


                }
                String n = join.getN();
                Integer number = null;
                if (n.startsWith("#{") && n.endsWith("}")) {
                  n = n.substring(2, n.length() - 1);
                  VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                    resolveContextInstance(VariableScope.VARIABLE_SCOPE, n);
                  if (variableScopeInstance == null) {
                    throw new IllegalArgumentException(
                    "Could not find variable " + n + " when executing join.");
                  }
                  Object value = variableScopeInstance.getVariable(n);
                  if (value instanceof Number) {
                    number = ((Number) value).intValue();
                  } else {
                    throw new IllegalArgumentException(
                    "Variable " + n + " did not return a number when executing join: " + value);
View Full Code Here

            case PersisterEnums.DYNAMIC_NODE_INSTANCE:
                int nbVariables = stream.readInt();
                if (nbVariables > 0) {
                    Context variableScope = ((org.jbpm.process.core.Process) ((org.jbpm.process.instance.ProcessInstance)
                    processInstance).getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
                    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) nodeInstance).getContextInstance(variableScope);
                    for (int i = 0; i < nbVariables; i++) {
                        String name = stream.readUTF();
                        try {
                            Object value = stream.readObject();
                            variableScopeInstance.internalSetVariable(name, value);
                        } catch (ClassNotFoundException e) {
                            throw new IllegalArgumentException("Could not reload variable " + name);
                        }
                    }
                }
View Full Code Here

        }
      }
      return null;
    }
    // else retrieve the variable scope
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
      getContextInstance(VariableScope.VARIABLE_SCOPE);
    if (variableScopeInstance == null) {
      return null;
    }
    return variableScopeInstance.getVariable(name);
  }
View Full Code Here

                result.putAll(variables);
            }
            return result;
        }
        // else retrieve the variable scope
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
            getContextInstance(VariableScope.VARIABLE_SCOPE);
        if (variableScopeInstance == null) {
            return null;
        }
        return variableScopeInstance.getVariables();
  }
View Full Code Here

        }
        return variableScopeInstance.getVariables();
  }
 
  public void setVariable(String name, Object value) {
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
      getContextInstance(VariableScope.VARIABLE_SCOPE);
    if (variableScopeInstance == null) {
      throw new IllegalArgumentException("No variable scope found.");
    }
    variableScopeInstance.setVariable(name, value);
  }
View Full Code Here

    private static final long serialVersionUID = 510l;

    public void signalEvent(String type, Object event) {
      String variableName = getEventNode().getVariableName();
      if (variableName != null) {
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
          resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
        if (variableScopeInstance == null) {
          throw new IllegalArgumentException(
          "Could not find variable for event node: " + variableName);
        }
        EventTransformer transformer = getEventNode().getEventTransformer();
        if (transformer != null) {
          event = transformer.transformEvent(event);
        }
        variableScopeInstance.setVariable(variableName, event);
      }
      triggerCompleted();
    }
View Full Code Here

        Map<String, String> replacements = new HashMap<String, String>();
        Matcher matcher = PARAMETER_MATCHER.matcher(s);
            while (matcher.find()) {
              String paramName = matcher.group(1);
              if (replacements.get(paramName) == null) {
                  VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                      resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                    if (variableScopeInstance != null) {
                        Object variableValue = variableScopeInstance.getVariable(paramName);
                      String variableValueString = variableValue == null ? "" : variableValue.toString();
                      replacements.put(paramName, variableValueString);
                    } else {
                      try {
                        Object variableValue = MVEL.eval(paramName, new NodeInstanceResolverFactory(this));
View Full Code Here

        ((WorkItem) workItem).setParameters(new HashMap<String, Object>(work.getParameters()));
        for (Iterator<DataAssociation> iterator = workItemNode.getInAssociations().iterator(); iterator.hasNext(); ) {
            DataAssociation association = iterator.next();
            if (association.getAssignments() == null || association.getAssignments().isEmpty()) {
                Object parameterValue = null;
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, association.getSources().get(0));
                if (variableScopeInstance != null) {
                    parameterValue = variableScopeInstance.getVariable(association.getSources().get(0));
                } else {
                    try {
                        parameterValue = MVEL.eval(association.getSources().get(0), new NodeInstanceResolverFactory(this));
                    } catch (Throwable t) {
                        System.err.println("Could not find variable scope for variable " + association.getSources().get(0));
                        System.err.println("when trying to execute Work Item " + work.getName());
                        System.err.println("Continuing without setting parameter.");
                    }
                }
                if (parameterValue != null) {
                    ((WorkItem) workItem).setParameter(association.getTarget(), parameterValue);
                }
            } else {
                for(Iterator<Assignment> it = association.getAssignments().iterator(); it.hasNext(); ) {
                    handleAssignment(it.next());
                }
            }
        }
       
        for (Map.Entry<String, Object> entry: workItem.getParameters().entrySet()) {
            if (entry.getValue() instanceof String) {
                String s = (String) entry.getValue();
                Map<String, String> replacements = new HashMap<String, String>();
                Matcher matcher = PARAMETER_MATCHER.matcher(s);
                while (matcher.find()) {
                    String paramName = matcher.group(1);
                    if (replacements.get(paramName) == null) {
                        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                            resolveContextInstance(VariableScope.VARIABLE_SCOPE, paramName);
                        if (variableScopeInstance != null) {
                            Object variableValue = variableScopeInstance.getVariable(paramName);
                            String variableValueString = variableValue == null ? "" : variableValue.toString();
                            replacements.put(paramName, variableValueString);
                        } else {
                            try {
                                Object variableValue = MVEL.eval(paramName, new NodeInstanceResolverFactory(this));
View Full Code Here

        WorkItemNode workItemNode = getWorkItemNode();
        if (workItemNode != null) {
            for (Iterator<DataAssociation> iterator = getWorkItemNode().getOutAssociations().iterator(); iterator.hasNext(); ) {
                DataAssociation association = iterator.next();
                if (association.getAssignments() == null || association.getAssignments().isEmpty()) {
                    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                    resolveContextInstance(VariableScope.VARIABLE_SCOPE, association.getTarget());
                    if (variableScopeInstance != null) {
                        Object value = workItem.getResult(association.getSources().get(0));
                        if (value == null) {
                            try {
                                value = MVEL.eval(association.getSources().get(0), new WorkItemResolverFactory(workItem));
                            } catch (Throwable t) {
                                // do nothing
                            }
                        }
                        variableScopeInstance.setVariable(association.getTarget(), value);
                    } else {
                        System.out.println("Could not find variable scope for variable " + association.getTarget());
                        System.out.println("when trying to complete Work Item " + workItem.getName());
                        System.out.println("Continuing without setting variable.");
                    }
View Full Code Here

TOP

Related Classes of org.jbpm.process.instance.context.variable.VariableScopeInstance

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.