/** * Get the defined sort option by number (.1, .2, etc). * * @param number the number of the sort option as given in the config file * @return the configured sort option with given number * @throws SortException if sort error */ public static SortOption getSortOption(int number) throws SortException { for (SortOption so : SortOption.getSortOptions()) { if (so.getNumber() == number) { return so; } } return null; }
/** * Get the field for sorting associated with this index. * * @param isSecondLevel whether second level browse * @return sort field * @throws BrowseException if browse error */ public String getSortField(boolean isSecondLevel) throws BrowseException { String focusField; if (isMetadataIndex() && !isSecondLevel) { focusField = "sort_value"; } else { if (sortOption != null) { focusField = "sort_" + sortOption.getNumber(); } else { focusField = "sort_1"; // Use the first sort column } } return focusField; }
/** * Convert the value into an offset into the table for this browse * * @param value value * @return the focus value to use * @throws BrowseException if browse error */ private int getOffsetForValue(String value) throws BrowseException { // we need to make sure that we select from the correct column. If the sort option // is the 0th option then we use sort_value, but if it is one of the others we have // to select from that column instead. Otherwise, we end up missing the focus value // to do comparisons in other columns. The use of the focus value needs to be consistent // across the browse SortOption so = scope.getSortOption(); if (so == null || so.getNumber() == 0) { if (browseIndex.getSortOption() != null) { so = browseIndex.getSortOption(); } } String col = "sort_1"; if (so.getNumber() > 0) { col = "sort_" + Integer.toString(so.getNumber()); } // now get the DAO to do the query for us, returning the highest // string value in the given column in the given table for the // item (I think) return dao.doOffsetQuery(col, value, scope.isAscending()); }
" (option " + Integer.toString(sortOption.getNumber()) + ")"); sb.append("||");
scope.setSortBy(so.getNumber());
scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING);
scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING);
.makeSortString(dcvalue.get(0).getValue(), dcvalue.get(0).getLanguage(), so.getType()); document.addField("bi_sort_" + so.getNumber() + "_sort", nValue);
scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING);
sortSelect.addOption(so.equals(info.getSortOption()), so.getNumber(), message("xmlui.ArtifactBrowser.ConfigurableBrowse.sort_by." + so.getName()));
if (so.getNumber() == sortBy) { sortOption = so;
bs.setSortBy(so.getNumber());
sortSelect.addOption(so.equals(info.getSortOption()), so.getNumber(), message("xmlui.ArtifactBrowser.ConfigurableBrowse.sort_by." + so.getName()));
if (so != null) sortBy = so.getNumber();
if (so != null) sortBy = so.getNumber();
String getKey() { try { String key = ""; key += "-" + scope.getBrowseIndex().getName(); key += "-" + scope.getBrowseLevel(); key += "-" + scope.getStartsWith(); key += "-" + scope.getResultsPerPage(); key += "-" + scope.getSortBy(); key += "-" + scope.getSortOption().getNumber(); key += "-" + scope.getOrder(); key += "-" + scope.getOffset(); key += "-" + scope.getJumpToItem(); key += "-" + scope.getFilterValue(); key += "-" + scope.getFilterValueLang(); key += "-" + scope.getJumpToValue(); key += "-" + scope.getJumpToValueLang(); key += "-" + etAl; return key; } catch (BrowseException e) { return null; // ignore exception and return no key } } };
key += "-" + scope.getResultsPerPage(); key += "-" + scope.getSortBy(); key += "-" + scope.getSortOption().getNumber(); key += "-" + scope.getOffset(); key += "-" + scope.getJumpToItem();