Exemplo n.º 1
0
  /** {@inheritDoc} */
  public boolean loadIndex(int searcher, File indexPath)
      throws SearchableNotSupportedException, IndexException {
    byte count = 0;
    Searchable searchable = this.searchableHash.get(searcher);
    File newFile = null;

    if (searchable == null || !(searchable instanceof SearchEngine)) {
      throw new SearchableNotSupportedException(
          "The searcher " + searcher + " is not supported for this operation");
    } else if (searchable.isEnabled()) {
      switch (searcher) {
        case LUCENE_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/lucene/index"));
          break;
        case MINION_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/minion/index"));
          break;
        case TERRIER_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/terrier/index"));
          break;
        case INDRI_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/indri/index"));
          break;
      }
      ((SearchEngine) searchable).loadIndex(newFile);
      count++;
    }

    if (count > 0) {
      return true;
    }
    return false;
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public long updateIndex(int searcher, List<File> collectionPath, File indexPath)
      throws SearchableNotSupportedException, IndexException {
    long count = 0;
    Searchable searchable = this.searchableHash.get(searcher);
    File newFile = null;

    if (searchable == null || !(searchable instanceof SearchEngine)) {
      throw new SearchableNotSupportedException(
          "The searcher " + searcher + " is not supported for this operation");
    } else if (searchable.isEnabled()) {
      switch (searcher) {
        case LUCENE_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/lucene/index"));
          break;
        case MINION_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/minion/index"));
          break;
        case TERRIER_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/terrier/index"));
          break;
        case INDRI_SEARCH_ENGINE:
          newFile = new File(indexPath.getPath().concat("/indri/index"));
          break;
      }
      count = ((SearchEngine) searchable).updateIndex(collectionPath, newFile);
    }
    return count;
  }
Exemplo n.º 3
0
  /** {@inheritDoc} */
  public long makeIndex(List<File> collectionPath) throws IndexException {
    long count = 0;
    SearchEngine engine;

    for (Searchable searchable : searcherList) {
      if (searchable instanceof SearchEngine && searchable.isEnabled()) {
        engine = (SearchEngine) searchable;
        count += engine.makeIndex(collectionPath);
      }
    }

    return count;
  }
Exemplo n.º 4
0
  /** {@inheritDoc} */
  public long updateIndex(int searcher, List<File> collectionPath)
      throws SearchableNotSupportedException, IndexException {
    long count = 0;
    Searchable searchable = this.searchableHash.get(searcher);

    if (searchable == null || !(searchable instanceof SearchEngine)) {
      throw new SearchableNotSupportedException(
          "The searcher " + searcher + " is not supported for this operation");
    } else if (searchable.isEnabled()) {
      count = ((SearchEngine) searchable).updateIndex(collectionPath);
    }
    return count;
  }
Exemplo n.º 5
0
  /** {@inheritDoc} */
  public boolean loadIndex(File indexPath) throws IndexException {

    byte count = 0;

    for (Searchable searchable : searcherList) {
      if (searchable instanceof SearchEngine && searchable.isEnabled()) {
        ((SearchEngine) searchable).loadIndex(indexPath);
        count++;
      }
    }

    if (count > 0) {
      return true;
    }
    return false;
  }
Exemplo n.º 6
0
  /**
   * To make an index from an SVN repository
   *
   * @param url
   * @param repListFile
   * @param indexPath
   * @param user
   * @param password
   * @param mergeFactor
   * @param directPath
   * @param facade
   * @return
   * @throws IndexException
   */
  public long makeSVNIndex(
      String url,
      String repListFile,
      String indexPath,
      String user,
      String password,
      String mergeFactor,
      String directPath,
      FacadeDesktopListener facade)
      throws IndexException, SearchableNotSupportedException, IndexException {

    Properties p = new Properties();
    p.setProperty("url", url);

    if (repListFile == null) {
      p.setProperty("directPath", directPath);
    } else {
      p.setProperty("repListFile", repListFile);
    }

    p.setProperty("indexPath", indexPath);

    if (user != null && password != null) {
      p.setProperty("user", user);
      p.setProperty("password", password);
    }

    p.setProperty("mergeFactor", mergeFactor); // max loadedDocs of files keept in memory by Lucene

    long count = 0;
    int searcher = KeySearchable.SVN_SEARCHER;
    Searchable searchable = this.searchableHash.get(searcher);

    if (searchable == null || !(searchable instanceof CVSSearch)) {
      throw new SearchableNotSupportedException(
          "The searcher " + searcher + " is not supported for this operation");
    } else if (searchable.isEnabled()) {

      CVSSearch search = ((CVSSearch) searchable);
      search.setListener(facade);
      search.setProperties(p);
      count = search.makeIndex();
    }
    return count;
  }
Exemplo n.º 7
0
  /** {@inheritDoc} */
  public boolean loadIndex(int searcher) throws SearchableNotSupportedException, IndexException {
    byte count = 0;
    Searchable searchable = this.searchableHash.get(searcher);

    if (searchable == null || !(searchable instanceof SearchEngine)) {
      throw new SearchableNotSupportedException(
          "The searcher " + searcher + " is not supported for this operation");
    } else if (searchable.isEnabled()) {

      ((SearchEngine) searchable).loadIndex();
      count++;
    }

    if (count > 0) {
      return true;
    }
    return false;
  }
Exemplo n.º 8
0
  private long batchMakeIndex(File collectionPath) throws IndexException {
    long count = 0;
    SearchEngine engine;
    boolean flag = false;
    if (collectionPath == null) {
      flag = true;
    }

    for (Searchable searchable : searcherList) {
      if (searchable instanceof SearchEngine && searchable.isEnabled()) {
        engine = (SearchEngine) searchable;
        if (flag) {
          count += engine.makeIndex();
        } else {
          count += engine.makeIndex(collectionPath);
        }
      }
    }

    return count;
  }