コード例 #1
0
  /**
   * Returns all history steps for a workflow, i.e., all the steps that have already been performed.
   *
   * @param userPrincipal a user principal
   * @param workflowId the ID of the desired workflow
   * @return a list of WorkflowStepVOs representing all history steps for the workflow with
   *     workflowId
   */
  public List getHistorySteps(InfoGluePrincipal userPrincipal, long workflowId) {
    List historySteps = new ArrayList();

    Session session = null;
    net.sf.hibernate.Transaction tx = null;

    try {
      session = hibernateSessionFactory.openSession();
      tx = session.beginTransaction();

      WorkflowFacade wf =
          new WorkflowFacade(userPrincipal, workflowId, hibernateSessionFactory, session);
      historySteps = wf.getHistorySteps();

      session.flush();

      tx.commit();
    } catch (Exception e) {
      logger.error("An error occurred when we tries to run getHistorySteps():" + e.getMessage(), e);
      try {
        tx.rollback();
      } catch (HibernateException he) {
        logger.error(
            "An error occurred when we tries to rollback transaction:" + he.getMessage(), he);
      }
      restoreSessionFactory(e);
    } finally {
      try {
        session.close();
      } catch (HibernateException e) {
        logger.error("An error occurred when we tries to close session:" + e.getMessage(), e);
      }
    }

    return historySteps;
    // return new WorkflowFacade(userPrincipal, workflowId, true).getHistorySteps();
  }