Пример #1
0
 private static Map<String, List<FieldDescriptor>> getClassKeys(ObjectStore os) {
   Properties classKeyProps = new Properties();
   try {
     InputStream inputStream =
         ProfileManagerBinding.class.getClassLoader().getResourceAsStream("class_keys.properties");
     classKeyProps.load(inputStream);
   } catch (IOException ioe) {
     throw new BuildException("class_keys.properties not found", ioe);
   }
   return ClassKeyHelper.readKeys(os.getModel(), classKeyProps);
 }
Пример #2
0
  @Override
  public void execute() {
    System.out.println("Creating lucene index for keyword search...");

    ObjectStore os;
    try {
      os = getObjectStore();
    } catch (Exception e) {
      throw new BuildException(e);
    }
    if (!(os instanceof ObjectStoreInterMineImpl)) {
      // Yes, yes, this is horrific...
      throw new RuntimeException(
          "Got invalid ObjectStore - must be an " + "instance of ObjectStoreInterMineImpl!");
    }

    /*
    String configFileName = "objectstoresummary.config.properties";
    InputStream configStream = classLoader.getResourceAsStream(configFileName);
    if (configStream == null) {
        throw new RuntimeException("can't find resource: " + configFileName);
    }

    Properties properties = new Properties();
    properties.load(configStream);*/

    // read class keys to figure out what are keyFields during indexing
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("class_keys.properties");
    Properties classKeyProperties = new Properties();
    try {
      classKeyProperties.load(is);
    } catch (NullPointerException e) {
      throw new BuildException("Could not find the class keys");
    } catch (IOException e) {
      throw new BuildException("Could not read the class keys", e);
    }
    Map<String, List<FieldDescriptor>> classKeys =
        ClassKeyHelper.readKeys(os.getModel(), classKeyProperties);

    // index and save
    KeywordSearch.saveIndexToDatabase(os, classKeys);
    KeywordSearch.deleteIndexDirectory();
  }