Esempio n. 1
0
 public void addSearchResult(SearchResult other) {
   if (other == null) {
     return;
   }
   addGeocodes(other.geocodes);
   addFilteredGeocodes(other.filteredGeocodes);
   if (StringUtils.isBlank(url)) {
     url = other.url;
   }
   // copy the GC total search results number to be able to use "More caches" button
   if (getTotalCountGC() == 0 && other.getTotalCountGC() != 0) {
     setViewstates(other.getViewstates());
     setTotalCountGC(other.getTotalCountGC());
   }
 }
Esempio n. 2
0
  /**
   * @param excludeDisabled
   * @param excludeMine
   * @param cacheType
   * @return
   */
  public SearchResult filterSearchResults(
      final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) {

    SearchResult result = new SearchResult(this);
    result.geocodes.clear();
    final ArrayList<Geocache> includedCaches = new ArrayList<Geocache>();
    final Set<Geocache> caches = DataStore.loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB);
    int excluded = 0;
    for (Geocache cache : caches) {
      // Is there any reason to exclude the cache from the list?
      final boolean excludeCache =
          (excludeDisabled && cache.isDisabled())
              || (excludeMine && (cache.isOwner() || cache.isFound()))
              || (!cacheType.contains(cache));
      if (excludeCache) {
        excluded++;
      } else {
        includedCaches.add(cache);
      }
    }
    result.addAndPutInCache(includedCaches);
    // decrease maximum number of caches by filtered ones
    result.setTotalCountGC(result.getTotalCountGC() - excluded);
    GCVote.loadRatings(includedCaches);
    return result;
  }
Esempio n. 3
0
 /**
  * Copy a search result, for example to apply different filters on it.
  *
  * @param searchResult the original search result, which cannot be null
  */
 public SearchResult(final SearchResult searchResult) {
   geocodes = new HashSet<String>(searchResult.geocodes);
   filteredGeocodes = new HashSet<String>(searchResult.filteredGeocodes);
   error = searchResult.error;
   url = searchResult.url;
   viewstates = searchResult.viewstates;
   setTotalCountGC(searchResult.getTotalCountGC());
 }