public abstract class AbstractOntologyService extends Object implements OntologyService
OntologyService.InferenceMode| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
AbstractOntologyService() |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelInitializationThread()
Cancel the initialization thread.
|
void |
closeIndex()
Do not do this except before re-indexing.
|
Collection<OntologyIndividual> |
findIndividuals(String search,
boolean keepObsoletes)
Looks for any individuals that match the given search string.
|
Collection<OntologyResource> |
findResources(String searchString,
boolean keepObsoletes)
Looks for any resources (terms or individuals) that match the given search string
|
Collection<OntologyTerm> |
findTerm(String search,
boolean keepObsoletes)
Looks for any terms that match the given search string.
|
OntologyTerm |
findUsingAlternativeId(String alternativeId)
Find a term using an alternative ID.
|
Set<String> |
getAllURIs()
Obtain all the resource URIs in this ontology.
|
protected String |
getCacheName()
A name for caching this ontology, or null to disable caching.
|
Set<OntologyTerm> |
getChildren(Collection<OntologyTerm> terms,
boolean direct,
boolean includeAdditionalProperties,
boolean keepObsoletes)
Obtain all the children of a given set of terms.
|
OntologyService.InferenceMode |
getInferenceMode()
Obtain the inference mode used for this ontology.
|
protected abstract String |
getOntologyName()
The simple getOntologyName() of the ontology.
|
protected abstract String |
getOntologyUrl()
Defines the location of the ontology eg: MGED
|
Set<OntologyTerm> |
getParents(Collection<OntologyTerm> terms,
boolean direct,
boolean includeAdditionalProperties,
boolean keepObsoletes)
Obtain all the parents of a given set of terms.
|
boolean |
getProcessImports() |
OntologyResource |
getResource(String uri)
Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given.
|
OntologyTerm |
getTerm(String uri)
Looks for a OntologyTerm that has the match in URI given
|
Collection<OntologyIndividual> |
getTermIndividuals(String uri)
Obtain all the individuals for a given term URI.
|
void |
index(boolean force)
Index the ontology for performing full-text searches.
|
void |
initialize(boolean forceLoad,
boolean forceIndexing)
Initialize this ontology service.
|
void |
initialize(InputStream stream,
boolean forceIndexing)
Initialize this ontology service from a stream.
|
boolean |
isEnabled()
Check if this ontology is enabled.
|
boolean |
isInitializationThreadAlive()
Check if the initialization thread is alive.
|
boolean |
isInitializationThreadCancelled()
Check if the initialization thread is cancelled.
|
boolean |
isOntologyLoaded()
Used for determining if the Ontology has finished loading into memory.
|
boolean |
isSearchEnabled() |
protected abstract OntologyModel |
loadModel(boolean processImports,
OntologyService.InferenceMode inferenceMode)
Delegates the call as to load the model into memory or leave it on disk.
|
protected abstract OntologyModel |
loadModelFromStream(InputStream stream,
boolean processImports,
OntologyService.InferenceMode inferenceMode)
Load a model from a given input stream.
|
void |
loadTermsInNameSpace(InputStream is,
boolean forceIndex)
For testing! Overrides normal way of loading the ontology.
|
void |
setInferenceMode(OntologyService.InferenceMode inferenceMode)
Set the inference mode used for this ontology.
|
void |
setProcessImports(boolean processImports) |
void |
setSearchEnabled(boolean searchEnabled) |
void |
startInitializationThread(boolean forceLoad,
boolean forceIndexing)
Start the initialization thread.
|
String |
toString() |
void |
waitForInitializationThread()
Wait for the initialization thread to finish.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitfindIndividuals, findResources, findTerm, getChildren, getParentspublic OntologyService.InferenceMode getInferenceMode()
OntologyServicegetInferenceMode in interface OntologyServicepublic void setInferenceMode(OntologyService.InferenceMode inferenceMode)
OntologyServiceChanges are applicable only if the service is re-initialized.
setInferenceMode in interface OntologyServicepublic boolean getProcessImports()
getProcessImports in interface OntologyServicepublic void setProcessImports(boolean processImports)
setProcessImports in interface OntologyServicepublic boolean isSearchEnabled()
isSearchEnabled in interface OntologyServicepublic void setSearchEnabled(boolean searchEnabled)
setSearchEnabled in interface OntologyServicepublic void initialize(boolean forceLoad,
boolean forceIndexing)
OntologyServiceinitialize in interface OntologyServiceforceLoad - Force loading of ontology, even if it is already loadedforceIndexing - 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.public void initialize(InputStream stream, boolean forceIndexing)
OntologyServiceNote that when this method of initialization is used, the ontology cache is not created on-disk.
initialize in interface OntologyServicepublic void closeIndex()
public Collection<OntologyIndividual> findIndividuals(String search, boolean keepObsoletes) throws OntologySearchException
OntologyServicefindIndividuals in interface OntologyServicesearch - search querykeepObsoletes - retain obsolete termsOntologySearchExceptionpublic Collection<OntologyResource> findResources(String searchString, boolean keepObsoletes) throws OntologySearchException
OntologyServicefindResources in interface OntologyServicesearchString - search querykeepObsoletes - retain obsolete termsOntologySearchExceptionpublic Collection<OntologyTerm> findTerm(String search, boolean keepObsoletes) throws OntologySearchException
OntologyServicefindTerm in interface OntologyServicesearch - search querykeepObsoletes - retain obsolete termsOntologySearchExceptionpublic OntologyTerm findUsingAlternativeId(String alternativeId)
OntologyServicefindUsingAlternativeId in interface OntologyServicepublic Set<String> getAllURIs()
OntologyServicegetAllURIs in interface OntologyServicepublic OntologyResource getResource(String uri)
OntologyServicegetResource in interface OntologyServicepublic OntologyTerm getTerm(String uri)
OntologyServicegetTerm in interface OntologyServicepublic Collection<OntologyIndividual> getTermIndividuals(String uri)
OntologyServicegetTermIndividuals in interface OntologyServicepublic Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
OntologyServicegetParents in interface OntologyServiceterms - set of terms whose parents are retrieveddirect - only retain direct parentsincludeAdditionalProperties - also include parents matched via additional propertieskeepObsoletes - retain obsolete termspublic Set<OntologyTerm> getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
OntologyServicegetChildren in interface OntologyServiceterms - set of terms whose children are retrieveddirect - only retain direct childrenincludeAdditionalProperties - also include children matched via additional propertieskeepObsoletes - retain obsolete termspublic boolean isEnabled()
OntologyServiceisEnabled in interface OntologyServicepublic boolean isOntologyLoaded()
OntologyServiceisOntologyLoaded in interface OntologyServicepublic void startInitializationThread(boolean forceLoad,
boolean forceIndexing)
OntologyServiceIf the initialization thread is already running, this method does nothing. If the initialization thread previously completed, the ontology will be reinitialized.
startInitializationThread in interface OntologyServiceforceLoad - Force loading of ontology, even if it is already loadedforceIndexing - 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.public boolean isInitializationThreadAlive()
OntologyServiceisInitializationThreadAlive in interface OntologyServicepublic boolean isInitializationThreadCancelled()
OntologyServiceisInitializationThreadCancelled in interface OntologyServicepublic void cancelInitializationThread()
cancelInitializationThread in interface OntologyServicepublic void waitForInitializationThread()
throws InterruptedException
OntologyServicewaitForInitializationThread in interface OntologyServiceInterruptedExceptionprotected abstract String getOntologyName()
protected abstract String getOntologyUrl()
protected abstract OntologyModel loadModel(boolean processImports, OntologyService.InferenceMode inferenceMode) throws IOException
IOExceptionprotected abstract OntologyModel loadModelFromStream(InputStream stream, boolean processImports, OntologyService.InferenceMode inferenceMode) throws IOException
IOException@Nullable protected String getCacheName()
Note that if null is returned, the ontology will not have full-text search capabilities.
public void index(boolean force)
OntologyServiceindex in interface OntologyServiceforce - if true, perform indexing even if an index already existsOntologyService.findIndividuals(String),
OntologyService.findTerm(String),
OntologyService.findResources(String)public void loadTermsInNameSpace(InputStream is, boolean forceIndex)
OntologyServiceloadTermsInNameSpace in interface OntologyServiceis - input stream from which the ontology model is loadedforceIndex - initialize the index. Otherwise it will only be initialized if it doesn't exist.Copyright © 2003–2023 UBC Michael Smith Laboratories. All rights reserved.