public int compare(Object obj1, Object obj2) { ShoppingItem item1 = (ShoppingItem) obj1; ShoppingItem item2 = (ShoppingItem) obj2; Long categoryId1 = new Long(item1.getCategoryId()); Long categoryId2 = new Long(item2.getCategoryId()); int value = categoryId1.compareTo(categoryId2); if (value == 0) { if (item1.getMinQuantity() < item2.getMinQuantity()) { value = -1; } else if (item1.getMinQuantity() > item2.getMinQuantity()) { value = 1; } } if (value == 0) { value = item1.getName().toLowerCase().compareTo(item2.getName().toLowerCase()); } if (_ascending) { return value; } else { return -value; } }
protected long getCategory(ShoppingItem item, long categoryId) throws SystemException { if ((item.getCategoryId() != categoryId) && (categoryId != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)) { ShoppingCategory newCategory = shoppingCategoryPersistence.fetchByPrimaryKey(categoryId); if ((newCategory == null) || (item.getGroupId() != newCategory.getGroupId())) { categoryId = item.getCategoryId(); } } return categoryId; }
public static boolean contains( PermissionChecker permissionChecker, ShoppingItem item, String actionId) throws PortalException, SystemException { if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) { if (item.getCategoryId() != ShoppingCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) { ShoppingCategory category = item.getCategory(); if (!ShoppingCategoryPermission.contains(permissionChecker, category, ActionKeys.VIEW)) { return false; } } } if (permissionChecker.hasOwnerPermission( item.getCompanyId(), ShoppingItem.class.getName(), item.getItemId(), item.getUserId(), actionId)) { return true; } return permissionChecker.hasPermission( item.getGroupId(), ShoppingItem.class.getName(), item.getItemId(), actionId); }
public ShoppingItem[] getItemsPrevAndNext(long itemId, OrderByComparator obc) throws PortalException, SystemException { ShoppingItem item = shoppingItemPersistence.findByPrimaryKey(itemId); return shoppingItemPersistence.findByG_C_PrevAndNext( item.getItemId(), item.getGroupId(), item.getCategoryId(), obc); }