6 Replies Latest reply on Jun 15, 2006 9:16 PM by ssquare

    Simple class to close open tasks

    sparx

      Hello all,

      I would like to create a simple class to cloase all open tasks for a user and signal the start of the next task in the process. Here's my code:

      package org.jbpm.servlet;
      
      import javax.servlet.http.*;
      import org.jbpm.JbpmContext;
      import org.jbpm.JbpmConfiguration;
      import org.jbpm.taskmgmt.exe.TaskInstance;
      import java.util.*;
      import java.io.*;
      
      public class WorkflowServlet extends HttpServlet
      {
       private static final long serialVersionUID = 1L;
      
       public void doGet(HttpServletRequest request, HttpServletResponse response)
       {
       JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       List tasks = jbpmContext.getTaskList("cookie monster");
       try
       {
       PrintWriter out = response.getWriter();
       response.setContentType("text/html");
       out.println("Total tasks: " + tasks.size() + "<br />");
       for (Iterator it = tasks.iterator(); it.hasNext(); )
       {
       TaskInstance taskInstance = (TaskInstance)it.next();
       out.println(taskInstance.getName() + "<br />");
       taskInstance.end();
       jbpmContext.save(taskInstance);
       }
       }
       catch (Exception e)
       {
       e.printStackTrace();
       }
       }
      }
      


      The code looks like it works - but when I log into the webapp - the tasks are still open. Can anyone give me an idea of where to go from here?

      Thanks,

      Shannon