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 } } };
Map<String, String> getCommonParameters() throws UIException { Map<String, String> paramMap = new HashMap<String, String>(); paramMap.put(BrowseParams.TYPE, scope.getBrowseIndex().getName()); if (scope.getFilterValue() != null) { paramMap.put(scope.getAuthorityValue() != null? BrowseParams.FILTER_VALUE[1]:BrowseParams.FILTER_VALUE[0], scope.getFilterValue()); } if (scope.getFilterValueLang() != null) { paramMap.put(BrowseParams.FILTER_VALUE_LANG, scope.getFilterValueLang()); } return paramMap; }
Map<String, String> getControlParameters() throws UIException { Map<String, String> paramMap = new HashMap<String, String>(); paramMap.put(BrowseParams.SORT_BY, Integer.toString(this.scope.getSortBy())); paramMap.put(BrowseParams.ORDER, AbstractDSpaceTransformer.encodeForURL(this.scope.getOrder())); paramMap.put(BrowseParams.RESULTS_PER_PAGE, Integer .toString(this.scope.getResultsPerPage())); paramMap.put(BrowseParams.ETAL, Integer.toString(this.etAl)); return paramMap; }
params.scope = new BrowserScope(context); params.scope.setCommunity((Community) dso); params.scope.setCollection((Collection) dso); params.scope.setBrowseIndex(bi); params.scope.setSortBy(sortBy); params.scope.setJumpToItem(RequestUtils.getIntParameter(request, BrowseParams.JUMPTO_ITEM)); params.scope.setOrder(request.getParameter(BrowseParams.ORDER)); params.scope.setOffset(RequestUtils.getIntParameter(request, BrowseParams.OFFSET)); params.scope.setResultsPerPage(RequestUtils.getIntParameter(request, BrowseParams.RESULTS_PER_PAGE)); params.scope.setStartsWith(request.getParameter(BrowseParams.STARTS_WITH)); String filterValue = request.getParameter(BrowseParams.FILTER_VALUE[0]); if (filterValue == null) params.scope.setAuthorityValue(filterValue); params.scope.setFilterValue(filterValue); params.scope.setJumpToValue(request.getParameter(BrowseParams.JUMPTO_VALUE)); params.scope.setJumpToValueLang(request.getParameter(BrowseParams.JUMPTO_VALUE_LANG)); params.scope.setFilterValueLang(request.getParameter(BrowseParams.FILTER_VALUE_LANG)); if (params.scope.getFilterValue() != null) params.scope.setBrowseLevel(1);
BrowserScope scope = new BrowserScope(context); scope.setBrowseIndex(bi); scope.setOrder(order); scope.setFilterValue(value != null?value:authority); scope.setFilterValueLang(valueLang); scope.setJumpToItem(focus); scope.setJumpToValue(valueFocus); scope.setJumpToValueLang(valueFocusLang); scope.setStartsWith(startsWith); scope.setOffset(offset); scope.setResultsPerPage(resultsperpage); scope.setSortBy(sortBy); scope.setBrowseLevel(level); scope.setEtAl(etAl); scope.setAuthorityValue(authority); scope.setBrowseContainer(community); scope.setBrowseContainer(collection); if (bi != null && bi.isMetadataIndex() && scope.isSecondLevel() && scope.getSortBy() <= 0) scope.setSortBy(1);
dao.setAscending(scope.isAscending()); if (scope.hasFilterValue() && scope.isSecondLevel()) { String value = scope.getFilterValue(); rawValue = value; value = OrderFormat.makeSortString(value, scope.getFilterValueLang(), scope.getBrowseIndex().getDataType()); dao.setAuthorityValue(scope.getAuthorityValue()); if (scope.isSecondLevel()) { dao.setFilterValueField("value"); dao.setFilterValue(rawValue); dao.setFilterValuePartial(scope.getFilterValuePartial()); if (scope.inCollection() || scope.inCommunity()) { if (scope.inCollection()) { Collection col = (Collection) scope.getBrowseContainer(); dao.setContainerTable("collection2item"); dao.setContainerIDField("collection_id"); dao.setContainerID(col.getID()); } else if (scope.inCommunity()) { Community com = (Community) scope.getBrowseContainer(); dao.setContainerTable("communities2item"); dao.setContainerIDField("community_id"); String orderBy = browseIndex.getSortField(scope.isSecondLevel());
browseIndex = scope.getBrowseIndex(); dao.setAscending(scope.isAscending()); if (scope.inCollection() || scope.inCommunity()) { if (scope.inCollection()) { Collection col = (Collection) scope.getBrowseContainer(); dao.setContainerTable("collection2item"); dao.setContainerIDField("collection_id"); dao.setContainerID(col.getID()); } else if (scope.inCommunity()) { Community com = (Community) scope.getBrowseContainer(); dao.setContainerTable("communities2item"); dao.setContainerIDField("community_id"); dao.setOffset(scope.getOffset()); dao.setLimit(scope.getResultsPerPage()); String orderBy = browseIndex.getSortField(scope.isSecondLevel()); if (scope.getSortBy() > 0) { orderBy = "sort_" + Integer.toString(scope.getSortBy()); BrowseInfo browseInfo = new BrowseInfo(results, 0, scope.getResultsPerPage(), 0); browseInfo.setSortOption(scope.getSortOption()); browseInfo.setAscending(scope.isAscending()); if (scope.inCollection() || scope.inCommunity()) {
BrowserScope scope = new BrowserScope(context); scope.setCommunity(community); scope.setResultsPerPage(numRecentSubmissions); scope.setBrowseIndex(BrowseIndex.getItemBrowseIndex()); for (SortOption so : SortOption.getSortOptions()) scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING);
log.info(LogManager.getHeader(context, "browse_by_value", "focus=" + bs.getJumpToValue())); dao.setStartsWith(StringUtils.lowerCase(scope.getStartsWith())); dao.setAscending(scope.isAscending()); if (scope.inCollection() || scope.inCommunity()) { if (scope.inCollection()) { Collection col = (Collection) scope.getBrowseContainer(); dao.setContainerTable("collection2item"); dao.setContainerIDField("collection_id"); dao.setContainerID(col.getID()); } else if (scope.inCommunity()) { Community com = (Community) scope.getBrowseContainer(); dao.setContainerTable("communities2item"); dao.setContainerIDField("community_id"); int offset = scope.getOffset(); String rawFocusValue = null; if (offset < 1 && scope.hasJumpToValue() || scope.hasStartsWith()) { rawFocusValue = getJumpToValue(); dao.setLimit(scope.getResultsPerPage()); offset = total - scope.getResultsPerPage(); if (offset < 0) { offset = 0;
try BrowserScope bs = new BrowserScope(context); BrowseIndex bi = BrowseIndex.getBrowseIndex(bidx); bs.setBrowseIndex(bi); bs.setOrder(SortOption.ASCENDING); bs.setFilterValue(name); bs.setFilterValuePartial(true); bs.setJumpToValue(null); bs.setResultsPerPage(10000); // an arbitrary number (large) for the time being bs.setBrowseLevel(1);
BrowserScope scope = new BrowserScope(context); scope.setBrowseIndex(bix); if (dso != null) scope.setBrowseContainer(dso); scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING); scope.setResultsPerPage(itemCount);
/** * Return a normalized focus value. If there is no normalization that can be performed, * return the focus value that is passed in. * * @param value a focus value to normalize * @return the normalized focus value * @throws BrowseException if browse error */ private String normalizeJumpToValue(String value) throws BrowseException { // If the scope has a focus value (focus by value) if (scope.hasJumpToValue()) { // Normalize it based on the specified language as appropriate for this index return OrderFormat.makeSortString(scope.getJumpToValue(), scope.getJumpToValueLang(), scope.getBrowseIndex().getDataType()); } else if (scope.hasStartsWith()) { // Scope has a starts with, so normalize that instead return OrderFormat.makeSortString(scope.getStartsWith(), null, scope.getBrowseIndex().getDataType()); } // No focus value on the scope (ie. focus by id), so just return the passed focus value // This is useful in cases where we have pulled a focus value from the index // which will already be normalized, and avoids another DB lookup return value; }
if (scope.hasJumpToValue()) { log.debug(LogManager.getHeader(context, "get_focus_value_return", "return=" + scope.getJumpToValue())); return scope.getJumpToValue(); if (scope.hasStartsWith()) { log.debug(LogManager.getHeader(context, "get_focus_value_return", "return=" + scope.getStartsWith())); return scope.getStartsWith(); int id = scope.getJumpToItem(); SortOption so = scope.getSortOption(); if (so == null || so.getNumber() == 0) { if (browseIndex.getSortOption() != null) {
Map<String, String> getCommonParameters() throws UIException { Map<String, String> paramMap = new HashMap<String, String>(); if (scope.getFilterValue() != null) { paramMap.put(scope.getAuthorityValue() != null? BrowseParams.FILTER_VALUE[1]:BrowseParams.FILTER_VALUE[0], AbstractDSpaceTransformer.encodeForURL( scope.getFilterValue())); } if (scope.getFilterValueLang() != null) { paramMap.put(BrowseParams.FILTER_VALUE_LANG, AbstractDSpaceTransformer.encodeForURL( scope.getFilterValueLang())); } return paramMap; }
/** * Perform a standard browse, which will return a BrowseInfo * object that represents the results for the current page, the * total number of results, the range, and information to construct * previous and next links on any web page * * @param bs the scope of the browse * @return the results of the browse * @throws BrowseException if browse error */ public BrowseInfo browse(BrowserScope bs) throws BrowseException { log.debug(LogManager.getHeader(context, "browse", "")); // first, load the browse scope into the object this.scope = bs; // since we use it so much, get the browse index out of the // scope and store as a member browseIndex = scope.getBrowseIndex(); // now make the decision as to how to browse if (browseIndex.isMetadataIndex() && !scope.isSecondLevel()) { // this is a single value browse type that has not gone to // the second level (i.e. authors, not items by a given author) return browseByValue(scope); } else { // this is the full browse type or a browse that has gone to // the second level return browseByItem(scope); } }
if (scope.getBrowseIndex() == null || scope.getBrowseIndex().isItemIndex()) scope.setBrowseIndex(BrowseIndex.getWithdrawnBrowseIndex());
/** * @return true if ascending, false if not - or not set */ public boolean isAscending() { if (SortOption.ASCENDING.equalsIgnoreCase(order)) { return true; } if (SortOption.DESCENDING.equalsIgnoreCase(order)) { return false; } BrowseIndex bi = getBrowseIndex(); if (bi != null && SortOption.DESCENDING.equalsIgnoreCase(bi.getDefaultOrder())) { return false; } return true; }
params.scope = new BrowserScope(context); params.scope.setCommunity((Community) dso); params.scope.setCollection((Collection) dso); params.scope.setBrowseIndex(bi); params.scope.setSortBy(sortBy); params.scope.setJumpToItem(RequestUtils.getIntParameter(request, BrowseParams.JUMPTO_ITEM)); params.scope.setOrder(request.getParameter(BrowseParams.ORDER)); int offset = RequestUtils.getIntParameter(request, BrowseParams.OFFSET); params.scope.setOffset(offset > 0 ? offset : 0); params.scope.setResultsPerPage(RequestUtils.getIntParameter(request, BrowseParams.RESULTS_PER_PAGE)); params.scope.setStartsWith(decodeFromURL(request.getParameter(BrowseParams.STARTS_WITH))); String filterValue = request.getParameter(BrowseParams.FILTER_VALUE[0]); if (filterValue == null) params.scope.setAuthorityValue(filterValue); params.scope.setFilterValue(filterValue); params.scope.setJumpToValue(decodeFromURL(request.getParameter(BrowseParams.JUMPTO_VALUE))); params.scope.setJumpToValueLang(decodeFromURL(request.getParameter(BrowseParams.JUMPTO_VALUE_LANG))); params.scope.setFilterValueLang(decodeFromURL(request.getParameter(BrowseParams.FILTER_VALUE_LANG))); if (params.scope.getFilterValue() != null) params.scope.setBrowseLevel(1);
BrowserScope scope = new BrowserScope(context); scope.setCollection(collection); scope.setResultsPerPage(numRecentSubmissions); scope.setBrowseIndex(BrowseIndex.getItemBrowseIndex()); for (SortOption so : SortOption.getSortOptions()) scope.setSortBy(so.getNumber()); scope.setOrder(SortOption.DESCENDING);
BrowserScope bs = new BrowserScope(context); BrowseIndex bi = BrowseIndex.getItemBrowseIndex(); bs.setBrowseIndex(bi); bs.setOrder(SortOption.DESCENDING); bs.setResultsPerPage(Integer.parseInt(count)); bs.setBrowseContainer(dso); for (SortOption so : SortOption.getSortOptions()) bs.setSortBy(so.getNumber());