示例#1
0
 /**
  * Deletes an ontology from Hypergraph Repository.
  *
  * @param physicalURI
  * @return
  */
 protected boolean handleDeleteFrom(OntologyRepositoryEntry ontologyEntry) {
   // A) Check, if the ontology is already loaded and/or managed and
   // whether it can be found in
   // the repository.
   OWLOntologyID oID = ((HGOntologyRepositoryEntry) ontologyEntry).getOntologyID();
   if (oID == null) throw new IllegalStateException();
   HGOwlModelManagerImpl hmm = (HGOwlModelManagerImpl) getOWLModelManager();
   PHGDBOntologyManagerImpl hom = (PHGDBOntologyManagerImpl) hmm.getOWLOntologyManager();
   OWLOntology loadedOntoToDelete = hom.getOntology(oID);
   // will be null if not loaded.
   // getOntologyCatalogManager().Ontologies()
   // B) Provide a confirmation Dialog with as much information as
   // possible.
   boolean userConfirmsDelete =
       showDeleteConfirmation(oID, ontologyEntry.getPhysicalURI(), loadedOntoToDelete);
   if (userConfirmsDelete) {
     // C) Actual Removal:
     // C-A) if ontology managed, remove from OwlModelManager,
     // Owlontologymanager
     if (loadedOntoToDelete != null) {
       if (!(hom.getOntologyFormat(loadedOntoToDelete) instanceof HGDBOntologyFormat)) {
         hmm.removeOntology(loadedOntoToDelete);
       } else {
         System.out.println(
             "File based ontology not unloaded :" + loadedOntoToDelete.getOntologyID());
       }
     }
     // C-B) delete in repository
     boolean repoDeleteOk = hom.getOntologyRepository().deleteOntology(oID);
     showDeleteSuccessOrFailure(repoDeleteOk, oID, ontologyEntry.getPhysicalURI());
     return repoDeleteOk;
   } else {
     JOptionPane.showMessageDialog(
         getWorkspace(),
         "Delete cancelled by user.                                ",
         "Delete Hypergraph Database Backed Ontology - Cancelled",
         JOptionPane.WARNING_MESSAGE);
     return false;
   }
 }