Package org.dbwiki.data.index

Examples of org.dbwiki.data.index.VectorDatabaseListing


  /** Get the content listing of the wiki
   *
   */
  public synchronized DatabaseContent content() throws org.dbwiki.exception.WikiException {
    try {
      VectorDatabaseListing content = new VectorDatabaseListing();
      Connection con = _connector.getConnection();
      PreparedStatement pStmtSelectPages = con.prepareStatement(
          "SELECT DISTINCT " + DatabaseConstants.RelPagesColName + " " +
          "FROM " +  _relName + DatabaseConstants.RelationPages + " " +
          "ORDER BY " + DatabaseConstants.RelPagesColName);
      ResultSet rs = pStmtSelectPages.executeQuery();
      while (rs.next()) {
        String title = rs.getString(DatabaseConstants.RelPagesColName);
        content.add(new WikiPageDescription(title, new PageIdentifier(URLEncoder.encode(title, "UTF-8"))));
      }
      rs.close();
      pStmtSelectPages.close();
      con.close();
      return content;
View Full Code Here


      sql = sql + ") q ORDER BY " + RelDataColEntry;
    } else {
      sql = "SELECT DISTINCT " + RelDataColEntry + " FROM " + this.name() + RelationData + " ORDER BY " + RelDataColEntry;
    }
   
    VectorDatabaseListing result = new VectorDatabaseListing();
   
    try {
      Connection con = _connector.getConnection();
      PreparedStatement pStmt = con.prepareStatement(sql);
      for (int iParameter = 0; iParameter < parameters.size(); iParameter++) {
        pStmt.setString(iParameter + 1, parameters.get(iParameter));
      }
      ResultSet rs = pStmt.executeQuery();
      RDBMSDatabaseListing content = this.content();
      while (rs.next()) {
        result.add(content.get(new NodeIdentifier(rs.getInt(1))));
      }
      rs.close();
      con.close();
    } catch (java.sql.SQLException sqlException) {
      throw new WikiFatalException(sqlException);
View Full Code Here

  public DatabaseContent search(String query) throws org.dbwiki.exception.WikiException {
    DatabaseQuery keywords = new DatabaseQuery(query);
   
    RDBMSDatabaseListing entries = content();
   
    VectorDatabaseListing result = new VectorDatabaseListing();
    if (keywords.size() > 0) {
      String union = "SELECT '0' kwid, " + RelDataColEntry + ", COUNT(*) cnt FROM " + name() + RelationData + " WHERE UPPER(" + RelDataColValue + ") LIKE '%" + keywords.get(0).toUpperCase() + "%' GROUP BY kwid, " + RelDataColEntry;
      for (int iKW = 1; iKW < keywords.size(); iKW++) {
        union = union + " UNION SELECT '" + iKW + "' kwid, "+ RelDataColEntry + ", COUNT(*) FROM " + name() + RelationData + " WHERE UPPER(" + RelDataColValue + ") LIKE '%" + keywords.get(iKW).toUpperCase() + "%' GROUP BY kwid, " + RelDataColEntry;
      }
      String sql = "(SELECT " + RelDataColEntry + ", COUNT(kwid), SUM(cnt) FROM (" + union + ") AS u GROUP BY " + RelDataColEntry + " ORDER BY COUNT(kwid) DESC, SUM(cnt) DESC) ";
      try {
        Connection con = _connector.getConnection();
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        while (rs.next()) {
          NodeIdentifier identifier = new NodeIdentifier(rs.getInt(RelDataColEntry));
          result.add(entries.get(identifier));
        }
        rs.close();
        stmt.close();
        con.close();
      } catch (java.sql.SQLException sqlException) {
View Full Code Here

TOP

Related Classes of org.dbwiki.data.index.VectorDatabaseListing

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.