3 Replies Latest reply on Feb 2, 2009 9:36 AM by Heiko Braun

    Task variables

    Dale Wyttenbach Newbie

      Hi,

      I'm new to jBPM, and for better or worse I'm diving in at the jBPM 4.0.0 alpha1 end of the pool.

      To begin with I've defined a trivial jpdl with start and end nodes, and one task in between. Then I wrote a bit of code to create process instances and complete the related tasks. I'm either doing something wrong or something isn't implemented yet, because the documentId is always null at the time when I mark the task complete.

      I'm using alpha1 jars downloaded from http://repository.jboss.com/maven2, together with jbpm.cfg.xml and hibernate.properties copied from the examples/src folder of the jbpm-4.0.0-Alpha1 distribution zip.

      I'm pleased with how smoothly this is all working, with the exception of the null documentId. I'd like to stick with jBPM v4 if possible, but would I be better off cutting my teeth on v3?

      Thanks.


       public void run() {
       ProcessEngine processEngine = new Configuration().buildProcessEngine();
      
       // define the wf
       ProcessService processService = processEngine.getProcessService();
       processService.createDeployment().addResource("review.jpdl.xml")
       .deploy();
      
       // create 3 wf process instances
       ExecutionService executionService = processEngine.getExecutionService();
       for (int i=1; i<=3; i++) {
       Map<String,Object> variables = new HashMap<String,Object>();
       variables.put(DOCUMENT_ID, "doc"+i);
       Execution execution = executionService.startExecutionByKey("review", variables);
       LOG.debug("documentId: " + executionService.getVariable(execution.getId(), DOCUMENT_ID));
       }
      
       // retrieve tasks, and mark them complete
       TaskService taskService = processEngine.getTaskService();
      
       List<Task> tasks = taskService.getPersonalTaskList("operator", 0, 10);
       for (Task task : tasks) {
       LOG.debug("task name: " + task.getName());
      
       // TODO: Why aren't Variables in Task interface?
       Map<String,Object> variables = ((TaskImpl) task).getVariables();
       String documentId = (String) variables.get(DOCUMENT_ID);
      
       LOG.debug("I'm supposed to review documentId: " + documentId);
       // TODO: Why is documentId always null here?
      
       // mark task complete
       taskService.submitTask(task.getId());
       }
      
       }