Class AbstractOntologyService

    • Field Detail

      • log

        protected static org.slf4j.Logger log
    • Constructor Detail

      • AbstractOntologyService

        public AbstractOntologyService()
    • Method Detail

      • initialize

        public void initialize​(boolean forceLoad,
                               boolean forceIndexing)
        Description copied from interface: OntologyService
        Initialize this ontology service.
        Specified by:
        initialize in interface OntologyService
        Parameters:
        forceLoad - Force loading of ontology, even if it is already loaded
        forceIndexing - If forceLoad is also true, indexing will be performed. If you know the index is up-to-date, there's no need to do it again. Normally indexing is only done if there is no index, or if the ontology has changed since last loaded.
      • initialize

        public void initialize​(InputStream stream,
                               boolean forceIndexing)
        Description copied from interface: OntologyService
        Initialize this ontology service from a stream.

        Note that when this method of initialization is used, the ontology cache is not created on-disk.

        Specified by:
        initialize in interface OntologyService
      • closeIndex

        public void closeIndex()
        Do not do this except before re-indexing.
      • getResource

        public OntologyResource getResource​(String uri)
        Description copied from interface: OntologyService
        Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given. If no OntologyTerm is found only then will ontologyIndividuals be searched. returns null if nothing is found.
        Specified by:
        getResource in interface OntologyService
      • getParents

        public Set<OntologyTerm> getParents​(Collection<OntologyTerm> terms,
                                            boolean direct,
                                            boolean includeAdditionalProperties,
                                            boolean keepObsoletes)
        Description copied from interface: OntologyService
        Obtain all the parents of a given set of terms.
        Specified by:
        getParents in interface OntologyService
        Parameters:
        terms - set of terms whose parents are retrieved
        direct - only retain direct parents
        includeAdditionalProperties - also include parents matched via additional properties
        keepObsoletes - retain obsolete terms
        Returns:
        a set of parent terms
      • getChildren

        public Set<OntologyTerm> getChildren​(Collection<OntologyTerm> terms,
                                             boolean direct,
                                             boolean includeAdditionalProperties,
                                             boolean keepObsoletes)
        Description copied from interface: OntologyService
        Obtain all the children of a given set of terms.
        Specified by:
        getChildren in interface OntologyService
        Parameters:
        terms - set of terms whose children are retrieved
        direct - only retain direct children
        includeAdditionalProperties - also include children matched via additional properties
        keepObsoletes - retain obsolete terms
        Returns:
        a set of child terms
      • isOntologyLoaded

        public boolean isOntologyLoaded()
        Description copied from interface: OntologyService
        Used for determining if the Ontology has finished loading into memory. Although calls like getParents, getChildren will still work (its much faster once the ontologies have been preloaded into memory.)
        Specified by:
        isOntologyLoaded in interface OntologyService
      • startInitializationThread

        public void startInitializationThread​(boolean forceLoad,
                                              boolean forceIndexing)
        Description copied from interface: OntologyService
        Start the initialization thread.

        If the initialization thread is already running, this method does nothing. If the initialization thread previously completed, the ontology will be reinitialized.

        Specified by:
        startInitializationThread in interface OntologyService
        Parameters:
        forceLoad - Force loading of ontology, even if it is already loaded
        forceIndexing - If forceLoad is also true, indexing will be performed. If you know the index is up to date, there's no need to do it again. Normally indexing is only done if there is no index, or if the ontology has changed since last loaded.
      • getOntologyName

        protected abstract String getOntologyName()
        The simple getOntologyName() of the ontology. Used for indexing purposes. (ie this will determine the getOntologyName() of the underlying index for searching the ontology)
      • getOntologyUrl

        protected abstract String getOntologyUrl()
        Defines the location of the ontology eg: MGED
      • loadModel

        protected abstract com.hp.hpl.jena.ontology.OntModel loadModel()
        Delegates the call as to load the model into memory or leave it on disk. Simply delegates to either OntologyLoader.loadMemoryModel( url ); OR OntologyLoader.loadPersistentModel( url, spec );
      • loadModelFromStream

        protected abstract com.hp.hpl.jena.ontology.OntModel loadModelFromStream​(InputStream stream)
        Load a model from a given input stream.
      • getCacheName

        @Nullable
        protected String getCacheName()
        A name for caching this ontology, or null to disable caching.

        Note that if null is returned, the ontology will not have full-text search capabilities.

      • loadTermsInNameSpace

        public void loadTermsInNameSpace​(InputStream is,
                                         boolean forceIndex)
        Description copied from interface: OntologyService
        For testing! Overrides normal way of loading the ontology. This does not index the ontology unless 'force' is true (if there is an existing index, it will be used)
        Specified by:
        loadTermsInNameSpace in interface OntologyService
        Parameters:
        is - input stream from which the ontology model is loaded
        forceIndex - initialize the index. Otherwise it will only be initialized if it doesn't exist.