Class MockOntologyTermFetcher
- java.lang.Object
-
- psidev.psi.mi.jami.bridges.fetcher.mock.MockOntologyTermFetcher
-
- All Implemented Interfaces:
CvTermFetcher<OntologyTerm>,OntologyTermFetcher
public class MockOntologyTermFetcher extends Object implements OntologyTermFetcher
A mock fetcher for testing. It extends all the methods of the true fetcher, but does not access an external service. Instead, it holds a map which can be loaded with objects and keys. which are then returned. It attempts to replicate the responses of the fetcher in most scenarios.- Since:
- 08/07/13
- Author:
- Gabriel Aldam (galdam@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description MockOntologyTermFetcher()Constructor for MockOntologyTermFetcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOntologyTerm(String identifier, OntologyTerm ontologyTerm)addOntologyTerm.voidclear()clear.OntologyTermfetchByIdentifier(String termIdentifier, String ontologyDatabaseName)Uses the identifier and the name of the database to search for a complete form of the cvTerm.OntologyTermfetchByIdentifier(String termIdentifier, CvTerm ontologyDatabase)fetchByIdentifier.Collection<OntologyTerm>fetchByIdentifiers(Collection<String> identifiers, String ontologyDatabaseName)fetchByIdentifiers.Collection<OntologyTerm>fetchByIdentifiers(Collection<String> identifiers, CvTerm ontologyDatabase)Uses the identifier and a cvTerm denoting the database to search to fetch a complete from of the term.Collection<OntologyTerm>fetchByName(String searchName)Uses the name of the term and the name of the database to search for a complete form of the term.OntologyTermfetchByName(String searchName, String ontologyDatabaseName)Uses the name of the term and the name of the database to search for a complete form of the term.Collection<OntologyTerm>fetchByNames(Collection<String> searchNames)Finds the CvTerms which match the exact names provided.Collection<OntologyTerm>fetchByNames(Collection<String> searchNames, String ontologyDatabaseName)Uses the name of the term and the name of the database to search for a complete form of the term.Set<OntologyTerm>fetchRootTerms(String databaseName)fetchRootTerms.Set<OntologyTerm>fetchRootTerms(CvTerm database)fetchRootTerms.
-
-
-
Method Detail
-
addOntologyTerm
public void addOntologyTerm(String identifier, OntologyTerm ontologyTerm)
addOntologyTerm.
- Parameters:
identifier- aStringobject.ontologyTerm- aOntologyTermobject.
-
clear
public void clear()
clear.
-
fetchByIdentifier
public OntologyTerm fetchByIdentifier(String termIdentifier, String ontologyDatabaseName) throws BridgeFailedException
Uses the identifier and the name of the database to search for a complete form of the cvTerm.- Specified by:
fetchByIdentifierin interfaceCvTermFetcher<OntologyTerm>- Parameters:
termIdentifier- The identifier for the CvTerm to fetch.ontologyDatabaseName- The name of the ontology to search for. Eg, psi-mi, psi-mod, go. Must not be Null.- Returns:
- A full cvTerm which matches the search term or null if one cannot be found.
- Throws:
BridgeFailedException- if any.
-
fetchByIdentifier
public OntologyTerm fetchByIdentifier(String termIdentifier, CvTerm ontologyDatabase) throws BridgeFailedException
fetchByIdentifier.
- Specified by:
fetchByIdentifierin interfaceCvTermFetcher<OntologyTerm>- Parameters:
termIdentifier- aStringobject.ontologyDatabase- aCvTermobject.- Returns:
- a
OntologyTermobject. - Throws:
BridgeFailedException- if any.
-
fetchByName
public OntologyTerm fetchByName(String searchName, String ontologyDatabaseName) throws BridgeFailedException
Uses the name of the term and the name of the database to search for a complete form of the term.- Specified by:
fetchByNamein interfaceCvTermFetcher<OntologyTerm>- Parameters:
searchName- A full or short name for the term to be searched for.ontologyDatabaseName- The ontology to search for the term in.- Returns:
- A fully enriched cvTerm which matches the search term or null if one cannot be found.
- Throws:
BridgeFailedException- if any.
-
fetchByName
public Collection<OntologyTerm> fetchByName(String searchName) throws BridgeFailedException
Uses the name of the term and the name of the database to search for a complete form of the term.If the term can not be resolved to a database, then this method may return null.
- Specified by:
fetchByNamein interfaceCvTermFetcher<OntologyTerm>- Parameters:
searchName- A full or short name for the term to be searched for.- Returns:
- A fully enriched cvTerm which matches the search term or null if one cannot be found.
- Throws:
BridgeFailedException- if any.
-
fetchByIdentifiers
public Collection<OntologyTerm> fetchByIdentifiers(Collection<String> identifiers, String ontologyDatabaseName) throws BridgeFailedException
fetchByIdentifiers.
- Specified by:
fetchByIdentifiersin interfaceCvTermFetcher<OntologyTerm>- Parameters:
identifiers- aCollectionobject.ontologyDatabaseName- aStringobject.- Returns:
- a
Collectionobject. - Throws:
BridgeFailedException- if any.
-
fetchByIdentifiers
public Collection<OntologyTerm> fetchByIdentifiers(Collection<String> identifiers, CvTerm ontologyDatabase) throws BridgeFailedException
Uses the identifier and a cvTerm denoting the database to search to fetch a complete from of the term.- Specified by:
fetchByIdentifiersin interfaceCvTermFetcher<OntologyTerm>- Parameters:
identifiers- The identifier for the CvTerms to fetch.ontologyDatabase- The name of the ontology to search for the terms in.- Returns:
- A fully enriched cvTerm which matches the search term or null if one cannot be found.
- Throws:
BridgeFailedException- if any.
-
fetchByNames
public Collection<OntologyTerm> fetchByNames(Collection<String> searchNames, String ontologyDatabaseName) throws BridgeFailedException
Uses the name of the term and the name of the database to search for a complete form of the term.- Specified by:
fetchByNamesin interfaceCvTermFetcher<OntologyTerm>- Parameters:
searchNames- A full or short name for the term to be searched for.ontologyDatabaseName- The name of the database to search for the names in.- Returns:
- A fully enriched cvTerm which matches the search term or null if one cannot be found.
- Throws:
BridgeFailedException- if any.
-
fetchByNames
public Collection<OntologyTerm> fetchByNames(Collection<String> searchNames) throws BridgeFailedException
Finds the CvTerms which match the exact names provided.If the a term found by the search can not be resolved to a database, this method may return null.
- Specified by:
fetchByNamesin interfaceCvTermFetcher<OntologyTerm>- Parameters:
searchNames- A collection full or short names for the term to be searched for.- Returns:
- A collection of cvTerms which matched a search term.
- Throws:
BridgeFailedException- if any.
-
fetchRootTerms
public Set<OntologyTerm> fetchRootTerms(String databaseName) throws BridgeFailedException
fetchRootTerms.
- Specified by:
fetchRootTermsin interfaceOntologyTermFetcher- Parameters:
databaseName- : ontology database name- Returns:
- a set of root terms for the ontology matching this database name
- Throws:
BridgeFailedException- if any.
-
fetchRootTerms
public Set<OntologyTerm> fetchRootTerms(CvTerm database) throws BridgeFailedException
fetchRootTerms.
- Specified by:
fetchRootTermsin interfaceOntologyTermFetcher- Parameters:
database- aCvTermobject.- Returns:
- a
Setobject. - Throws:
BridgeFailedException- if any.
-
-