コード例 #1
0
  /**
   * Returns all steps for a workflow definition. These are the steps declared in the workfow
   * descriptor; there is no knowledge of current or history steps at this point.
   *
   * @param userPrincipal an InfoGluePrincipal representing a system user
   * @param workflowId a workflowId
   * @return a list of WorkflowStepVOs representing all steps in the workflow.
   */
  public List getAllSteps(InfoGluePrincipal userPrincipal, long workflowId) {
    List declaredSteps = 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);
      declaredSteps = wf.getDeclaredSteps();

      session.flush();

      tx.commit();
    } catch (Exception e) {
      logger.error("An error occurred when we tries to run getAllSteps():" + 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 declaredSteps;
    // return new WorkflowFacade(userPrincipal, workflowId, true).getDeclaredSteps();
  }