Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ff7c7979 authored by Jérôme Euzenat's avatar Jérôme Euzenat
Browse files

- reinstated caching

- ontowrap has been made independent from align (exception)
parent 2fa6235f
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,7 @@ import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException; ...@@ -31,8 +31,7 @@ import org.semanticweb.owlapi.model.OWLOntologyDocumentAlreadyExistsException;
import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.semanticweb.owlapi.model.IRI; import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owl.align.AlignmentException; import fr.inrialpes.exmo.ontowrap.OntowrapException;
import fr.inrialpes.exmo.ontowrap.OntologyCache; import fr.inrialpes.exmo.ontowrap.OntologyCache;
import fr.inrialpes.exmo.ontowrap.OntologyFactory; import fr.inrialpes.exmo.ontowrap.OntologyFactory;
import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology; import fr.inrialpes.exmo.ontowrap.HeavyLoadedOntology;
...@@ -58,50 +57,49 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { ...@@ -58,50 +57,49 @@ public class OWLAPI3OntologyFactory extends OntologyFactory {
} }
@Override @Override
public OWLAPI3Ontology newOntology( Object ontology ) throws AlignmentException { public OWLAPI3Ontology newOntology( Object ontology ) throws OntowrapException {
if ( ontology instanceof OWLOntology ) { if ( ontology instanceof OWLOntology ) {
OWLAPI3Ontology onto = new OWLAPI3Ontology(); OWLAPI3Ontology onto = new OWLAPI3Ontology();
onto.setFormalism( formalismId ); onto.setFormalism( formalismId );
onto.setFormURI( formalismUri ); onto.setFormURI( formalismUri );
onto.setOntology( (OWLOntology)ontology ); onto.setOntology( (OWLOntology)ontology );
//onto.setURI( ((OWLOntology)ontology).getURI() );
onto.setURI( ((OWLOntology)ontology).getOntologyID().getOntologyIRI().toURI() ); onto.setURI( ((OWLOntology)ontology).getOntologyID().getOntologyIRI().toURI() );
// JE: was commented but doubtful cache.recordOntology( onto.getURI(), onto );
//cache.recordOntology( onto.getURI(), onto );
cache.recordOntology( ((OWLOntology)ontology).getOntologyID().getOntologyIRI().toURI(), onto ); cache.recordOntology( ((OWLOntology)ontology).getOntologyID().getOntologyIRI().toURI(), onto );
return onto; return onto;
} else { } else {
throw new AlignmentException( "Argument is not an OWLOntology: "+ontology ); throw new OntowrapException( "Argument is not an OWLOntology: "+ontology );
} }
} }
@Override @Override
public HeavyLoadedOntology loadOntology( URI uri ) throws AlignmentException { public HeavyLoadedOntology loadOntology( URI uri ) throws OntowrapException {
OWLAPI3Ontology onto = null; OWLAPI3Ontology onto = null;
// JE: Cache does not seem to work and // Cache seems to be implemented in API 3.0 anyway
// seems to be useless with API 3.0! // and it seems to not work well with this one
//onto = cache.getOntologyFromURI( uri ); onto = cache.getOntologyFromURI( uri );
//if ( onto != null ) return onto; if ( onto != null ) return onto;
//onto = cache.getOntology( uri ); onto = cache.getOntology( uri );
//if ( onto != null ) return onto; if ( onto != null ) return onto;
OWLOntology ontology; OWLOntology ontology;
try { try {
//ontology = manager.loadOntologyFromPhysicalURI(uri);
// This below does not seem to work! // This below does not seem to work!
//ontology = manager.loadOntologyFromOntologyDocument( IRI.create( uri ) ); //ontology = manager.loadOntologyFromOntologyDocument( IRI.create( uri ) );
ontology = manager.loadOntology( IRI.create( uri ) ); ontology = manager.loadOntology( IRI.create( uri ) );
} catch ( OWLOntologyDocumentAlreadyExistsException oodaeex ) {
// This is a cache failure
throw new OntowrapException("Already loaded [cache failure] " + uri, oodaeex );
} catch ( OWLOntologyCreationException oocex ) { } catch ( OWLOntologyCreationException oocex ) {
oocex.printStackTrace(); oocex.printStackTrace();
throw new AlignmentException("Cannot load " + uri, oocex ); throw new OntowrapException("Cannot load " + uri, oocex );
} }
onto = new OWLAPI3Ontology(); onto = new OWLAPI3Ontology();
onto.setFormalism( formalismId ); onto.setFormalism( formalismId );
onto.setFormURI( formalismUri ); onto.setFormURI( formalismUri );
onto.setOntology( ontology ); onto.setOntology( ontology );
onto.setFile( uri ); onto.setFile( uri );
//onto.setURI( ontology.getURI() );
onto.setURI( ontology.getOntologyID().getOntologyIRI().toURI() ); onto.setURI( ontology.getOntologyID().getOntologyIRI().toURI() );
//cache.recordOntology( uri, onto ); cache.recordOntology( uri, onto );
return onto; return onto;
} }
...@@ -111,6 +109,7 @@ public class OWLAPI3OntologyFactory extends OntologyFactory { ...@@ -111,6 +109,7 @@ public class OWLAPI3OntologyFactory extends OntologyFactory {
@Override @Override
public void clearCache() { public void clearCache() {
cache.clear(); cache.clear();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment