예제 #1
0
  protected List<JournalArticle> getReindexApprovedArticles(
      long companyId, long startId, long endId) throws Exception {

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            JournalArticle.class, PACLClassLoaderUtil.getPortalClassLoader());

    Property property = PropertyFactoryUtil.forName("id");

    dynamicQuery.add(property.ge(startId));
    dynamicQuery.add(property.lt(endId));

    addReindexCriteria(dynamicQuery, companyId, WorkflowConstants.STATUS_APPROVED);

    return JournalArticleLocalServiceUtil.dynamicQuery(dynamicQuery);
  }
예제 #2
0
  protected void reindexArticles(long companyId) throws Exception {
    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(
            JournalArticle.class, PACLClassLoaderUtil.getPortalClassLoader());

    Projection minIdProjection = ProjectionFactoryUtil.min("id");
    Projection maxIdProjection = ProjectionFactoryUtil.max("id");

    ProjectionList projectionList = ProjectionFactoryUtil.projectionList();

    projectionList.add(minIdProjection);
    projectionList.add(maxIdProjection);

    dynamicQuery.setProjection(projectionList);

    addReindexCriteria(dynamicQuery, companyId, WorkflowConstants.STATUS_APPROVED);

    List<Object[]> results = JournalArticleLocalServiceUtil.dynamicQuery(dynamicQuery);

    Object[] minAndMaxIds = results.get(0);

    if ((minAndMaxIds[0] == null) || (minAndMaxIds[1] == null)) {
      return;
    }

    long minId = (Long) minAndMaxIds[0];
    long maxId = (Long) minAndMaxIds[1];

    long startId = minId;
    long endId = startId + DEFAULT_INTERVAL;

    while (startId <= maxId) {
      reindexArticles(companyId, startId, endId);

      startId = endId;
      endId += DEFAULT_INTERVAL;
    }
  }