public Object execute()

in core/src/main/java/org/apache/sdap/mudrod/ontology/process/OntologyLinkCal.java [72:114]


  public Object execute() {
    es.deleteType(props.getProperty(MudrodConstants.ES_INDEX_NAME), MudrodConstants.ONTOLOGY_LINKAGE_TYPE);
    es.createBulkProcessor();

    BufferedReader br = null;
    String line = "";
    double weight = 0;

    try {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(props.getProperty(MudrodConstants.ONTOLOGY_PATH)), StandardCharsets.UTF_8));
      while ((line = br.readLine()) != null) {
        String[] strList = line.toLowerCase(Locale.ENGLISH).split(",");
        if (strList[1].equals("subclassof")) {
          weight = 0.75;
        } else {
          weight = 0.9;
        }

        IndexRequest ir = new IndexRequest(props.getProperty(MudrodConstants.ES_INDEX_NAME), MudrodConstants.ONTOLOGY_LINKAGE_TYPE).source(
            jsonBuilder().startObject().field("concept_A", es.customAnalyzing(props.getProperty(MudrodConstants.ES_INDEX_NAME), strList[2]))
                .field("concept_B", es.customAnalyzing(props.getProperty(MudrodConstants.ES_INDEX_NAME), strList[0])).field("weight", weight).endObject());
        es.getBulkProcessor().add(ir);

      }

    } catch (IOException | ExecutionException | InterruptedException e) {
      LOG.error("Couldn't open file!", e);
      if (e instanceof InterruptedException) {
        Thread.currentThread().interrupt();
      }
    } finally {
      if (br != null) {
        try {
          br.close();
          es.destroyBulkProcessor();
          es.refreshIndex();
        } catch (IOException e) {
          LOG.error("Error whilst closing file!", e);
        }
      }
    }
    return null;
  }