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