/*
   * (non-Javadoc)
   *
   * @see org.apache.oodt.cas.workflow.repository.WorkflowRepository#getWorkflowConditionById(java.lang.String)
   */
  public WorkflowCondition getWorkflowConditionById(String conditionId) throws RepositoryException {
    Connection conn = null;
    Statement statement = null;
    ResultSet rs = null;

    WorkflowCondition condition = null;

    try {
      conn = dataSource.getConnection();
      statement = conn.createStatement();

      String getConditionsSql =
          "SELECT * FROM workflow_conditions WHERE workflow_condition_id = " + conditionId;

      LOG.log(Level.FINE, "getWorkflowConditionById: Executing: " + getConditionsSql);
      rs = statement.executeQuery(getConditionsSql);

      while (rs.next()) {
        // get an instance of the class name
        condition = DbStructFactory.getWorkflowCondition(rs, false);
        condition.setCondConfig(getConfigurationByConditionId(conditionId));
      }

    } catch (Exception e) {
      e.printStackTrace();
      LOG.log(Level.WARNING, "Exception getting condition by id. Message: " + e.getMessage());
      try {
        conn.rollback();
      } catch (SQLException e2) {
        LOG.log(
            Level.SEVERE,
            "Unable to rollback getWorkflowConditionById transaction. Message: " + e2.getMessage());
      }
      throw new RepositoryException(e.getMessage());
    } finally {

      if (rs != null) {
        try {
          rs.close();
        } catch (SQLException ignore) {
        }

        rs = null;
      }

      if (statement != null) {
        try {
          statement.close();
        } catch (SQLException ignore) {
        }

        statement = null;
      }

      if (conn != null) {
        try {
          conn.close();

        } catch (SQLException ignore) {
        }

        conn = null;
      }
    }

    return condition;
  }