Skip to content

Commit 4466c94

Browse files
shuyangzhoubrianchandotcom
authored andcommitted
LPD-17341 DDLRecordBatchReindexer is an internal interface, it should not be registered as osgi service
1 parent 72e543a commit 4466c94

File tree

3 files changed

+53
-64
lines changed

3 files changed

+53
-64
lines changed

modules/apps/dynamic-data-lists/dynamic-data-lists-service/src/main/java/com/liferay/dynamic/data/lists/internal/search/DDLRecordBatchReindexer.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,46 @@
55

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

8+
import com.liferay.dynamic.data.lists.model.DDLRecord;
9+
import com.liferay.portal.kernel.dao.orm.Property;
10+
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
11+
import com.liferay.portal.search.batch.BatchIndexingActionable;
12+
import com.liferay.portal.search.indexer.IndexerDocumentBuilder;
13+
import com.liferay.portal.search.indexer.IndexerWriter;
14+
815
/**
916
* @author Marcela Cunha
1017
*/
11-
public interface DDLRecordBatchReindexer {
18+
public class DDLRecordBatchReindexer {
19+
20+
public DDLRecordBatchReindexer(
21+
IndexerDocumentBuilder indexerDocumentBuilder,
22+
IndexerWriter<DDLRecord> indexerWriter) {
23+
24+
_indexerDocumentBuilder = indexerDocumentBuilder;
25+
_indexerWriter = indexerWriter;
26+
}
27+
28+
public void reindex(long ddlRecordSetId, long companyId) {
29+
BatchIndexingActionable batchIndexingActionable =
30+
_indexerWriter.getBatchIndexingActionable();
31+
32+
batchIndexingActionable.setAddCriteriaMethod(
33+
dynamicQuery -> {
34+
Property recordIdProperty = PropertyFactoryUtil.forName(
35+
"recordSetId");
36+
37+
dynamicQuery.add(recordIdProperty.eq(ddlRecordSetId));
38+
});
39+
batchIndexingActionable.setCompanyId(companyId);
40+
batchIndexingActionable.setPerformActionMethod(
41+
(DDLRecord record) -> batchIndexingActionable.addDocuments(
42+
_indexerDocumentBuilder.getDocument(record)));
43+
44+
batchIndexingActionable.performActions();
45+
}
1246

13-
public void reindex(long ddlRecordSetId, long companyId);
47+
private final IndexerDocumentBuilder _indexerDocumentBuilder;
48+
private final IndexerWriter<DDLRecord> _indexerWriter;
1449

1550
}

modules/apps/dynamic-data-lists/dynamic-data-lists-service/src/main/java/com/liferay/dynamic/data/lists/internal/search/DDLRecordBatchReindexerImpl.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

modules/apps/dynamic-data-lists/dynamic-data-lists-service/src/main/java/com/liferay/dynamic/data/lists/internal/search/DDLRecordSetModelSearchConfigurator.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
package com.liferay.dynamic.data.lists.internal.search;
77

88
import com.liferay.dynamic.data.lists.internal.search.spi.model.index.contributor.DDLRecordSetModelIndexerWriterContributor;
9+
import com.liferay.dynamic.data.lists.model.DDLRecord;
910
import com.liferay.dynamic.data.lists.model.DDLRecordSet;
1011
import com.liferay.dynamic.data.lists.service.DDLRecordSetLocalService;
1112
import com.liferay.portal.kernel.search.Field;
1213
import com.liferay.portal.search.batch.DynamicQueryBatchIndexingActionableFactory;
14+
import com.liferay.portal.search.indexer.IndexerDocumentBuilder;
15+
import com.liferay.portal.search.indexer.IndexerWriter;
1316
import com.liferay.portal.search.spi.model.index.contributor.ModelIndexerWriterContributor;
1417
import com.liferay.portal.search.spi.model.registrar.ModelSearchConfigurator;
1518

@@ -53,20 +56,29 @@ public String[] getDefaultSelectedLocalizedFieldNames() {
5356
protected void activate() {
5457
_modelIndexWriterContributor =
5558
new DDLRecordSetModelIndexerWriterContributor(
56-
_ddlRecordBatchReindexer, _ddlRecordSetLocalService,
59+
new DDLRecordBatchReindexer(
60+
_indexerDocumentBuilder, _indexerWriter),
61+
_ddlRecordSetLocalService,
5762
_dynamicQueryBatchIndexingActionableFactory);
5863
}
5964

60-
@Reference
61-
private DDLRecordBatchReindexer _ddlRecordBatchReindexer;
62-
6365
@Reference
6466
private DDLRecordSetLocalService _ddlRecordSetLocalService;
6567

6668
@Reference
6769
private DynamicQueryBatchIndexingActionableFactory
6870
_dynamicQueryBatchIndexingActionableFactory;
6971

72+
@Reference(
73+
target = "(indexer.class.name=com.liferay.dynamic.data.lists.model.DDLRecord)"
74+
)
75+
private IndexerDocumentBuilder _indexerDocumentBuilder;
76+
77+
@Reference(
78+
target = "(indexer.class.name=com.liferay.dynamic.data.lists.model.DDLRecord)"
79+
)
80+
private IndexerWriter<DDLRecord> _indexerWriter;
81+
7082
private ModelIndexerWriterContributor<DDLRecordSet>
7183
_modelIndexWriterContributor;
7284

0 commit comments

Comments
 (0)