/**
   * for term_info part, get the ontology match records for a given term
   *
   * @param term
   * @param glossaryType
   * @return
   * @throws SQLException
   */
  public ArrayList<TermGlossary> getOntologyMatchForTerm(String term, int glossaryType)
      throws SQLException {
    ArrayList<TermGlossary> glossies = new ArrayList<TermGlossary>();
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rset = null, rset2 = null;

    try {
      conn = getConnection();
      String sql =
          "select category, recordType, recordID "
              + "from selected_ontology_records "
              + "where glossaryType = ? and term = ?";
      pstmt = conn.prepareStatement(sql);
      pstmt.setInt(1, glossaryType);
      pstmt.setString(2, term);
      rset = pstmt.executeQuery();
      while (rset.next()) {
        String category = rset.getString("category");
        // get id and definition
        OntologyRecordType recordType = translateToOntologyRecordType(rset.getInt("recordType"));
        String id_prefix = "Ontology ID: ";
        if (recordType.equals(OntologyRecordType.SUBMISSION)) {
          id_prefix = "Temporary ID: ";
          sql = "select tmpID as id, definition from ontology_submissions where ID = ?";
        } else {
          sql = "select permanentID as id, definition from ontology_matches where ID = ?";
        }
        pstmt = conn.prepareStatement(sql);
        pstmt.setInt(1, rset.getInt("recordID"));
        rset2 = pstmt.executeQuery();
        if (rset2.next()) {
          String id = rset2.getString(1);
          if (recordType.equals(OntologyRecordType.MATCH)) {
            id = truncatePermanentID(id);
          }
          TermGlossary gloss = new TermGlossary(id_prefix + id, category, rset2.getString(2));
          glossies.add(gloss);
        }
      }
    } catch (SQLException e) {
      e.printStackTrace();
      throw e;
    } finally {
      close(rset);
      close(pstmt);
      closeConnection(conn);
    }

    return glossies;
  }
 // in db, couldn't save enum type, therefore translate it to integer values
 private int translateOntologyRecordType(OntologyRecordType type) {
   if (type.equals(OntologyRecordType.MATCH)) {
     return 1;
   } else {
     return 2;
   }
 }