public void setOntology(OWLOntology ont) {
    this.ont = ont;
    List<Object> data = new ArrayList<>();
    data.add(directImportsHeader);

    // @@TODO ordering
    for (OWLImportsDeclaration decl : ont.getImportsDeclarations()) {
      data.add(new OntologyImportItem(ont, decl, editorKit));
    }
    data.add(indirectImportsHeader);
    // @@TODO ordering
    try {
      for (OWLOntology ontRef :
          editorKit.getOWLModelManager().getOWLOntologyManager().getImportsClosure(ont)) {
        if (!ontRef.equals(ont)) {
          for (OWLImportsDeclaration dec : ontRef.getImportsDeclarations()) {
            if (!data.contains(dec)) {
              data.add(new OntologyImportItem(ontRef, dec, editorKit));
            }
          }
        }
      }
    } catch (UnknownOWLOntologyException e) {
      throw new OWLRuntimeException(e);
    }
    setListData(data.toArray());
  }
예제 #2
0
  public void mergeOntologies() {
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
    for (OWLOntology ont : ontologies) {
      if (!ont.equals(targetOntology)) {

        // move the axioms
        for (OWLAxiom ax : ont.getAxioms()) {
          changes.add(new AddAxiom(targetOntology, ax));
        }

        // move ontology annotations
        for (OWLAnnotation annot : ont.getAnnotations()) {
          changes.add(new AddOntologyAnnotation(targetOntology, annot));
        }

        if (!targetOntology.getOntologyID().isAnonymous()) {
          // move ontology imports
          for (OWLImportsDeclaration decl : ont.getImportsDeclarations()) {
            if (ontologies.contains(ont.getOWLOntologyManager().getImportedOntology(decl))) {
              continue;
            }
            Optional<IRI> defaultDocumentIRI =
                targetOntology.getOntologyID().getDefaultDocumentIRI();
            if (defaultDocumentIRI.isPresent() && !decl.getIRI().equals(defaultDocumentIRI.get())) {
              changes.add(new AddImport(targetOntology, decl));
            } else {
              logger.warn(
                  "Merge: ignoring import declaration for ontology "
                      + targetOntology.getOntologyID()
                      + " (would result in target ontology importing itself).");
            }
          }
        }
      }
    }
    try {
      owlOntologyManager.applyChanges(changes);
    } catch (OWLOntologyChangeException e) {
      ErrorLogPanel.showErrorDialog(e);
    }
  }
 /**
  * Determines if the reference ontology (if set) is equal to the active ontology.
  *
  * @return <code>true</code> if the reference ontology is equal to the active ontology, otherwise
  *     <code>false</code>.
  */
 public boolean isReferenceOntologyActive() {
   return ontology != null && ontology.equals(editorKit.getOWLModelManager().getActiveOntology());
 }