Пример #1
0
 public boolean handleDeleteFromRepositoryRequest() throws Exception {
   if (DBG) System.out.println("HG HandleDeleteFromRepositoryRequest");
   boolean success;
   HGDBOntologyManager m = (HGDBOntologyManager) this.getModelManager().getOWLOntologyManager();
   m.getOntologyRepository().printStatistics();
   // Find our Repository
   OntologyRepository repository = getProtegeRepository();
   if (repository == null)
     throw new IllegalStateException(
         "Cannot handle delete from repository. No HGOwlOntologyRepository registered with Protege.");
   // Open Repository delete dialog
   OntologyRepositoryEntry ontologyEntry = RepositoryViewPanel.showDeleteDialog(repository);
   if (ontologyEntry != null) {
     // User wants to delete ontology.
     // Do not allow deletion of any active ontology:
     if (isLoadedOntologyFromLocation(ontologyEntry.getPhysicalURI())) {
       // Dialog, cannot delete active ontology. Remove from sources
       // first.
       showDeleteCannotDeleteLoaded(ontologyEntry.getPhysicalURI());
       success = false;
     } else {
       success = handleDeleteFrom(ontologyEntry);
     }
   } else {
     success = false;
   }
   //
   if (DBG) m.getOntologyRepository().printStatistics();
   return success;
 }
Пример #2
0
 public boolean handleLoadFromRepositoryRequest() throws Exception {
   if (DBG) System.out.println("HG HandleLoadFromRepositoryRequest");
   boolean success;
   HGDBOntologyManager m = (HGDBOntologyManager) this.getModelManager().getOWLOntologyManager();
   OntologyRepository repository = getProtegeRepository();
   if (repository == null)
     throw new IllegalStateException(
         "Cannot handle load from repository. No HGOwlOntologyRepository registered with Protege.");
   // Open Repository open Dlg
   OntologyRepositoryEntry ontologyEntry = RepositoryViewPanel.showOpenDialog(repository);
   if (ontologyEntry != null) {
     if (isLoadedOntologyFromLocation(ontologyEntry.getPhysicalURI())) {
       // Dialog: database backed ontology already loaded, no reload
       // necessary.
       success = false;
     } else {
       success = handleLoadFrom(ontologyEntry.getPhysicalURI());
     }
   } else {
     success = false;
   }
   //
   m.getOntologyRepository().printStatistics();
   return success;
 }
Пример #3
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;
   }
 }