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

com.liferay.fragment.service.persistence.impl.FragmentEntryLinkFinderImpl Maven / Gradle / Ivy

/**
 * 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.fragment.service.persistence.impl;

import com.liferay.fragment.model.FragmentEntryLink;
import com.liferay.fragment.model.impl.FragmentEntryLinkImpl;
import com.liferay.fragment.service.persistence.FragmentEntryLinkFinder;
import com.liferay.portal.dao.orm.custom.sql.CustomSQL;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.OrderByComparator;

import java.util.List;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
 * @author Pavel Savinov
 */
@Component(service = FragmentEntryLinkFinder.class)
public class FragmentEntryLinkFinderImpl
	extends FragmentEntryLinkFinderBaseImpl implements FragmentEntryLinkFinder {

	public static final String FIND_BY_G_F =
		FragmentEntryLinkFinder.class.getName() + ".findByG_F";

	public static final String FIND_BY_G_F_P =
		FragmentEntryLinkFinder.class.getName() + ".findByG_F_P";

	public static final String FIND_BY_G_F_P_L =
		FragmentEntryLinkFinder.class.getName() + ".findByG_F_P_L";

	@Override
	public List findByG_F(
		long groupId, long fragmentEntryId, int start, int end,
		OrderByComparator orderByComparator) {

		Session session = null;

		try {
			session = openSession();

			String sql = _customSQL.get(getClass(), FIND_BY_G_F);

			sql = _customSQL.replaceOrderBy(sql, orderByComparator);

			SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);

			sqlQuery.addEntity(
				"FragmentEntryLink", FragmentEntryLinkImpl.class);

			QueryPos queryPos = QueryPos.getInstance(sqlQuery);

			queryPos.add(groupId);
			queryPos.add(fragmentEntryId);

			return (List)QueryUtil.list(
				sqlQuery, getDialect(), start, end);
		}
		catch (Exception exception) {
			throw new SystemException(exception);
		}
		finally {
			closeSession(session);
		}
	}

	@Override
	public List findByG_F_P_L(
		long groupId, long fragmentEntryId, int layoutPageTemplateEntryType,
		int start, int end,
		OrderByComparator orderByComparator) {

		Session session = null;

		try {
			session = openSession();

			String sql = null;

			if (layoutPageTemplateEntryType >= 0) {
				sql = _customSQL.get(getClass(), FIND_BY_G_F_P_L);
			}
			else {
				sql = _customSQL.get(getClass(), FIND_BY_G_F_P);
			}

			sql = _customSQL.replaceOrderBy(sql, orderByComparator);

			SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);

			sqlQuery.addEntity(
				"FragmentEntryLink", FragmentEntryLinkImpl.class);

			QueryPos queryPos = QueryPos.getInstance(sqlQuery);

			if (layoutPageTemplateEntryType >= 0) {
				queryPos.add(layoutPageTemplateEntryType);
			}

			queryPos.add(groupId);
			queryPos.add(fragmentEntryId);

			return (List)QueryUtil.list(
				sqlQuery, getDialect(), start, end);
		}
		catch (Exception exception) {
			throw new SystemException(exception);
		}
		finally {
			closeSession(session);
		}
	}

	@Reference
	private CustomSQL _customSQL;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy