Skip to content

Commit

Permalink
LPS-97939 Add filter contributor to DEDataListView search
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeyvison Nascimento authored and brianchandotcom committed Jul 30, 2019
1 parent ed005e5 commit 9c621af
Showing 1 changed file with 49 additions and 0 deletions.
@@ -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);
}
}

}

0 comments on commit 9c621af

Please sign in to comment.