Beispiel #1
0
  @Override
  public List<MBThread> findByS_G_U(long groupId, long userId, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_S_G_U);

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBThread.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Beispiel #2
0
  protected List<MBThread> doFindByS_G_U_C(
      long groupId,
      long userId,
      long[] categoryIds,
      QueryDefinition queryDefinition,
      boolean inlineSQLHelper)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_S_G_U_C);

      if (ArrayUtil.isEmpty(categoryIds)) {
        sql = StringUtil.replace(sql, "(MBThread.categoryId = ?) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql,
                "MBThread.categoryId = ?",
                "MBThread.categoryId = "
                    + StringUtil.merge(categoryIds, " OR MBThread.categoryId = "));
      }

      sql = updateSQL(sql, queryDefinition);

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, MBMessage.class.getName(), "MBThread.rootMessageId", groupId);
      }

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(PortalUtil.getClassNameId(MBThread.class.getName()));
      qPos.add(groupId);
      qPos.add(userId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  public List<MBThread> getGroupThreads(long groupId, QueryDefinition<MBThread> queryDefinition) {

    if (queryDefinition.isExcludeStatus()) {
      return mbThreadPersistence.findByG_NotC_NotS(
          groupId,
          MBCategoryConstants.DISCUSSION_CATEGORY_ID,
          queryDefinition.getStatus(),
          queryDefinition.getStart(),
          queryDefinition.getEnd());
    } else {
      return mbThreadPersistence.findByG_NotC_S(
          groupId,
          MBCategoryConstants.DISCUSSION_CATEGORY_ID,
          queryDefinition.getStatus(),
          queryDefinition.getStart(),
          queryDefinition.getEnd());
    }
  }
  protected List<JournalArticle> doFindByG_F(
      long groupId,
      List<Long> folderIds,
      QueryDefinition<JournalArticle> queryDefinition,
      boolean inlineSQLHelper) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_F, queryDefinition, "JournalArticle");

      sql = replaceStatusJoin(sql, queryDefinition);

      sql =
          CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator("JournalArticle"));

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId);
      }

      sql =
          StringUtil.replace(
              sql, "[$FOLDER_ID$]", getFolderIds(folderIds, JournalArticleImpl.TABLE_NAME));

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(queryDefinition.getStatus());

      for (int i = 0; i < folderIds.size(); i++) {
        Long folderId = folderIds.get(i);

        qPos.add(folderId);
      }

      return (List<JournalArticle>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Beispiel #5
0
  @Override
  public List<MBThread> findByG_U_C_A(
      long groupId,
      long userId,
      long[] categoryIds,
      boolean anonymous,
      QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_U_C_A);

      if (ArrayUtil.isEmpty(categoryIds)) {
        sql = StringUtil.replace(sql, "(MBThread.categoryId = ?) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql,
                "MBThread.categoryId = ?",
                "MBThread.categoryId = "
                    + StringUtil.merge(categoryIds, " OR MBThread.categoryId = "));
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(userId);
      qPos.add(anonymous);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  public List<BlogsEntry> findByOrganizationIds(
      List<Long> organizationIds, Date displayDate, QueryDefinition<BlogsEntry> queryDefinition) {

    Timestamp displayDate_TS = CalendarUtil.getTimestamp(displayDate);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_ORGANIZATION_IDS);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        if (queryDefinition.isExcludeStatus()) {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status != ?)");
        } else {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status = ?)");
        }
      }

      sql = StringUtil.replace(sql, "[$ORGANIZATION_ID$]", getOrganizationIds(organizationIds));
      sql = CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator());

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("BlogsEntry", BlogsEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      for (int i = 0; i < organizationIds.size(); i++) {
        Long organizationId = organizationIds.get(i);

        qPos.add(organizationId);
      }

      qPos.add(displayDate_TS);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<BlogsEntry>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Beispiel #7
0
  @Override
  public List<MBThread> findByG_U_LPD(
      long groupId, long userId, Date lastPostDate, QueryDefinition queryDefinition)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_U_LPD);

      if (userId <= 0) {
        sql = StringUtil.replace(sql, _INNER_JOIN_SQL, StringPool.BLANK);
        sql = StringUtil.replace(sql, _USER_ID_SQL, StringPool.BLANK);
      }

      sql = updateSQL(sql, queryDefinition);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(lastPostDate);

      if (userId > 0) {
        qPos.add(userId);
      }

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  public List<BlogsEntry> findByGroupIds(
      long companyId, long groupId, Date displayDate, QueryDefinition<BlogsEntry> queryDefinition) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_GROUP_IDS);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        if (queryDefinition.isExcludeStatus()) {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status != ?)");
        } else {
          sql = CustomSQLUtil.appendCriteria(sql, "AND (BlogsEntry.status = ?)");
        }
      }

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("BlogsEntry", BlogsEntryImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(companyId);
      qPos.add(groupId);
      qPos.add(groupId);
      qPos.add(groupId);
      qPos.add(displayDate);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<BlogsEntry>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected List<JournalArticle> doFindByC_G_F_C_A_V_T_D_C_S_T_D_R(
      long companyId,
      long groupId,
      List<Long> folderIds,
      long classNameId,
      String[] articleIds,
      Double version,
      String[] titles,
      String[] descriptions,
      String[] contents,
      String[] ddmStructureKeys,
      String[] ddmTemplateKeys,
      Date displayDateGT,
      Date displayDateLT,
      Date reviewDate,
      boolean andOperator,
      QueryDefinition<JournalArticle> queryDefinition,
      boolean inlineSQLHelper) {

    articleIds = CustomSQLUtil.keywords(articleIds, false);
    titles = CustomSQLUtil.keywords(titles);
    descriptions = CustomSQLUtil.keywords(descriptions, false);
    contents = CustomSQLUtil.keywords(contents, false);
    ddmStructureKeys = CustomSQLUtil.keywords(ddmStructureKeys, false);
    ddmTemplateKeys = CustomSQLUtil.keywords(ddmTemplateKeys, false);
    Timestamp displayDateGT_TS = CalendarUtil.getTimestamp(displayDateGT);
    Timestamp displayDateLT_TS = CalendarUtil.getTimestamp(displayDateLT);
    Timestamp reviewDate_TS = CalendarUtil.getTimestamp(reviewDate);

    Session session = null;

    try {
      session = openSession();

      String sql =
          CustomSQLUtil.get(FIND_BY_C_G_F_C_A_V_T_D_C_S_T_D_R, queryDefinition, "JournalArticle");

      sql = replaceStatusJoin(sql, queryDefinition);

      if (groupId <= 0) {
        sql = StringUtil.replace(sql, "(JournalArticle.groupId = ?) AND", StringPool.BLANK);
      }

      if (folderIds.isEmpty()) {
        sql = StringUtil.replace(sql, "([$FOLDER_ID$]) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql, "[$FOLDER_ID$]", getFolderIds(folderIds, JournalArticleImpl.TABLE_NAME));
      }

      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "JournalArticle.articleId", StringPool.LIKE, false, articleIds);

      if ((version == null) || (version <= 0)) {
        sql =
            StringUtil.replace(
                sql, "(JournalArticle.version = ?) [$AND_OR_CONNECTOR$]", StringPool.BLANK);
      }

      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "lower(JournalArticle.title)", StringPool.LIKE, false, titles);
      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "JournalArticle.description", StringPool.LIKE, false, descriptions);
      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "JournalArticle.content", StringPool.LIKE, false, contents);

      sql = replaceStructureTemplate(sql, ddmStructureKeys, ddmTemplateKeys);

      if (!isNullArray(ddmStructureKeys)) {
        sql =
            CustomSQLUtil.replaceKeywords(
                sql, "JournalArticle.DDMStructureKey", StringPool.LIKE, false, ddmStructureKeys);
      }

      if (!isNullArray(ddmTemplateKeys)) {
        sql =
            CustomSQLUtil.replaceKeywords(
                sql, "JournalArticle.DDMTemplateKey", StringPool.LIKE, false, ddmTemplateKeys);
      }

      sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);
      sql =
          CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator("JournalArticle"));

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId);

        sql = StringUtil.replace(sql, "(companyId", "(JournalArticle.companyId");
      }

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(companyId);

      if (groupId > 0) {
        qPos.add(groupId);
      }

      for (long folderId : folderIds) {
        qPos.add(folderId);
      }

      qPos.add(classNameId);
      qPos.add(queryDefinition.getStatus());

      if (!isNullArray(ddmStructureKeys)) {
        qPos.add(ddmStructureKeys, 2);
      }

      if (!isNullArray(ddmTemplateKeys)) {
        qPos.add(ddmTemplateKeys, 2);
      }

      qPos.add(articleIds, 2);

      if ((version != null) && (version > 0)) {
        qPos.add(version);
      }

      qPos.add(titles, 2);
      qPos.add(descriptions, 2);
      qPos.add(contents, 2);
      qPos.add(displayDateGT_TS);
      qPos.add(displayDateGT_TS);
      qPos.add(displayDateLT_TS);
      qPos.add(displayDateLT_TS);
      qPos.add(reviewDate_TS);
      qPos.add(reviewDate_TS);

      return (List<JournalArticle>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected List<JournalArticle> doFindByG_U_F_C(
      long groupId,
      long userId,
      List<Long> folderIds,
      long classNameId,
      QueryDefinition<JournalArticle> queryDefinition,
      boolean inlineSQLHelper) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_U_F_C, queryDefinition, "JournalArticle");

      sql = replaceStatusJoin(sql, queryDefinition);

      sql =
          CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator("JournalArticle"));

      if (folderIds.isEmpty()) {
        sql = StringUtil.replace(sql, "([$FOLDER_ID$]) AND", StringPool.BLANK);
      } else {
        sql =
            StringUtil.replace(
                sql, "[$FOLDER_ID$]", getFolderIds(folderIds, JournalArticleImpl.TABLE_NAME));
      }

      if (userId <= 0) {
        sql = StringUtil.replace(sql, "(JournalArticle.userId = ?) AND", StringPool.BLANK);
      }

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId);
      }

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(classNameId);

      if (userId > 0) {
        qPos.add(userId);
      }

      for (long folderId : folderIds) {
        qPos.add(folderId);
      }

      qPos.add(queryDefinition.getStatus());

      return (List<JournalArticle>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected List<JournalArticle> doFindByG_C_S(
      long groupId,
      long classNameId,
      String ddmStructureKey,
      QueryDefinition<JournalArticle> queryDefinition,
      boolean inlineSQLHelper) {

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_C_S, queryDefinition, "JournalArticle");

      sql = replaceStatusJoin(sql, queryDefinition);

      sql =
          CustomSQLUtil.replaceOrderBy(sql, queryDefinition.getOrderByComparator("JournalArticle"));

      if (groupId <= 0) {
        sql = StringUtil.replace(sql, "(JournalArticle.groupId = ?) AND", StringPool.BLANK);
      }

      if (ddmStructureKey.equals(String.valueOf(JournalArticleConstants.CLASSNAME_ID_DEFAULT))) {

        sql =
            StringUtil.replace(
                sql,
                "(JournalArticle.DDMStructureKey = ?)",
                "((JournalArticle.DDMStructureKey = ?) OR "
                    + "(JournalArticle.DDMStructureKey = '') OR"
                    + "(JournalArticle.DDMStructureKey IS NULL))");
      }

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, JournalArticle.class.getName(), "JournalArticle.resourcePrimKey", groupId);
      }

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity(JournalArticleImpl.TABLE_NAME, JournalArticleImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      if (groupId > 0) {
        qPos.add(groupId);
      }

      qPos.add(classNameId);
      qPos.add(ddmStructureKey);
      qPos.add(queryDefinition.getStatus());

      return (List<JournalArticle>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected List<Object> doFindF_E_ByG_F(
      long groupId, long folderId, QueryDefinition<?> queryDefinition, boolean inlineSQLHelper) {

    Session session = null;

    try {
      session = openSession();

      StringBundler sb = new StringBundler(5);

      sb.append("SELECT * FROM (");

      String sql = null;

      if (queryDefinition.getStatus() == WorkflowConstants.STATUS_ANY) {
        sql = CustomSQLUtil.get(getClass(), FIND_F_BY_G_P);
      } else {
        sql = CustomSQLUtil.get(getClass(), FIND_F_BY_G_P_S);

        sql = replaceExcludeStatus(sql, queryDefinition);
      }

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, BookmarksFolder.class.getName(), "BookmarksFolder.folderId", groupId);
      }

      sb.append(sql);
      sb.append(" UNION ALL ");

      if (queryDefinition.getStatus() == WorkflowConstants.STATUS_ANY) {
        sql = CustomSQLUtil.get(getClass(), FIND_E_BY_G_F);
      } else {
        sql = CustomSQLUtil.get(getClass(), FIND_E_BY_G_F_S);

        sql = replaceExcludeStatus(sql, queryDefinition);
      }

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql, BookmarksEntry.class.getName(), "BookmarksEntry.fileEntryId", groupId);
      }

      sb.append(sql);
      sb.append(") TEMP_TABLE ORDER BY modelName ASC");

      sql = sb.toString();

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addScalar("modelId", Type.LONG);
      q.addScalar("modelName", Type.STRING);
      q.addScalar("modelFolder", Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(folderId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      qPos.add(groupId);
      qPos.add(folderId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      List<Object> models = new ArrayList<>();

      Iterator<Object[]> itr =
          (Iterator<Object[]>)
              QueryUtil.iterate(
                  q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());

      while (itr.hasNext()) {
        Object[] array = itr.next();

        long modelId = (Long) array[0];
        // String name = (String)array[1];
        long modelFolder = (Long) array[2];

        Object obj = null;

        if (modelFolder == 0) {
          obj = BookmarksFolderUtil.findByPrimaryKey(modelId);
        } else {
          obj = BookmarksEntryUtil.findByPrimaryKey(modelId);
        }

        models.add(obj);
      }

      return models;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
Beispiel #13
0
  protected List<MBThread> doFindByG_C(
      long groupId, long categoryId, QueryDefinition queryDefinition, boolean inlineSQLHelper)
      throws SystemException {

    if (!inlineSQLHelper || !InlineSQLHelperUtil.isEnabled(groupId)) {
      if (queryDefinition.isExcludeStatus()) {
        return MBThreadUtil.findByG_C_NotS(
            groupId,
            categoryId,
            queryDefinition.getStatus(),
            queryDefinition.getStart(),
            queryDefinition.getEnd());
      } else {
        if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {

          return MBThreadUtil.findByG_C_S(
              groupId,
              categoryId,
              queryDefinition.getStatus(),
              queryDefinition.getStart(),
              queryDefinition.getEnd());
        } else {
          return MBThreadUtil.findByG_C(
              groupId, categoryId, queryDefinition.getStart(), queryDefinition.getEnd());
        }
      }
    }

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_G_C);

      sql = updateSQL(sql, queryDefinition);

      sql =
          InlineSQLHelperUtil.replacePermissionCheck(
              sql, MBMessage.class.getName(), "MBThread.rootMessageId", groupId);

      SQLQuery q = session.createSQLQuery(sql);

      q.addEntity("MBThread", MBThreadImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(groupId);
      qPos.add(categoryId);

      if (queryDefinition.getStatus() != WorkflowConstants.STATUS_ANY) {
        qPos.add(queryDefinition.getStatus());
      }

      return (List<MBThread>)
          QueryUtil.list(q, getDialect(), queryDefinition.getStart(), queryDefinition.getEnd());
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }