Skip to content

Commit

Permalink
LPD-17341 DDLRecordBatchReindexer is an internal interface, it should…
Browse files Browse the repository at this point in the history
… not be registered as osgi service
  • Loading branch information
shuyangzhou authored and brianchandotcom committed Feb 8, 2024
1 parent 72e543a commit 4466c94
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,46 @@

package com.liferay.dynamic.data.lists.internal.search;

import com.liferay.dynamic.data.lists.model.DDLRecord;
import com.liferay.portal.kernel.dao.orm.Property;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.search.batch.BatchIndexingActionable;
import com.liferay.portal.search.indexer.IndexerDocumentBuilder;
import com.liferay.portal.search.indexer.IndexerWriter;

/**
* @author Marcela Cunha
*/
public interface DDLRecordBatchReindexer {
public class DDLRecordBatchReindexer {

public DDLRecordBatchReindexer(
IndexerDocumentBuilder indexerDocumentBuilder,
IndexerWriter<DDLRecord> indexerWriter) {

_indexerDocumentBuilder = indexerDocumentBuilder;
_indexerWriter = indexerWriter;
}

public void reindex(long ddlRecordSetId, long companyId) {
BatchIndexingActionable batchIndexingActionable =
_indexerWriter.getBatchIndexingActionable();

batchIndexingActionable.setAddCriteriaMethod(
dynamicQuery -> {
Property recordIdProperty = PropertyFactoryUtil.forName(
"recordSetId");

dynamicQuery.add(recordIdProperty.eq(ddlRecordSetId));
});
batchIndexingActionable.setCompanyId(companyId);
batchIndexingActionable.setPerformActionMethod(
(DDLRecord record) -> batchIndexingActionable.addDocuments(
_indexerDocumentBuilder.getDocument(record)));

batchIndexingActionable.performActions();
}

public void reindex(long ddlRecordSetId, long companyId);
private final IndexerDocumentBuilder _indexerDocumentBuilder;
private final IndexerWriter<DDLRecord> _indexerWriter;

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
package com.liferay.dynamic.data.lists.internal.search;

import com.liferay.dynamic.data.lists.internal.search.spi.model.index.contributor.DDLRecordSetModelIndexerWriterContributor;
import com.liferay.dynamic.data.lists.model.DDLRecord;
import com.liferay.dynamic.data.lists.model.DDLRecordSet;
import com.liferay.dynamic.data.lists.service.DDLRecordSetLocalService;
import com.liferay.portal.kernel.search.Field;
import com.liferay.portal.search.batch.DynamicQueryBatchIndexingActionableFactory;
import com.liferay.portal.search.indexer.IndexerDocumentBuilder;
import com.liferay.portal.search.indexer.IndexerWriter;
import com.liferay.portal.search.spi.model.index.contributor.ModelIndexerWriterContributor;
import com.liferay.portal.search.spi.model.registrar.ModelSearchConfigurator;

Expand Down Expand Up @@ -53,20 +56,29 @@ public String[] getDefaultSelectedLocalizedFieldNames() {
protected void activate() {
_modelIndexWriterContributor =
new DDLRecordSetModelIndexerWriterContributor(
_ddlRecordBatchReindexer, _ddlRecordSetLocalService,
new DDLRecordBatchReindexer(
_indexerDocumentBuilder, _indexerWriter),
_ddlRecordSetLocalService,
_dynamicQueryBatchIndexingActionableFactory);
}

@Reference
private DDLRecordBatchReindexer _ddlRecordBatchReindexer;

@Reference
private DDLRecordSetLocalService _ddlRecordSetLocalService;

@Reference
private DynamicQueryBatchIndexingActionableFactory
_dynamicQueryBatchIndexingActionableFactory;

@Reference(
target = "(indexer.class.name=com.liferay.dynamic.data.lists.model.DDLRecord)"
)
private IndexerDocumentBuilder _indexerDocumentBuilder;

@Reference(
target = "(indexer.class.name=com.liferay.dynamic.data.lists.model.DDLRecord)"
)
private IndexerWriter<DDLRecord> _indexerWriter;

private ModelIndexerWriterContributor<DDLRecordSet>
_modelIndexWriterContributor;

Expand Down

0 comments on commit 4466c94

Please sign in to comment.