2424import com .hp .hpl .jena .rdf .arp .ParseException ;
2525import com .hp .hpl .jena .rdf .model .Property ;
2626import com .hp .hpl .jena .rdf .model .Resource ;
27- import com .hp .hpl .jena .shared .JenaException ;
2827import com .hp .hpl .jena .util .iterator .ExtendedIterator ;
2928import org .apache .commons .lang3 .RandomStringUtils ;
3029import org .apache .commons .lang3 .StringUtils ;
3130import org .apache .commons .lang3 .time .StopWatch ;
3231import org .slf4j .Logger ;
3332import org .slf4j .LoggerFactory ;
34- import ubic .basecode .ontology .jena .search .OntologyIndexer ;
35- import ubic .basecode .ontology .jena .search .OntologySearch ;
36- import ubic .basecode .ontology .jena .search .SearchIndex ;
37- import ubic .basecode .ontology .jena .vocabulary .BFO ;
38- import ubic .basecode .ontology .jena .vocabulary .RO ;
3933import ubic .basecode .ontology .model .OntologyIndividual ;
34+ import ubic .basecode .ontology .model .OntologyModel ;
4035import ubic .basecode .ontology .model .OntologyResource ;
4136import ubic .basecode .ontology .model .OntologyTerm ;
4237import ubic .basecode .ontology .providers .OntologyService ;
@@ -201,7 +196,12 @@ private void initialize( @Nullable InputStream stream, boolean forceLoad, boolea
201196 return ;
202197
203198 try {
204- model = stream != null ? loadModelFromStream ( stream , processImports , inferenceMode ) : loadModel ( processImports , inferenceMode ); // can take a while.
199+ OntologyModel m = stream != null ? loadModelFromStream ( stream , processImports , inferenceMode ) : loadModel ( processImports , inferenceMode ); // can take a while.
200+ if ( m instanceof OntologyModelImpl ) {
201+ model = ( ( OntologyModelImpl ) m ).getOntModel ();
202+ } else {
203+ throw new RuntimeException ( "Only Jena-based ontology models are supported." );
204+ }
205205 } catch ( Exception e ) {
206206 if ( isCausedByInterrupt ( e ) ) {
207207 return ;
@@ -491,7 +491,7 @@ public Collection<OntologyIndividual> getTermIndividuals( String uri ) {
491491
492492 @ Override
493493 public Set <OntologyTerm > getParents ( Collection <OntologyTerm > terms , boolean direct ,
494- boolean includeAdditionalProperties , boolean keepObsoletes ) {
494+ boolean includeAdditionalProperties , boolean keepObsoletes ) {
495495 Lock lock = rwLock .readLock ();
496496 try {
497497 lock .lock ();
@@ -510,7 +510,7 @@ public Set<OntologyTerm> getParents( Collection<OntologyTerm> terms, boolean dir
510510
511511 @ Override
512512 public Set <OntologyTerm > getChildren ( Collection <OntologyTerm > terms , boolean direct ,
513- boolean includeAdditionalProperties , boolean keepObsoletes ) {
513+ boolean includeAdditionalProperties , boolean keepObsoletes ) {
514514 Lock lock = rwLock .readLock ();
515515 try {
516516 lock .lock ();
@@ -615,13 +615,13 @@ public void waitForInitializationThread() throws InterruptedException {
615615 * Delegates the call as to load the model into memory or leave it on disk. Simply delegates to either
616616 * OntologyLoader.loadMemoryModel( url ); OR OntologyLoader.loadPersistentModel( url, spec );
617617 */
618- protected abstract OntModel loadModel ( boolean processImports , InferenceMode inferenceMode ) throws JenaException , IOException ;
618+ protected abstract OntologyModel loadModel ( boolean processImports , InferenceMode inferenceMode ) throws IOException ;
619619
620620
621621 /**
622622 * Load a model from a given input stream.
623623 */
624- protected abstract OntModel loadModelFromStream ( InputStream stream , boolean processImports , InferenceMode inferenceMode ) throws JenaException , IOException ;
624+ protected abstract OntologyModel loadModelFromStream ( InputStream stream , boolean processImports , InferenceMode inferenceMode ) throws IOException ;
625625
626626 /**
627627 * A name for caching this ontology, or null to disable caching.
@@ -633,6 +633,17 @@ protected String getCacheName() {
633633 return getOntologyName ();
634634 }
635635
636+ private OntModelSpec getSpec ( InferenceMode inferenceMode ) {
637+ switch ( inferenceMode ) {
638+ case TRANSITIVE :
639+ return OntModelSpec .OWL_MEM_TRANS_INF ;
640+ case NONE :
641+ return OntModelSpec .OWL_MEM ;
642+ default :
643+ throw new UnsupportedOperationException ( String .format ( "Unsupported inference level %s." , inferenceMode ) );
644+ }
645+ }
646+
636647 @ Override
637648 public void index ( boolean force ) {
638649 String cacheName = getCacheName ();
0 commit comments