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

com.liferay.fragment.web.internal.util.FragmentPortletUtil Maven / Gradle / Ivy

There is a newer version: 4.0.119
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.fragment.web.internal.util;

import com.liferay.fragment.model.FragmentCollection;
import com.liferay.fragment.util.comparator.FragmentCollectionCreateDateComparator;
import com.liferay.fragment.util.comparator.FragmentCollectionNameComparator;
import com.liferay.fragment.util.comparator.FragmentCompositionFragmentEntryModifiedDateComparator;
import com.liferay.fragment.util.comparator.FragmentCompositionFragmentEntryNameComparator;
import com.liferay.portal.kernel.util.OrderByComparator;

/**
 * @author Jürgen Kappler
 */
public class FragmentPortletUtil {

	public static OrderByComparator
		getFragmentCollectionOrderByComparator(
			String orderByCol, String orderByType) {

		boolean orderByAsc = false;

		if (orderByType.equals("asc")) {
			orderByAsc = true;
		}

		OrderByComparator orderByComparator = null;

		if (orderByCol.equals("create-date")) {
			orderByComparator =
				FragmentCollectionCreateDateComparator.getInstance(orderByAsc);
		}
		else if (orderByCol.equals("name")) {
			orderByComparator = FragmentCollectionNameComparator.getInstance(
				orderByAsc);
		}

		return orderByComparator;
	}

	public static OrderByComparator
		getFragmentCompositionAndEntryOrderByComparator(
			String orderByCol, String orderByType) {

		boolean orderByAsc = false;

		if (orderByType.equals("asc")) {
			orderByAsc = true;
		}

		OrderByComparator orderByComparator = null;

		if (orderByCol.equals("name")) {
			orderByComparator =
				FragmentCompositionFragmentEntryNameComparator.getInstance(
					orderByAsc);
		}
		else if (orderByCol.equals("modified-date")) {
			orderByComparator =
				FragmentCompositionFragmentEntryModifiedDateComparator.
					getInstance(orderByAsc);
		}

		return orderByComparator;
	}

}