Class AbstractOntologyService
- All Implemented Interfaces:
- AutoCloseable,- OntologyService
- Direct Known Subclasses:
- ClasspathOntologyService,- TdbOntologyService,- UrlOntologyService
- 
Nested Class SummaryNested classes/interfaces inherited from interface ubic.basecode.ontology.providers.OntologyServiceOntologyService.InferenceMode, OntologyService.LanguageLevel
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractOntologyService(String ontologyName, String ontologyUrl, boolean ontologyEnabled, String cacheName) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidCancel the initialization thread.voidClear the list of allowed URI prefixes.voidclose()findIndividuals(String search, int maxResults, boolean keepObsoletes) Looks for any individuals that match the given search string.findResources(String searchString, int maxResults, boolean keepObsoletes) Looks for any resources (terms or individuals) that match the given search stringLooks for any terms that match the given search string.findUsingAlternativeId(String alternativeId) Find a term using an alternative ID.Obtain the URIs used as additional properties when inferring parents and children.Obtain all the resource URIs in this ontology.protected StringgetChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes) Obtain all the children of a given set of terms.Obtain a description of this ontology if available.Obtain the words that should be excluded from stemming.Obtain the inference mode used for this ontology.Obtain the OWL language level supported by this ontology.getName()Obtain the name of this ontology if available.protected Stringprotected StringgetParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes) Obtain all the parents of a given set of terms.booleanCheck if this ontology will process imports.getResource(String uri) Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given.protected com.hp.hpl.jena.ontology.OntModelSpecgetSpec(OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) Looks for a OntologyTerm that has the match in URI givengetTermIndividuals(String uri) Obtain all the individuals for a given term URI.voidindex(boolean force) Index the ontology for performing full-text searches.voidinitialize(boolean forceLoad, boolean forceIndexing) Initialize this ontology service.voidinitialize(InputStream stream, boolean forceIndexing) Initialize this ontology service from a stream.booleanCheck if this ontology is enabled.booleanCheck if the initialization thread is alive.booleanCheck if the initialization thread is cancelled.protected booleanbooleanUsed for determining if the Ontology has finished loading into memory.booleanCheck if this ontology has full-text search enabled.protected abstract OntologyModelloadModel(boolean processImports, OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) Delegates the call as to load the model into memory or leave it on disk.protected abstract OntologyModelloadModelFromStream(InputStream is, boolean processImports, OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) Load a model from a given input stream.voidloadTermsInNameSpace(InputStream is, boolean forceIndex) For testing! Overrides normal way of loading the ontology.voidsetAdditionalPropertyUris(Set<String> additionalPropertyUris) Set the URIs to be used as additional properties when inferring parents and children.voidsetAllowedUriPrefixes(String... uriPrefixes) List of URI prefixes to load from the ontology.voidsetExcludedWordsFromStemming(Set<String> excludedWordsFromStemming) Set words that should be excluded from stemming when searching.voidsetInferenceMode(OntologyService.InferenceMode inferenceMode) Set the inference mode used for this ontology.voidsetLanguageLevel(OntologyService.LanguageLevel languageLevel) Set the OWL language level supported by this ontology.voidsetProcessImports(boolean processImports) Allow of forbid this ontology to process imports.voidsetSearchEnabled(boolean searchEnabled) Enable or disable search for this ontology.voidstartInitializationThread(boolean forceLoad, boolean forceIndexing) Start the initialization thread.toString()voidWait for the initialization thread to finish.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ubic.basecode.ontology.providers.OntologyServicefindIndividuals, findResources, findTerm, getChildren, getParents
- 
Field Details- 
logprotected static org.slf4j.Logger log
 
- 
- 
Constructor Details- 
AbstractOntologyService
 
- 
- 
Method Details- 
getOntologyName
- 
getOntologyUrl
- 
isOntologyEnabledprotected boolean isOntologyEnabled()
- 
getCacheName
- 
startInitializationThreadpublic void startInitializationThread(boolean forceLoad, boolean forceIndexing) Description copied from interface:OntologyServiceStart 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:
- startInitializationThreadin 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.
 
- 
isInitializationThreadAlivepublic boolean isInitializationThreadAlive()Description copied from interface:OntologyServiceCheck if the initialization thread is alive.- Specified by:
- isInitializationThreadAlivein interface- OntologyService
 
- 
isInitializationThreadCancelledpublic boolean isInitializationThreadCancelled()Description copied from interface:OntologyServiceCheck if the initialization thread is cancelled.- Specified by:
- isInitializationThreadCancelledin interface- OntologyService
 
- 
cancelInitializationThreadpublic void cancelInitializationThread()Cancel the initialization thread.- Specified by:
- cancelInitializationThreadin interface- OntologyService
 
- 
waitForInitializationThreadDescription copied from interface:OntologyServiceWait for the initialization thread to finish.- Specified by:
- waitForInitializationThreadin interface- OntologyService
- Throws:
- InterruptedException
 
- 
loadTermsInNameSpaceDescription copied from interface:OntologyServiceFor 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:
- loadTermsInNameSpacein 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.
 
- 
getNameDescription copied from interface:OntologyServiceObtain the name of this ontology if available.- Specified by:
- getNamein interface- OntologyService
 
- 
getDescriptionDescription copied from interface:OntologyServiceObtain a description of this ontology if available.- Specified by:
- getDescriptionin interface- OntologyService
 
- 
getLanguageLevelDescription copied from interface:OntologyServiceObtain the OWL language level supported by this ontology.The default is to use OntologyService.LanguageLevel.FULL.- Specified by:
- getLanguageLevelin interface- OntologyService
 
- 
setLanguageLevelDescription copied from interface:OntologyServiceSet the OWL language level supported by this ontology.Changes are applicable only if the service is re-initialized. - Specified by:
- setLanguageLevelin interface- OntologyService
 
- 
getInferenceModeDescription copied from interface:OntologyServiceObtain the inference mode used for this ontology.The default is OntologyService.InferenceMode.TRANSITIVE.- Specified by:
- getInferenceModein interface- OntologyService
 
- 
setInferenceModeDescription copied from interface:OntologyServiceSet the inference mode used for this ontology.Changes are applicable only if the service is re-initialized. - Specified by:
- setInferenceModein interface- OntologyService
 
- 
getProcessImportspublic boolean getProcessImports()Description copied from interface:OntologyServiceCheck if this ontology will process imports.If disabled, ontologies imported by this ontology will not be loaded. - Specified by:
- getProcessImportsin interface- OntologyService
 
- 
setProcessImportspublic void setProcessImports(boolean processImports) Description copied from interface:OntologyServiceAllow of forbid this ontology to process imports.Changes are applicable only if the service is re-initialized. - Specified by:
- setProcessImportsin interface- OntologyService
 
- 
setAllowedUriPrefixesDescription copied from interface:OntologyServiceList of URI prefixes to load from the ontology.Changes are applicable only if the service is re-initialized. - Specified by:
- setAllowedUriPrefixesin interface- OntologyService
 
- 
clearAllowedUriPrefixespublic void clearAllowedUriPrefixes()Description copied from interface:OntologyServiceClear the list of allowed URI prefixes.Changes are applicable only if the service is re-initialized. - Specified by:
- clearAllowedUriPrefixesin interface- OntologyService
 
- 
isSearchEnabledpublic boolean isSearchEnabled()Description copied from interface:OntologyServiceCheck if this ontology has full-text search enabled.This is necessary for finding term using full-text queries. If enabled, an index will be generated in during initialization by OntologyService.initialize(boolean, boolean).Search is enabled by default. - Specified by:
- isSearchEnabledin interface- OntologyService
- See Also:
 
- 
setSearchEnabledpublic void setSearchEnabled(boolean searchEnabled) Description copied from interface:OntologyServiceEnable or disable search for this ontology.Changes are only applicable if the service is re-initialized. - Specified by:
- setSearchEnabledin interface- OntologyService
 
- 
getExcludedWordsFromStemmingDescription copied from interface:OntologyServiceObtain the words that should be excluded from stemming.By default, all words are subject to stemming. The exact implementation of stemming depends on the actual search implementation. - Specified by:
- getExcludedWordsFromStemmingin interface- OntologyService
 
- 
setExcludedWordsFromStemmingDescription copied from interface:OntologyServiceSet words that should be excluded from stemming when searching.- Specified by:
- setExcludedWordsFromStemmingin interface- OntologyService
 
- 
getAdditionalPropertyUrisDescription copied from interface:OntologyServiceObtain the URIs used as additional properties when inferring parents and children.The default is to use part of, proper part of and all of their sub-properties if inference is enabled. - Specified by:
- getAdditionalPropertyUrisin interface- OntologyService
- See Also:
 
- 
setAdditionalPropertyUrisDescription copied from interface:OntologyServiceSet the URIs to be used as additional properties when inferring parents and children.Changes are applicable only if the service is re-initialized. - Specified by:
- setAdditionalPropertyUrisin interface- OntologyService
 
- 
initializepublic void initialize(boolean forceLoad, boolean forceIndexing) Description copied from interface:OntologyServiceInitialize this ontology service.- Specified by:
- initializein 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.
 
- 
initializeDescription copied from interface:OntologyServiceInitialize 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:
- initializein interface- OntologyService
 
- 
findIndividualspublic Collection<OntologySearchResult<OntologyIndividual>> findIndividuals(String search, int maxResults, boolean keepObsoletes) throws OntologySearchException Description copied from interface:OntologyServiceLooks for any individuals that match the given search string.- Specified by:
- findIndividualsin interface- OntologyService
- Parameters:
- search- search query
- keepObsoletes- retain obsolete terms
- Throws:
- OntologySearchException
 
- 
findResourcespublic Collection<OntologySearchResult<OntologyResource>> findResources(String searchString, int maxResults, boolean keepObsoletes) throws OntologySearchException Description copied from interface:OntologyServiceLooks for any resources (terms or individuals) that match the given search string- Specified by:
- findResourcesin interface- OntologyService
- Parameters:
- searchString- search query
- keepObsoletes- retain obsolete terms
- Throws:
- OntologySearchException
 
- 
findTermpublic Collection<OntologySearchResult<OntologyTerm>> findTerm(String search, int maxResults, boolean keepObsoletes) throws OntologySearchException Description copied from interface:OntologyServiceLooks for any terms that match the given search string.- Specified by:
- findTermin interface- OntologyService
- Parameters:
- search- search query
- keepObsoletes- retain obsolete terms
- Throws:
- OntologySearchException
 
- 
findUsingAlternativeIdDescription copied from interface:OntologyServiceFind a term using an alternative ID.- Specified by:
- findUsingAlternativeIdin interface- OntologyService
 
- 
getAllURIsDescription copied from interface:OntologyServiceObtain all the resource URIs in this ontology.- Specified by:
- getAllURIsin interface- OntologyService
 
- 
getResourceDescription copied from interface:OntologyServiceLooks 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:
- getResourcein interface- OntologyService
 
- 
getTermDescription copied from interface:OntologyServiceLooks for a OntologyTerm that has the match in URI given- Specified by:
- getTermin interface- OntologyService
 
- 
getTermIndividualsDescription copied from interface:OntologyServiceObtain all the individuals for a given term URI.- Specified by:
- getTermIndividualsin interface- OntologyService
 
- 
getParentspublic Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes) Description copied from interface:OntologyServiceObtain all the parents of a given set of terms.- Specified by:
- getParentsin 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
 
- 
getChildrenpublic Set<OntologyTerm> getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes) Description copied from interface:OntologyServiceObtain all the children of a given set of terms.- Specified by:
- getChildrenin 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
 
- 
isEnabledpublic boolean isEnabled()Description copied from interface:OntologyServiceCheck if this ontology is enabled.- Specified by:
- isEnabledin interface- OntologyService
 
- 
isOntologyLoadedpublic boolean isOntologyLoaded()Description copied from interface:OntologyServiceUsed 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:
- isOntologyLoadedin interface- OntologyService
 
- 
loadModelprotected abstract OntologyModel loadModel(boolean processImports, OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) throws IOException 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 );- Throws:
- IOException
 
- 
loadModelFromStreamprotected abstract OntologyModel loadModelFromStream(InputStream is, boolean processImports, OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) throws IOException Load a model from a given input stream.- Throws:
- IOException
 
- 
getSpecprotected com.hp.hpl.jena.ontology.OntModelSpec getSpec(OntologyService.LanguageLevel languageLevel, OntologyService.InferenceMode inferenceMode) 
- 
indexpublic void index(boolean force) Description copied from interface:OntologyServiceIndex the ontology for performing full-text searches.- Specified by:
- indexin interface- OntologyService
- Parameters:
- force- if true, perform indexing even if an index already exists
- See Also:
 
- 
close- Specified by:
- closein interface- AutoCloseable
- Throws:
- Exception
 
- 
toString
 
-