AnsweredAssumed Answered

Save Variables without completing Task

Question asked by dognose on Dec 10, 2012
Latest reply on Dec 19, 2012 by frederikheremans1
Hello,

I want to save entered Values of an Task, without completing it.
This so far can be achieved by calling runtimeservice.setVariable()

In my XHTML files, im binding the form-fields directly to the processVariableMap, so a call to businessProcess.complete()
will flush that values.

So, without completing the process and having all (updated) values inside the processVariableMap, i need to iterateover the processVariableMap
in order to update the process's internal variableMap using setVariable() as mentioned above.

However the implementation of the ProcessVariableMap neither supports size(), containsKey(), keySet(), values() nor any of the functions I would need
to access all key/value pairs in an iterative way.

So, what to do?

Here's what i want to achieve:


   public String saveChanges(BusinessProcess businessProcess, ProcessVariableMap processVariables){
      //Save all variables.
      for (Map.Entry<String, Object> entry : processVariables.entrySet()) {
         //Save to process using runtimeService
      }
      
      System.out.println("Just saving task.");
      return this.getNavigationOutcome();
   }

but as mentioned:
java.lang.UnsupportedOperationException: org.activiti.cdi.impl.ProcessVariableMap.entrySet() is not supported.

using


this.runtimeservice.setVariables(businessProcess.getExecutionId(), processVariables);

instead of iterating manually results in an Exception also:

Caused by: java.lang.UnsupportedOperationException: org.activiti.cdi.impl.ProcessVariableMap.keySet() is not supported.

Outcomes