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, wait
findIndividuals, findResources, findTerm, getChildren, getParents
public OntologyService.InferenceMode getInferenceMode()
OntologyService
getInferenceMode
in interface OntologyService
public void setInferenceMode(OntologyService.InferenceMode inferenceMode)
OntologyService
Changes are applicable only if the service is re-initialized.
setInferenceMode
in interface OntologyService
public boolean getProcessImports()
getProcessImports
in interface OntologyService
public void setProcessImports(boolean processImports)
setProcessImports
in interface OntologyService
public boolean isSearchEnabled()
isSearchEnabled
in interface OntologyService
public void setSearchEnabled(boolean searchEnabled)
setSearchEnabled
in interface OntologyService
public void initialize(boolean forceLoad, boolean forceIndexing)
OntologyService
initialize
in interface OntologyService
forceLoad
- 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)
OntologyService
Note that when this method of initialization is used, the ontology cache is not created on-disk.
initialize
in interface OntologyService
public void closeIndex()
public Collection<OntologyIndividual> findIndividuals(String search, boolean keepObsoletes) throws OntologySearchException
OntologyService
findIndividuals
in interface OntologyService
search
- search querykeepObsoletes
- retain obsolete termsOntologySearchException
public Collection<OntologyResource> findResources(String searchString, boolean keepObsoletes) throws OntologySearchException
OntologyService
findResources
in interface OntologyService
searchString
- search querykeepObsoletes
- retain obsolete termsOntologySearchException
public Collection<OntologyTerm> findTerm(String search, boolean keepObsoletes) throws OntologySearchException
OntologyService
findTerm
in interface OntologyService
search
- search querykeepObsoletes
- retain obsolete termsOntologySearchException
public OntologyTerm findUsingAlternativeId(String alternativeId)
OntologyService
findUsingAlternativeId
in interface OntologyService
public Set<String> getAllURIs()
OntologyService
getAllURIs
in interface OntologyService
public OntologyResource getResource(String uri)
OntologyService
getResource
in interface OntologyService
public OntologyTerm getTerm(String uri)
OntologyService
getTerm
in interface OntologyService
public Collection<OntologyIndividual> getTermIndividuals(String uri)
OntologyService
getTermIndividuals
in interface OntologyService
public Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
OntologyService
getParents
in interface OntologyService
terms
- 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)
OntologyService
getChildren
in interface OntologyService
terms
- set of terms whose children are retrieveddirect
- only retain direct childrenincludeAdditionalProperties
- also include children matched via additional propertieskeepObsoletes
- retain obsolete termspublic boolean isEnabled()
OntologyService
isEnabled
in interface OntologyService
public boolean isOntologyLoaded()
OntologyService
isOntologyLoaded
in interface OntologyService
public void startInitializationThread(boolean forceLoad, boolean forceIndexing)
OntologyService
If the initialization thread is already running, this method does nothing. If the initialization thread previously completed, the ontology will be reinitialized.
startInitializationThread
in interface OntologyService
forceLoad
- 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()
OntologyService
isInitializationThreadAlive
in interface OntologyService
public boolean isInitializationThreadCancelled()
OntologyService
isInitializationThreadCancelled
in interface OntologyService
public void cancelInitializationThread()
cancelInitializationThread
in interface OntologyService
public void waitForInitializationThread() throws InterruptedException
OntologyService
waitForInitializationThread
in interface OntologyService
InterruptedException
protected abstract String getOntologyName()
protected abstract String getOntologyUrl()
protected abstract OntologyModel loadModel(boolean processImports, OntologyService.InferenceMode inferenceMode) throws IOException
IOException
protected 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)
OntologyService
index
in interface OntologyService
force
- 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)
OntologyService
loadTermsInNameSpace
in interface OntologyService
is
- 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.