public OWLOntology getMergedOntology() {
   final IRI mergedOntologyIRI =
       IRI.create(queryOntology.getOntologyID().getDefaultDocumentIRI() + "-merged");
   final OWLOntologyManager mm = controller.getOWLOntologyManager();
   if (mm.contains(mergedOntologyIRI)) {
     return mm.getOntology(mergedOntologyIRI);
   } else {
     try {
       final OWLOntology mergedOntology = mm.createOntology(mergedOntologyIRI);
       mm.setOntologyFormat(mergedOntology, new RDFXMLOntologyFormat());
       final String mergedOntologyFileName =
           mergedOntologyIRI
                   .toURI()
                   .toString()
                   .substring(mergedOntologyIRI.toURI().toString().lastIndexOf("/") + 1)
               + ".owl";
       mm.setOntologyDocumentIRI(
           mergedOntology,
           IRI.create(
               controller.getRuleSpec().getOutputDir().toURI() + "/" + mergedOntologyFileName));
       mm.applyChange(
           new AddImport(
               mergedOntology,
               mm.getOWLDataFactory()
                   .getOWLImportsDeclaration(
                       queryOntology.getOntologyID().getDefaultDocumentIRI())));
       return mergedOntology;
     } catch (OWLOntologyCreationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       return null;
     }
   }
 }
 private void createEmptyNotesOntology() {
   try {
     OWLOntologyManager notesOntologyManager = WebProtegeOWLManager.createOWLOntologyManager();
     notesOntology = notesOntologyManager.createOntology();
     IRI notesOntologyDocumentIRI = IRI.create(notesOntologyDocument);
     notesOntologyManager.setOntologyDocumentIRI(notesOntology, notesOntologyDocumentIRI);
     notesOntologyDocument.getParentFile().mkdirs();
     BinaryOWLOntologyDocumentFormat notesOntologyDocumentFormat =
         new BinaryOWLOntologyDocumentFormat();
     notesOntologyManager.saveOntology(
         notesOntology, notesOntologyDocumentFormat, notesOntologyDocumentIRI);
   } catch (OWLOntologyCreationException e) {
     throw new RuntimeException(e);
   } catch (OWLOntologyStorageException e) {
     throw new RuntimeException(e);
   }
 }