Пример #1
0
  @Override
  public SearchIndexBuilder makeSearchIndex() {
    SearchIndexBuilder sib = super.makeSearchIndex();
    sib.add(
        new CollectionSearchIndex<TopLevelItem>() { // for jobs in the view
          protected TopLevelItem get(String key) {
            return getItem(key);
          }

          protected Collection<TopLevelItem> all() {
            return getItems();
          }

          @Override
          protected String getName(TopLevelItem o) {
            // return the name instead of the display for suggestion searching
            return o.getName();
          }
        });

    // add the display name for each item in the search index
    addDisplayNamesToSearchIndex(sib, getItems());

    return sib;
  }
Пример #2
0
  void addDisplayNamesToSearchIndex(SearchIndexBuilder sib, Collection<TopLevelItem> items) {
    for (TopLevelItem item : items) {

      if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine(
            (String.format(
                "Adding url=%s,displayName=%s", item.getSearchUrl(), item.getDisplayName())));
      }
      sib.add(item.getSearchUrl(), item.getDisplayName());
    }
  }