Package org.jbpm.pvm

Examples of org.jbpm.pvm.VariableScope


  /** @see Execution#setVariable(String, Object) */
  public void setVariable(String key, Object value) {
    // first search for the most inner variable scope that has a variable for
    // the given key
    VariableScope variableScope = findVariableScope(key);
   
    // if no variable scope exists for the given variable
    if (variableScope==null) {
      // then take the most outer scope of the process instance
      List<VariableScope> processInstanceVariableScopes = processInstance.getVariableScopes();
      if ( (processInstanceVariableScopes!=null)
           && (! processInstanceVariableScopes.isEmpty())
         ) {
        int lastIndex = processInstanceVariableScopes.size()-1;
        variableScope = processInstanceVariableScopes.get(lastIndex);

      } else { // means the process instance doesn't have a variable scope yet
        // create the most outer variable scope
        variableScope = processInstance.createVariableScope();
      }
    }
    variableScope.set(key, value);
  }
View Full Code Here


      }
    }
  }

  public Object getVariable(String key) {
    VariableScope variableScope = findVariableScope(key);
    if (variableScope!=null) {
      return variableScope.get(key);
    }
    return null;
  }
View Full Code Here

  public Set<String> getVariableKeys() {
    Set<String> variableKeys = new HashSet<String>();
    VariableScopeIterator iter = new VariableScopeIterator(this);
    while (iter.hasNext()) {
      VariableScope variableScope = iter.next();
      Set<String> keys = variableScope.keys();
      if (keys!=null) {
        variableKeys.addAll(keys);
      }
    }
    return variableKeys;
View Full Code Here

 
  public Map<String, Object> getVariables() {
    Map<String, Object> allVariables = new HashMap<String, Object>();
    VariableScopeIterator iter = new VariableScopeIterator(this);
    while (iter.hasNext()) {
      VariableScope variableScope = iter.next();
      Map<String, Object> localVariables = variableScope.getAll();
      if (localVariables!=null) {
        for(String key: localVariables.keySet()) {
          if (! allVariables.containsKey(key)) {
            allVariables.put(key, localVariables.get(key));
          }
View Full Code Here

    return createVariableScope(null);
  }
 
  public VariableScope createVariableScope(List<VariableDefinition> variableDefinitions) {
    log.finest("creating variable scope on "+this);
    VariableScope variableScope = newVariableScope();
    pushVariableScope(variableScope);
    if (variableDefinitions!=null) {
      for (VariableDefinition variableDefinition: variableDefinitions) {
        String variableName = variableDefinition.getName();
        Object initialValue = variableDefinition.getInitialValue(this);
        variableScope.set(variableName, initialValue);
      }
    }
    return variableScope;
  }
View Full Code Here

    return new VariableScopeIterator(this);
  }
 

  public void removeVariable(String key) {
    VariableScope variableScope = findVariableScope(key);
    if (variableScope!=null) {
      variableScope.remove(key);
    }
  }
View Full Code Here

  }
 
  // protected variable helper methods ////////////////////////////////////////

  protected VariableScope getVariableScope() {
    VariableScope variableScope = findVariableScope();
    if (variableScope!=null) {
      return variableScope;
    }
    return processInstance.createVariableScope();
  }
View Full Code Here

  protected List getScopeListFromExecution() {
    return execution.getVariableScopes();
  }

  protected boolean isWanted(Object executionScope) {
    VariableScope variableScope = (VariableScope) executionScope;
   
    return ( (key==null)
             || (variableScope.has(key))
           );
  }
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.VariableScope

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.