Examples of VariableScopeInstance


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

  public WorkflowProcess getWorkflowProcess() {
    return (WorkflowProcess) getProcess();
  }
 
  public Object getVariable(String name) {
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
      getContextInstance(VariableScope.VARIABLE_SCOPE);
    if (variableScopeInstance == null) {
      return null;
    }
    return variableScopeInstance.getVariable(name);
  }
View Full Code Here

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

        long nodeInstanceCounter = stream.readLong();
        processInstance.setWorkingMemory( wm );

        int nbVariables = stream.readInt();
        if ( nbVariables > 0 ) {
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance( VariableScope.VARIABLE_SCOPE );
            for ( int i = 0; i < nbVariables; i++ ) {
                String name = stream.readUTF();
                try {
                    Object value = stream.readObject();
                    variableScopeInstance.setVariable( name,
                                                       value );
                } catch ( ClassNotFoundException e ) {
                    throw new IllegalArgumentException( "Could not reload variable " + name );
                }
            }
View Full Code Here

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

        nodeInstance.setId( id );
        switch ( nodeType ) {
            case PersisterEnums.COMPOSITE_NODE_INSTANCE :
                int nbVariables = stream.readInt();
                if ( nbVariables > 0 ) {
                    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) nodeInstance).getContextInstance( VariableScope.VARIABLE_SCOPE );
                    for ( int i = 0; i < nbVariables; i++ ) {
                        String name = stream.readUTF();
                        try {
                            Object value = stream.readObject();
                            variableScopeInstance.setVariable( name,
                                                               value );
                        } catch ( ClassNotFoundException e ) {
                            throw new IllegalArgumentException( "Could not reload variable " + name );
                        }
                    }
View Full Code Here

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

        processInstance.setProcess( process );
        processInstanceManager.addProcessInstance( processInstance );
        // set variable default values
        // TODO: should be part of processInstanceImpl?
        VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext( VariableScope.VARIABLE_SCOPE );
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance( VariableScope.VARIABLE_SCOPE );
        // set input parameters
        if ( parameters != null ) {
            if ( variableScope != null ) {
                for ( Map.Entry<String, Object> entry : parameters.entrySet() ) {
                    variableScopeInstance.setVariable( entry.getKey(),
                                                       entry.getValue() );
                }
            } else {
                throw new IllegalArgumentException( "This process does not support parameters!" );
            }
View Full Code Here

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

        stream.writeLong( processInstance.getId() );
        stream.writeUTF( processInstance.getProcessId() );
        stream.writeInt( processInstance.getState() );
        stream.writeLong( processInstance.getNodeInstanceCounter() );

        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance( VariableScope.VARIABLE_SCOPE );
        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

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

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

    }
   
    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

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

        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

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

    }
   
    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

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

        }
      }
    }
   
    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
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.