| 1 package com.dotmarketing.comparators; 2 3 import java.util.Comparator ; 4 5 import com.dotmarketing.beans.WebAsset; 6 import com.dotmarketing.cms.factories.PublicUserFactory; 7 import com.liferay.portal.model.User; 8 9 16 public class WebAssetTitleComparator implements Comparator { 17 18 private String orderType = ""; 19 20 public WebAssetTitleComparator(String orderType) { 21 super(); 22 this.orderType = orderType; 23 } 24 25 public int compare(Object o1, Object o2) { 26 27 try { 28 WebAsset w1 = (WebAsset) o1; 29 WebAsset w2 = (WebAsset) o2; 30 31 User user1 = PublicUserFactory.getUserByUserId(w1.getModUser()); 32 User user2 = PublicUserFactory.getUserByUserId(w2.getModUser()); 33 34 int ret = user1.getFullName().compareTo(user2.getFullName()); 35 36 if (orderType.equals("asc")) { 37 return ret; 38 } 39 40 return ret * -1; 41 42 } catch (ClassCastException e) { 43 44 } 45 return 0; 46 } 47 } | Popular Tags |