예제 #1
0
 /* (non-Javadoc)
  * @see org.fireflow.engine.IProcessInstance#getProcessInstanceVariable(java.lang.String)
  */
 public Object getProcessInstanceVariable(String name) {
   IPersistenceService persistenceService = this.rtCtx.getPersistenceService();
   if (processInstanceVariables == null) {
     // 通过数据库查询进行初始化
     List<ProcessInstanceVar> allVars =
         persistenceService.findProcessInstanceVariable(this.getId());
     processInstanceVariables = new HashMap<String, Object>();
     if (allVars != null && allVars.size() != 0) {
       for (ProcessInstanceVar theVar : allVars) {
         processInstanceVariables.put(theVar.getVarPrimaryKey().getName(), theVar.getValue());
       }
     }
   }
   return processInstanceVariables.get(name);
 }
예제 #2
0
  /* (non-Javadoc)
   * @see org.fireflow.engine.IProcessInstance#setProcessInstanceVariable(java.lang.String, java.lang.Object)
   */
  public void setProcessInstanceVariable(String name, Object value) {
    IPersistenceService persistenceService = this.rtCtx.getPersistenceService();
    if (processInstanceVariables == null) {
      // 通过数据库查询进行初始化
      List<ProcessInstanceVar> allVars =
          persistenceService.findProcessInstanceVariable(this.getId());
      processInstanceVariables = new HashMap<String, Object>();
      if (allVars != null && allVars.size() != 0) {
        for (ProcessInstanceVar theVar : allVars) {
          processInstanceVariables.put(theVar.getVarPrimaryKey().getName(), theVar.getValue());
        }
      }
    }
    ProcessInstanceVar procInstVar = new ProcessInstanceVar();
    ProcessInstanceVarPk pk = new ProcessInstanceVarPk();
    pk.setProcessInstanceId(this.getId());
    pk.setName(name);
    procInstVar.setVarPrimaryKey(pk);
    procInstVar.setValue(value);
    procInstVar.setValueType(value.getClass().getName());

    if (processInstanceVariables.containsKey(name)) {
      persistenceService.updateProcessInstanceVariable(procInstVar);
    } else {
      persistenceService.saveProcessInstanceVariable(procInstVar);
    }
    processInstanceVariables.put(name, value);
  }