001
014
015 package com.liferay.portlet.softwarecatalog.util;
016
017 import com.liferay.portal.kernel.util.OrderByComparator;
018 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
019 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryCreateDateComparator;
020 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryModifiedDateComparator;
021 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryNameComparator;
022 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryTypeComparator;
023
024
027 public class SCUtil {
028
029 public static OrderByComparator<SCProductEntry>
030 getProductEntryOrderByComparator(
031 String orderByCol, String orderByType) {
032
033 boolean orderByAsc = false;
034
035 if (orderByType.equals("asc")) {
036 orderByAsc = true;
037 }
038
039 OrderByComparator<SCProductEntry> orderByComparator = null;
040
041 if (orderByCol.equals("create-date")) {
042 orderByComparator = new ProductEntryCreateDateComparator(
043 orderByAsc);
044 }
045 else if (orderByCol.equals("modified-date")) {
046 orderByComparator = new ProductEntryModifiedDateComparator(
047 orderByAsc);
048 }
049 else if (orderByCol.equals("name")) {
050 orderByComparator = new ProductEntryNameComparator(orderByAsc);
051 }
052 else if (orderByCol.equals("type")) {
053 orderByComparator = new ProductEntryTypeComparator(orderByAsc);
054 }
055
056 return orderByComparator;
057 }
058
059 }