コード例 #1
0
  @Override
  protected void doReindex(JournalArticle article) throws Exception {
    if (PortalUtil.getClassNameId(DDMStructure.class) == article.getClassNameId()) {

      Document document = getDocument(article);

      IndexWriterHelperUtil.deleteDocument(
          getSearchEngineId(), article.getCompanyId(),
          document.get(Field.UID), isCommitImmediately());

      return;
    }

    reindexArticleVersions(article);
  }
コード例 #2
0
  @Override
  public void reindexDDMStructures(List<Long> ddmStructureIds) throws SearchException {

    if (IndexWriterHelperUtil.isIndexReadOnly() || !isIndexerEnabled()) {
      return;
    }

    try {
      Indexer<DLFileEntry> indexer = IndexerRegistryUtil.nullSafeGetIndexer(DLFileEntry.class);

      List<DLFileEntry> dlFileEntries =
          DLFileEntryLocalServiceUtil.getDDMStructureFileEntries(
              ArrayUtil.toLongArray(ddmStructureIds));

      for (DLFileEntry dlFileEntry : dlFileEntries) {
        indexer.reindex(dlFileEntry);
      }
    } catch (Exception e) {
      throw new SearchException(e);
    }
  }
コード例 #3
0
  @Override
  protected void doDelete(JournalArticle journalArticle) throws Exception {
    long classPK = journalArticle.getId();

    if (!isIndexAllArticleVersions()) {
      if (_journalArticleLocalService.getArticlesCount(
              journalArticle.getGroupId(), journalArticle.getArticleId())
          > 0) {

        doReindex(journalArticle);

        return;
      } else {
        classPK = journalArticle.getResourcePrimKey();
      }
    }

    deleteDocument(journalArticle.getCompanyId(), classPK);

    if (!journalArticle.isApproved()) {
      return;
    }

    JournalArticle latestIndexableArticle =
        _journalArticleLocalService.fetchLatestIndexableArticle(
            journalArticle.getResourcePrimKey());

    if ((latestIndexableArticle == null)
        || (latestIndexableArticle.getVersion() > journalArticle.getVersion())) {

      return;
    }

    IndexWriterHelperUtil.updateDocument(
        getSearchEngineId(), journalArticle.getCompanyId(),
        getDocument(latestIndexableArticle), isCommitImmediately());
  }
コード例 #4
0
  protected void reindexArticleVersions(JournalArticle article) throws PortalException {

    IndexWriterHelperUtil.updateDocuments(
        getSearchEngineId(), article.getCompanyId(),
        getArticleVersions(article), isCommitImmediately());
  }
コード例 #5
0
  @Override
  public void reindexDDMStructures(List<Long> ddmStructureIds) throws SearchException {

    if (IndexWriterHelperUtil.isIndexReadOnly() || !isIndexerEnabled()) {
      return;
    }

    try {
      final String[] ddmStructureKeys = new String[ddmStructureIds.size()];

      for (int i = 0; i < ddmStructureIds.size(); i++) {
        long ddmStructureId = ddmStructureIds.get(i);

        DDMStructure ddmStructure = _ddmStructureLocalService.getDDMStructure(ddmStructureId);

        ddmStructureKeys[i] = ddmStructure.getStructureKey();
      }

      final Indexer<JournalArticle> indexer =
          IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class);

      final ActionableDynamicQuery actionableDynamicQuery =
          _journalArticleLocalService.getActionableDynamicQuery();

      actionableDynamicQuery.setAddCriteriaMethod(
          new ActionableDynamicQuery.AddCriteriaMethod() {

            @Override
            public void addCriteria(DynamicQuery dynamicQuery) {
              Property ddmStructureKey = PropertyFactoryUtil.forName("DDMStructureKey");

              dynamicQuery.add(ddmStructureKey.in(ddmStructureKeys));

              if (!isIndexAllArticleVersions()) {
                Property statusProperty = PropertyFactoryUtil.forName("status");

                Integer[] statuses = {
                  WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH
                };

                dynamicQuery.add(statusProperty.in(statuses));
              }
            }
          });
      actionableDynamicQuery.setPerformActionMethod(
          new ActionableDynamicQuery.PerformActionMethod<JournalArticle>() {

            @Override
            public void performAction(JournalArticle article) throws PortalException {

              try {
                indexer.reindex(indexer.getClassName(), article.getResourcePrimKey());
              } catch (Exception e) {
                throw new PortalException(e);
              }
            }
          });

      actionableDynamicQuery.performActions();
    } catch (Exception e) {
      throw new SearchException(e);
    }
  }