Package org.drools.process.instance.context.variable

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


        }
        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


        stream.writeLong(workFlow.getId());
        stream.writeUTF(workFlow.getProcessId());
        stream.writeInt(workFlow.getState());
        stream.writeLong(workFlow.getNodeInstanceCounter());
        if (includeVariables) {
            VariableScopeInstance variableScopeInstance = (VariableScopeInstance) workFlow.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,
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

        processInstance.setWorkingMemory(wm);
        if (includeVariables) {
            int nbVariables = stream.readInt();
            if (nbVariables > 0) {
                Context variableScope = process.getDefaultContext(VariableScope.VARIABLE_SCOPE);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) processInstance.getContextInstance(variableScope);
                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

            case PersisterEnums.COMPOSITE_NODE_INSTANCE:
            case PersisterEnums.DYNAMIC_NODE_INSTANCE:
                int nbVariables = stream.readInt();
                if (nbVariables > 0) {
                    Context variableScope = ((org.drools.process.core.Process) 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.setVariable(name,
                                    value);
                        } catch (ClassNotFoundException e) {
                            throw new IllegalArgumentException("Could not reload variable " + name);
                        }
                    }
View Full Code Here

        processInstance.setProcess( process );
       
        // 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

    public void setNodeInstance(NodeInstance nodeInstance) {
        this.nodeInstance = nodeInstance;
    }
   
    public Object getVariable(String variableName) {
      VariableScopeInstance variableScope = null;
      if (nodeInstance != null) {
        variableScope = (VariableScopeInstance) ((org.drools.workflow.instance.NodeInstance)
        nodeInstance).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 = null;
      if (nodeInstance != null) {
        variableScope = (VariableScopeInstance) ((org.drools.workflow.instance.NodeInstance)
          nodeInstance).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

      parameters = new HashMap<String, Object>();
      // TODO: transient variables ?
      for (VariableAccess variableAccess : variableAccesses) {
        if (variableAccess.isReadable()) {
          String variableName = variableAccess.getVariableName();
          VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
            resolveContextInstance(VariableScope.VARIABLE_SCOPE, variableName);
          Object value = variableScopeInstance.getVariable(variableName);
          if (value != null) {
            String mappedName = variableAccess.getMappedName();
            parameters.put(mappedName, value);
          }
        }
View Full Code Here

        if ((variableAccesses != null) && (!variableAccesses.isEmpty())) {

          for (VariableAccess variableAccess: variableAccesses) {
            if (variableAccess.isWritable()) {
              String mappedName = variableAccess.getMappedName();
              VariableScopeInstance variableScopeInstance = (VariableScopeInstance)
              ((ProcessInstance) event.getProcessInstance())
                .getContextInstance(VariableScope.VARIABLE_SCOPE);
              Object value = variableScopeInstance.getVariable(mappedName);
              if (value != null) {
                  String variableName = variableAccess.getVariableName();
                  variableScopeInstance = (VariableScopeInstance)
                resolveContextInstance(VariableScope.VARIABLE_SCOPE, mappedName);
                  variableScopeInstance.setVariable(variableName, value);
              }
            }
          }
        }
        fireEvent(Event.EVENTTYPE_SUBPROCESS_END);
View Full Code Here

TOP

Related Classes of org.drools.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.