All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.journal.web.internal.dao.search.JournalResultRowSplitter Maven / Gradle / Ivy

There is a newer version: 5.0.181
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.journal.web.internal.dao.search;

import com.liferay.journal.model.JournalFolder;
import com.liferay.portal.kernel.dao.search.ResultRow;
import com.liferay.portal.kernel.dao.search.ResultRowSplitter;
import com.liferay.portal.kernel.dao.search.ResultRowSplitterEntry;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Eudaldo Alonso
 */
public class JournalResultRowSplitter implements ResultRowSplitter {

	@Override
	public List split(List resultRows) {
		List resultRowSplitterEntries =
			new ArrayList<>();

		List journalArticleResultRows = new ArrayList<>();
		List journalFolderResultRows = new ArrayList<>();

		for (ResultRow resultRow : resultRows) {
			Object object = resultRow.getObject();

			if (object instanceof JournalFolder) {
				journalFolderResultRows.add(resultRow);
			}
			else {
				journalArticleResultRows.add(resultRow);
			}
		}

		if (!journalFolderResultRows.isEmpty()) {
			resultRowSplitterEntries.add(
				new ResultRowSplitterEntry("folders", journalFolderResultRows));
		}

		if (!journalArticleResultRows.isEmpty()) {
			resultRowSplitterEntries.add(
				new ResultRowSplitterEntry(
					"web-content", journalArticleResultRows));
		}

		return resultRowSplitterEntries;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy