1
22
23 package com.liferay.portlet.softwarecatalog.util;
24
25 import com.liferay.portal.kernel.util.OrderByComparator;
26 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryCreateDateComparator;
27 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryModifiedDateComparator;
28 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryNameComparator;
29 import com.liferay.portlet.softwarecatalog.util.comparator.ProductEntryTypeComparator;
30
31
37 public class SCUtil {
38
39 public static OrderByComparator getProductEntryOrderByComparator(
40 String orderByCol, String orderByType) {
41
42 boolean orderByAsc = false;
43
44 if (orderByType.equals("asc")) {
45 orderByAsc = true;
46 }
47
48 OrderByComparator orderByComparator = null;
49
50 if (orderByCol.equals("create-date")) {
51 orderByComparator =
52 new ProductEntryCreateDateComparator(orderByAsc);
53 }
54 else if (orderByCol.equals("modified-date")) {
55 orderByComparator =
56 new ProductEntryModifiedDateComparator(orderByAsc);
57 }
58 else if (orderByCol.equals("name")) {
59 orderByComparator = new ProductEntryNameComparator(orderByAsc);
60 }
61 else if (orderByCol.equals("type")) {
62 orderByComparator = new ProductEntryTypeComparator(orderByAsc);
63 }
64
65 return orderByComparator;
66 }
67
68 }