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

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


        org.jbpm.process.instance.ProcessInstance processInstance = ( org.jbpm.process.instance.ProcessInstance )
        workingMemory.startProcess("com.sample.ruleflow", map);
        assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
        assertEquals(2, workingMemory.getProcessInstances().size());
        for (ProcessInstance p: workingMemory.getProcessInstances()) {
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
          (( org.jbpm.process.instance.ProcessInstance )p).getContextInstance(VariableScope.VARIABLE_SCOPE);
          if ("com.sample.ruleflow".equals(p.getProcessId())) {
            assertEquals("x-value", variableScopeInstance.getVariable("x"));
          } else if ("com.sample.subflow".equals(p.getProcessId())) {
            assertEquals("x-value", variableScopeInstance.getVariable("y"));
            assertEquals("z-value", variableScopeInstance.getVariable("z"));
            assertEquals(7, variableScopeInstance.getVariable("n"));
            assertEquals(10, variableScopeInstance.getVariable("o"));
          }
        }
        workingMemory.insert(new Person());
        assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
      processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
      assertEquals("z-value", variableScopeInstance.getVariable("x"));
      assertEquals(10, variableScopeInstance.getVariable("m"));
        assertEquals(0, workingMemory.getProcessInstances().size());
    }
View Full Code Here


    }
   
    public static class ProcessUtils {
     
      public static Object getValue(RuleFlowProcessInstance processInstance, String name) {
        VariableScopeInstance scope = (VariableScopeInstance)
          processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
        return scope.getVariable(name);
      }
View Full Code Here

        assertEquals(1, session.getProcessInstances().size());
        assertTrue(handler.getWorkItem() != null);
       
        session = getSerialisedStatefulSession( session );
        assertEquals(1, session.getProcessInstances().size());
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
          (( ProcessInstance )session.getProcessInstances().iterator().next()).getContextInstance(VariableScope.VARIABLE_SCOPE);
        assertEquals("ThisIsMyValue", variableScopeInstance.getVariable("myVariable"));
       
        session.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null);
       
        assertEquals(0, session.getProcessInstances().size());
    }
View Full Code Here

    }
   
    public static class ProcessUtils {
     
      public static Object getValue(RuleFlowProcessInstance processInstance, String name) {
        VariableScopeInstance scope = (VariableScopeInstance)
          processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
        return scope.getVariable(name);
      }
View Full Code Here

        }
      }
    }
   
    public Object getVariable(String variableName) {
      VariableScopeInstance variableScope = (VariableScopeInstance)
        resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
      if (variableScope == null) {
        variableScope = (VariableScopeInstance) ((ProcessInstance)
          getProcessInstance()).getContextInstance(VariableScope.VARIABLE_SCOPE);
      }
      return variableScope.getVariable(variableName);
    }
View Full Code Here

      }
      return variableScope.getVariable(variableName);
    }
   
    public void setVariable(String variableName, Object value) {
      VariableScopeInstance variableScope = (VariableScopeInstance)
        resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
      if (variableScope == null) {
        variableScope = (VariableScopeInstance) getProcessInstance().getContextInstance(VariableScope.VARIABLE_SCOPE);
        if (variableScope.getVariableScope().findVariable(variableName) == null) {
          variableScope = null;
        }
      }
      if (variableScope == null) {
        System.err.println("Could not find variable " + variableName);
        System.err.println("Using process-level scope");
        variableScope = (VariableScopeInstance) ((ProcessInstance)
          getProcessInstance()).getContextInstance(VariableScope.VARIABLE_SCOPE);
      }
      variableScope.setVariable(variableName, value);
    }
View Full Code Here

              List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>();
              for (Object o: collection) {
                String variableName = getForEachNode().getVariableName();
                NodeInstance nodeInstance = (NodeInstance)
                ((NodeInstanceContainer) getNodeInstanceContainer()).getNodeInstance(getForEachSplitNode().getTo().getTo());
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                  nodeInstance.resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
                variableScopeInstance.setVariable(variableName, o);
                nodeInstances.add(nodeInstance);
              }
              for (NodeInstance nodeInstance: nodeInstances) {
                ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(this, getForEachSplitNode().getTo().getToType());
              }
View Full Code Here

        }

        private Collection<?> evaluateCollectionExpression(String collectionExpression) {
            // TODO: should evaluate this expression using MVEL
          Object collection = null;
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, collectionExpression);
            if (variableScopeInstance != null) {
              collection = variableScopeInstance.getVariable(collectionExpression);
            } else {
              try {
                collection = MVEL.eval(collectionExpression, new NodeInstanceResolverFactory(this));
              } catch (Throwable t) {
                throw new IllegalArgumentException(
View Full Code Here

            for (NodeInstance nodeInstance: groupNodeInstances) {
              stream.writeLong(nodeInstance.getId());
            }
          }
        }
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) workFlow.getContextInstance(VariableScope.VARIABLE_SCOPE);
        Map<String, Object> variables = variableScopeInstance.getVariables();
        List<String> keys = new ArrayList<String>(variables.keySet());
        Collection<Object> values = variables.values();
       
        Collections.sort(keys,
                new Comparator<String>() {
View Full Code Here

                    stream.writeLong(id);
                }
            } else {
                stream.writeInt(0);
            }
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance) compositeNodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
            if (variableScopeInstance == null) {
              stream.writeInt(0);
            } else {
              Map<String, Object> variables = variableScopeInstance.getVariables();
              List<String> keys = new ArrayList<String>(variables.keySet());
              Collections.sort(keys,
                      new Comparator<String>() {
                          public int compare(String o1,
                                  String o2) {
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.