Exemplo n.º 1
0
  /** @see com.mob.forum.dao.LuceneDAO#getPostsToIndex(LuceneReindexArgs, int, int) */
  public List getPostsToIndex(int fromPostId, int toPostId) {
    List l = new ArrayList();

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p =
          JForumExecutionContext.getConnection()
              .prepareStatement(SystemGlobals.getSql("SearchModel.getPostsToIndexForLucene"));

      p.setInt(1, fromPostId);
      p.setInt(2, toPostId);

      rs = p.executeQuery();

      while (rs.next()) {
        l.add(this.makePost(rs));
      }
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return l;
  }
Exemplo n.º 2
0
  /** @see com.mob.forum.dao.LuceneDAO#getPostsData(int[]) */
  public List getPostsData(int[] postIds, String orderDir) {
    if (postIds.length == 0) {
      return new ArrayList();
    }

    List l = new ArrayList();

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      String sql = SystemGlobals.getSql("SearchModel.getPostsDataForLucene");
      sql = sql.replaceAll(":posts:", this.buildInClause(postIds));

      if ("ASC".equals(orderDir)) {
        sql = sql + " ORDER BY p.post_id";
      } else {
        sql = sql + " ORDER BY p.post_id DESC";
      }

      p = JForumExecutionContext.getConnection().prepareStatement(sql);
      rs = p.executeQuery();

      while (rs.next()) {
        Post post = this.makePost(rs);
        post.setPostUsername(rs.getString("username"));
        l.add(post);
      }
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return l;
  }
Exemplo n.º 3
0
  private int getPostIdByDate(Date date, String query) {
    int postId = 0;

    PreparedStatement p = null;
    ResultSet rs = null;

    try {
      p = JForumExecutionContext.getConnection().prepareStatement(query);

      p.setTimestamp(1, new Timestamp(date.getTime()));

      rs = p.executeQuery();

      if (rs.next()) {
        postId = rs.getInt(1);
      }
    } catch (SQLException e) {
      throw new DatabaseException(e);
    } finally {
      DbUtils.close(rs, p);
    }

    return postId;
  }