Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-97939 Add filter contributor to DEDataListView search
- Loading branch information
1 parent
ed005e5
commit 9c621af
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
.../internal/search/spi/model/query/contributor/DEDataListViewModelPreFilterContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.data.engine.internal.search.spi.model.query.contributor; | ||
|
||
import com.liferay.portal.kernel.search.SearchContext; | ||
import com.liferay.portal.kernel.search.filter.BooleanFilter; | ||
import com.liferay.portal.kernel.util.GetterUtil; | ||
import com.liferay.portal.search.spi.model.query.contributor.ModelPreFilterContributor; | ||
import com.liferay.portal.search.spi.model.registrar.ModelSearchSettings; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* @author Jeyvison Nascimento | ||
*/ | ||
@Component( | ||
immediate = true, | ||
property = "indexer.class.name=com.liferay.data.engine.model.DEDataListView", | ||
service = ModelPreFilterContributor.class | ||
) | ||
public class DEDataListViewModelPreFilterContributor | ||
implements ModelPreFilterContributor { | ||
|
||
@Override | ||
public void contribute( | ||
BooleanFilter booleanFilter, ModelSearchSettings modelSearchSettings, | ||
SearchContext searchContext) { | ||
|
||
long ddmStructureId = GetterUtil.getLong( | ||
searchContext.getAttribute("ddmStructureId")); | ||
|
||
if (ddmStructureId > 0) { | ||
booleanFilter.addRequiredTerm("ddmStructureId", ddmStructureId); | ||
} | ||
} | ||
|
||
} |