5 Replies Latest reply on Jun 27, 2011 11:12 PM by missedone

    How get completed/release time for a task?

    jlgranda81

      Hi everybody, An advance about How get completed/release time for a task?

        • 1. Re: How get completed/release time for a task?
          krisverlaenen

          The WS-HumanTask specification does not define a time for when a Task is completed or released as part of the TaskData, so this is not included by default in the Task.

           

          It would be possible to register a listener that would record this information whenever a task is completed / released.  The time a task is completed is probably also available in the history log as the time the human task node instance that requested it was left.

           

          It would be possible to extend TaskData with (an) additional field(s) to store this information (that would be populated whenever the task is completed / released), if you would like to record this kind of information as part of the task data.

           

          Kris

          • 2. Re: How get completed/release time for a task?
            jlgranda81

            Thanks Kris,

             

            I fount audit data in nodeintanceid, accesible throw ProcessInstanceInfo class at jbpm-bam-5.1.0.CR1.jar. I use ProcessInstanceDbLog.findNodeInstances(task.getTaskData().getProcessInstanceId(), task.getId().toString()),for retrieve data.

             

            Best José

            • 3. Re: How get completed/release time for a task?
              missedone

              Hi, Jose

               

              that's it, and also you can implement your own ProcessEventListener, and add it to the ksession, to record more detail log to your own database schema.

               

              BTW, not sure whether you encounter this same problem as me, i now try to retrieve the content data of task from the Content table, as the content stored in postgresql with oid style, that said, what i got back if the oid bytearray rather than the real content data bytearray

              http://community.jboss.org/message/611957#611957

               

              i'm still investigate on it,

              • 4. Re: How get completed/release time for a task?
                jlgranda81

                Thanks Nick for the idea, I will try it.

                 

                About retrieve content data, you can use JBPM BlockingGetContentResponseHandler pass contentId, that is useful for retrieve  any content in the task. Then you can cast the byte array to object and cast to map for explore variables by one by.

                 

                protected Content getTaskContent(Long contentId) {

                        BlockingGetContentResponseHandler responseHandler = new BlockingGetContentResponseHandler();

                        client.getContent(contentId, responseHandler);

                        return responseHandler.getContent();

                    }

                 

                    protected Object getTaskContentAsObject(Long contentId) {

                        Object objectReturn = null;

                        byte[] buf = getTaskContent(contentId).getContent();

                        // Do something with the data read here

                        ByteArrayInputStream bais = new ByteArrayInputStream(buf);

                        try {

                            ObjectInputStream is = new ObjectInputStream(bais);

                 

                            boolean okRead = false;

                            // Map map = new LinkedHashMap<String, Object>();

                            while (!okRead && (objectReturn = is.readObject()) != null) {

                                okRead = true;

                                System.out.println("getTaskContentAsObject object: "

                                        + objectReturn);

                            }

                 

                        } catch (Exception e) {

                            System.err

                                    .print("There was an error reading content task input...");

                            e.printStackTrace();

                        }

                 

                        return objectReturn;

                    }

                • 5. Re: How get completed/release time for a task?
                  missedone

                  Thanks, Jose

                   

                  finally, i use jdbc directly since i want to have as less dependency as possible, but obviously the limition is it tightly couple with postgresql driver classes