コード例 #1
0
  public static MatchingTaskPreset[] getMatchingTaskPresets() {
    List<MatchingTaskPreset> loadedTaskList = loadMatchingTaskPresets();

    if (loadedTaskList == null) {
      return new MatchingTaskPreset[0];
    }

    // make sure the files exist
    List<MatchingTaskPreset> filteredTaskList = new LinkedList<>();
    for (MatchingTaskPreset p : loadedTaskList) {
      File sourceOntFile = new File(p.getSourceOntology());
      if (!sourceOntFile.exists()) {
        LOG.debug("Source ontology file not found. Ignoring preset:" + p);
        continue;
      }

      File targetOntFile = new File(p.getTargetOntology());
      if (!targetOntFile.exists()) {
        LOG.debug("Target ontology file not found. Ignoring preset:" + p);
        continue;
      }

      filteredTaskList.add(p);
    }

    return filteredTaskList.toArray(new MatchingTaskPreset[0]);
  }
コード例 #2
0
 /**
  * @param name
  * @return The MatchingTaskPreset with the given name. null if there is no MatchingTaskPreset with
  *     that name.
  */
 public static MatchingTaskPreset getMatchingTaskPreset(String name) {
   List<MatchingTaskPreset> loadedTaskList = loadMatchingTaskPresets();
   for (MatchingTaskPreset p : loadedTaskList) {
     if (p.getName().equals(name)) return p;
   }
   return null;
 }
コード例 #3
0
  /**
   * Verify that a MatchingTaskPreset is correctly specified.
   *
   * @return true if the MatchingTaskPreset is valid, false otherwise.
   */
  public static boolean isValid(MatchingTaskPreset p) {
    if (p == null) {
      LOG.trace("MatchingTaskPreset is null.");
      return false;
    }

    if (p.getName() == null || p.getName().isEmpty()) {
      LOG.trace("MatchingTaskPreset name is missing.");
      return false;
    }

    if (p.getSourceOntology() == null) {
      LOG.trace("MatchingTaskPreset sourceOntology cannot be null");
      return false;
    }
    File sourceFile = new File(p.getSourceOntology());
    if (!sourceFile.exists() || sourceFile.isDirectory()) {
      LOG.trace("MatchingTaskPreset sourceOntology file not found.");
      return false;
    }

    if (p.getTargetOntology() == null) {
      LOG.trace("MatchingTaskPreset targetOntology cannot be null");
      return false;
    }
    File targetFile = new File(p.getTargetOntology());
    if (!targetFile.exists() || targetFile.isDirectory()) {
      LOG.trace("MatchingTaskPreset targetOntology file not found.");
      return false;
    }

    if (p.hasReference()) {
      if (p.getReference() == null) {
        LOG.trace("MatchingTaskPreset reference cannot be null when hasReference() is true.");
        return false;
      }
      File refFile = new File(p.getReference());
      if (!refFile.exists() || refFile.isDirectory()) {
        LOG.trace("MatchingTaskPreset reference file not found.");
        return false;
      }
    }

    return true;
  }