List of usage examples for org.apache.commons.collections SetUtils EMPTY_SORTED_SET
SortedSet EMPTY_SORTED_SET
To view the source code for org.apache.commons.collections SetUtils EMPTY_SORTED_SET.
Click Source Link
From source file:org.tonguetied.web.MainController.java
/** * Handler method that acts as an HTTP interface to the * {@linkplain KeywordService#getKeywords()} method. * /*w ww .j av a2 s. c om*/ * @param request the current HTTP request. * @param response the current HTTP response. * @return a ModelAndView to render. * @throws Exception in case of errors. */ public ModelAndView keywords(HttpServletRequest request, HttpServletResponse response) throws Exception { Cookie cookie = CookieUtils.getCookie(request, "menuSelected"); if (cookie == null) { cookie = CookieUtils.createCookie(request, "menuSelected", "1"); response.addCookie(cookie); } Boolean showAll = RequestUtils.getBooleanParameter(request, SHOW_ALL_KEYWORDS); if (showAll == null) { showAll = (Boolean) request.getSession().getAttribute(SHOW_ALL_KEYWORDS); } final int firstResult = PaginationUtils.calculateFirstResult(TABLE_ID_KEYWORD, viewPreferences.getMaxResults(), request); final KeyValue<String, Order> keyValue = PaginationUtils.getOrder(TABLE_ID_KEYWORD, request); Order order = null; if (keyValue != null) order = keyValue.getValue(); PaginatedList<Keyword> keywords; if (showAll) { keywords = keywordService.getKeywords(firstResult, viewPreferences.getMaxResults(), order); searchParameters.initialize(); } else { Keyword keyword = searchParameters.getKeyword(); if (new Translation().equals(keyword.getTranslations().first())) { keyword.setTranslations(SetUtils.EMPTY_SORTED_SET); } keywords = keywordService.findKeywords(keyword, searchParameters.getIgnoreCase(), order, firstResult, viewPreferences.getMaxResults()); } keywords = applyViewPreferences(keywords); searchParameters.getKeyword(); Map<String, Object> model = new HashMap<String, Object>(); model.put(KEYWORDS, keywords); model.put(LANGUAGES, keywordService.getLanguages()); model.put(BUNDLES, keywordService.getBundles()); model.put(COUNTRIES, keywordService.getCountries()); model.put(STATES, TranslationState.values()); model.put(SEARCH_PARAMETERS, searchParameters); model.put(VIEW_PREFERENCES, viewPreferences); model.put(MAX_LIST_SIZE, keywords.getMaxListSize()); model.put(PAGE_SIZES, KEYWORD_PAGE_SIZE_OPTIONS); return new ModelAndView("keyword/keywords", model); }