Skip to content

Commit

Permalink
Fixed some issues with imports loading
Browse files Browse the repository at this point in the history
- Save the catalog when the save action is performed
  • Loading branch information
matthewhorridge committed May 18, 2016
1 parent 6794f44 commit 0df4649
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ public void save(OWLOntology ont) throws OWLOntologyStorageException {
.addOntology(ont, format, documentIRI)
.build();
saver.saveOntologies();
ensureCatalogFileExists();
manager.setOntologyDocumentIRI(ont, documentIRI);
logger.info("Saved ontology {} to {} in {} format", ont.getOntologyID(), documentIRI, format);

Expand All @@ -516,6 +517,20 @@ public void save(OWLOntology ont) throws OWLOntologyStorageException {
}
}

private void ensureCatalogFileExists() {
try {
OWLOntology activeOntology = getActiveOntology();
IRI ontologyDocumentIRI = manager.getOntologyDocumentIRI(activeOntology);
if("file".equals(ontologyDocumentIRI.getScheme())) {
File file = new File(ontologyDocumentIRI.toURI());
File parentDirectory = file.getParentFile();
getOntologyCatalogManager().ensureCatalogExists(parentDirectory);
}
} catch (IllegalArgumentException e) {
logger.error("A problem occurred when trying to save the catalog file: {}", e.getMessage());
}
}

/**
* @throws OWLOntologyStorageException if a problem occurs during the save
* @deprecated - this method would require user interaction - use <code>OWLEditorKit.saveAs()</code> instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private Void saveOntologyInternal() throws OWLOntologyStorageException {
IRI documentIRI = descriptor.getDocumentIRI();
dlg.setSubMessage(String.format("Location: %s", formatIRI(documentIRI)));
ontology.saveOntology(descriptor.getDocumentFormat(), documentIRI);

}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void addImports() {
}

private void addImportsInOtherThread() {
ListenableFuture<List<OWLOntologyChange>> future = service.submit(() -> loadImportsInternal());
ListenableFuture<List<OWLOntologyChange>> future = service.submit(this::loadImportsInternal);
Futures.addCallback(future, new FutureCallback<List<OWLOntologyChange>>() {
@Override
public void onSuccess(List<OWLOntologyChange> result) {
Expand Down Expand Up @@ -105,16 +105,12 @@ private List<OWLOntologyChange> loadImportsInternal() {
if (!man.contains(importParameters.getOntologyID())) {
try {
OWLOntologyManager loadingManager = OWLManager.createConcurrentOWLOntologyManager();
PriorityCollection<OWLOntologyIRIMapper> iriMappers = loadingManager.getIRIMappers();
iriMappers.clear();
iriMappers.add(new UserResolvedIRIMapper(new MissingImportHandlerUI(editorKit)));
iriMappers.add(new WebConnectionIRIMapper());
iriMappers.add(new AutoMappedRepositoryIRIMapper(editorKit.getOWLModelManager().getOntologyCatalogManager()));

loadingManager.getIRIMappers()
.add(man.getIRIMappers());
ProgressDialogOntologyLoaderListener listener = new ProgressDialogOntologyLoaderListener(dlg, logger);
loadingManager.addOntologyLoaderListener(listener);
loadingManager.loadOntologyFromOntologyDocument(
new IRIDocumentSource(importedOntologyDocumentIRI),
new IRIDocumentSource(IRI.create(physicalLocation)),
new OWLOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT));
loadingManager.removeOntologyLoaderListener(listener);
// editorKit.getModelManager().fireEvent(EventType.ONTOLOGY_LOADED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class ImportConfirmationPage extends AbstractOWLWizardPanel {
public static final String ID = "ImportConfirmationPage";

private JComponent importedOntologiesComponent;

private TitledBorder titledBorder;

private Object backPanelDescriptor;
Expand Down

0 comments on commit 0df4649

Please sign in to comment.