AnsweredAssumed Answered

Process Instance Variables

Question asked by michael.eyre on Jan 27, 2016
Latest reply on Jan 29, 2016 by martin.grofcik
I am working on an integration with Activiti and a java REST application.  The application is designed to receive JSON data and start the specified process instance by the key.  What I want to do is to get the list of starter variables for the process instance to verify all of the necessary values are present before starting the process instance.  If there is anything missing, I can send an error message back in the response.

I have found classes to query existing process instances, but I have not found a way to get what variables need to be populated at the launch of the process.

Here is my current test code:

   public static String create (String processName, JSONObject inputData) {
      
      ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
      
      // Get Activiti services
      RuntimeService runtimeService = processEngine.getRuntimeService();
      Map<String, Object> variables = new HashMap<String, Object>();
      for (String key:inputData.getJSONObject("data").keySet()) {
         System.out.println("Data Key:" + key);
         variables.put(key, inputData.getJSONObject("data").get(key));
      }
      
      RepositoryService repositoryService = processEngine.getRepositoryService();
      DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
      deploymentQuery.processDefinitionKey(processName);
      long deploymentCount = deploymentQuery.count();
      Deployment testDeployment = deploymentQuery.singleResult();
      log.info("Deployment ID = " + testDeployment.getId());
      
      variables.put("startDate", new Date());
      variables.put("employeeName", "Test Cloud Logic");
      
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processName, variables);
      
      log.info("Process instance ID: " + processInstance.getId());
      
      return "test";
   }


Thanks

Mike

Outcomes