Class MockImexCentralClient
- java.lang.Object
-
- psidev.psi.mi.jami.bridges.imex.mock.MockImexCentralClient
-
- All Implemented Interfaces:
PublicationFetcher
,ImexCentralClient
public class MockImexCentralClient extends Object implements ImexCentralClient
Dummy service that one can use to write test against.
-
-
Field Summary
-
Fields inherited from interface psidev.psi.mi.jami.bridges.imex.ImexCentralClient
IC_BETA, IC_PROD, IC_TEST, IDENTIFIER_MISSING, IDENTIFIER_UNKNOWN, INTERNAL_SERVER_ERROR, NO_IMEX_ID, NO_RECORD, NO_RECORD_CREATED, OPERATION_NOT_SUPPORTED, OPERATION_NOT_VALID, STATUS_UNKNOWN, UNKNOWN_GROUP, UNKNOWN_USER, USER_NOT_AUTHORIZED
-
-
Constructor Summary
Constructors Constructor Description MockImexCentralClient()
Constructor for MockImexCentralClient.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPublication(String identifier, String imexAccession, String status, String owner)
addPublication.void
addPublication(Publication p)
addPublication.void
createPublication(Publication publication)
Create a new publication record in IMEx central (not implemented yet in production but can be used in test with the MockImexCentralClient)Publication
createPublicationById(String identifier, String source)
Creates a publication given a valid pubmed id.Publication
fetchByIdentifier(String identifier, String source)
Uses the identifier to search for a publication and return a completed record.Collection<Publication>
fetchByIdentifiers(Map<String,Collection<String>> identifiers)
Uses the identifiers to search for publications and return completed records.Publication
fetchPublicationImexAccession(String identifier, String source, boolean create)
Create a new IMEx id if requested for a given pubmed idList<Publication>
fetchPublicationsByOwner(String owner, int first, int max)
Collect a list of publications associated with a specific owner.List<Publication>
fetchPublicationsByStatus(String status, int first, int max)
Collect a list of publications having a specific status.String
getEndpoint()
getEndpoint.int
getNextSequenceValue()
getNextSequenceValue.Set<String>
initializeImexDBGroups()
void
initImexSequence(int sequence)
initImexSequence.void
initPublications(List<Publication> allPublications)
initPublications.Publication
updatePublicationAdminGroup(String identifier, String source, Operation operation, String group)
Update the publication admin group given a valid pubmed identifier and a valid operator.Publication
updatePublicationAdminUser(String identifier, String source, Operation operation, String user)
Update the publication admin user given a valid pubmed identifier and a valid operator.Publication
updatePublicationIdentifier(String oldIdentifier, String oldSource, String newIdentifier, String source)
Update publication pubmed identifier, DOI number or internal identifier of an existing record in IMEx central.Publication
updatePublicationStatus(String identifier, String source, PublicationStatus status)
Update the status of a publication associated with a valid pubmed identifier already registered in IMEx central
-
-
-
Method Detail
-
initImexSequence
public void initImexSequence(int sequence)
initImexSequence.
- Parameters:
sequence
- a int.
-
initPublications
public void initPublications(List<Publication> allPublications)
initPublications.
- Parameters:
allPublications
- aList
object.
-
getNextSequenceValue
public int getNextSequenceValue()
getNextSequenceValue.
- Returns:
- a int.
-
addPublication
public void addPublication(Publication p)
addPublication.
- Parameters:
p
- aPublication
object.
-
addPublication
public void addPublication(String identifier, String imexAccession, String status, String owner)
addPublication.
-
getEndpoint
public String getEndpoint()
getEndpoint.
- Specified by:
getEndpoint
in interfaceImexCentralClient
- Returns:
- a
String
object.
-
fetchByIdentifier
public Publication fetchByIdentifier(String identifier, String source) throws BridgeFailedException
Uses the identifier to search for a publication and return a completed record.- Specified by:
fetchByIdentifier
in interfacePublicationFetcher
- Parameters:
identifier
- The identifier of the publication to search for.source
- The database that the identifier is from (pubmed, doi, ...).- Returns:
- A completed record for the publication or null if no publication could be found.
- Throws:
BridgeFailedException
- if any.
-
fetchByIdentifiers
public Collection<Publication> fetchByIdentifiers(Map<String,Collection<String>> identifiers) throws BridgeFailedException
Uses the identifiers to search for publications and return completed records.- Specified by:
fetchByIdentifiers
in interfacePublicationFetcher
- Parameters:
identifiers
- The identifiers of the publications to search for per publication identifier source (pubmed, doi, ...).- Returns:
- Completed records for the publications.
- Throws:
BridgeFailedException
- if any.
-
fetchPublicationsByOwner
public List<Publication> fetchPublicationsByOwner(String owner, int first, int max) throws BridgeFailedException
Collect a list of publications associated with a specific owner. Selects first and last results- Specified by:
fetchPublicationsByOwner
in interfaceImexCentralClient
- Parameters:
owner
- : login of ownerfirst
- : first resultmax
- : last result- Returns:
- list of publications associated with this owner, empty list if no results
- Throws:
BridgeFailedException
- if any.
-
fetchPublicationsByStatus
public List<Publication> fetchPublicationsByStatus(String status, int first, int max) throws BridgeFailedException
Collect a list of publications having a specific status. Selects first and last results- Specified by:
fetchPublicationsByStatus
in interfaceImexCentralClient
- Parameters:
status
- : the status of publication in IMEx centralfirst
- : first resultmax
- : last result- Returns:
- list of publications associated with this status, empty list if no results
- Throws:
BridgeFailedException
- if any.
-
updatePublicationStatus
public Publication updatePublicationStatus(String identifier, String source, PublicationStatus status) throws BridgeFailedException
Update the status of a publication associated with a valid pubmed identifier already registered in IMEx central- Specified by:
updatePublicationStatus
in interfaceImexCentralClient
- Parameters:
identifier
- : a valid pubmed identifiersource
- : the source pubmed, doi or imexstatus
- : new status- Returns:
- the updated record in IMEx central
- Throws:
BridgeFailedException
- if no record found in IMEx central, no pubmed identifier or invalid status
-
updatePublicationAdminGroup
public Publication updatePublicationAdminGroup(String identifier, String source, Operation operation, String group) throws BridgeFailedException
Update the publication admin group given a valid pubmed identifier and a valid operator. The publication must be registered in IMEx central- Specified by:
updatePublicationAdminGroup
in interfaceImexCentralClient
- Parameters:
identifier
- : valid pubmed idsource
- : the source pubmed, doi or imexoperation
- : DROP or ADDgroup
- : the name of the admin group- Returns:
- the updated record in IMEx central
- Throws:
BridgeFailedException
- if no record found in IMEX central, no pubmed identifiier or unknown group
-
updatePublicationAdminUser
public Publication updatePublicationAdminUser(String identifier, String source, Operation operation, String user) throws BridgeFailedException
Update the publication admin user given a valid pubmed identifier and a valid operator. The publication must be registered in IMEx central- Specified by:
updatePublicationAdminUser
in interfaceImexCentralClient
- Parameters:
identifier
- aString
object.source
- pubmed, doi or imexoperation
- aOperation
object.user
- aString
object.- Returns:
- the updated record in IMEx central
- Throws:
BridgeFailedException
- if no record found in IMEX central, no pubmed identifiier or unknown user
-
updatePublicationIdentifier
public Publication updatePublicationIdentifier(String oldIdentifier, String oldSource, String newIdentifier, String source) throws BridgeFailedException
Update publication pubmed identifier, DOI number or internal identifier of an existing record in IMEx central. The new publication identifier should not be already registered in IMEx central- Specified by:
updatePublicationIdentifier
in interfaceImexCentralClient
- Parameters:
oldIdentifier
- : can be pubmed, imex, doi or internal identifieroldSource
- : the source of old identifiernewIdentifier
- : can be pubmed, doi or internal identifiersource
- : the source pubmed, doi or imex- Returns:
- a
Publication
object. - Throws:
BridgeFailedException
- if no record found in IMEX central, identifier not recognized or new identifier is associated with another publication in IMEx central
-
createPublication
public void createPublication(Publication publication) throws BridgeFailedException
Create a new publication record in IMEx central (not implemented yet in production but can be used in test with the MockImexCentralClient)- Specified by:
createPublication
in interfaceImexCentralClient
- Parameters:
publication
- : the publication to create in IMEx central- Throws:
BridgeFailedException
- if any.
-
createPublicationById
public Publication createPublicationById(String identifier, String source) throws BridgeFailedException
Creates a publication given a valid pubmed id.- Specified by:
createPublicationById
in interfaceImexCentralClient
- Parameters:
identifier
- : valid pubmed idsource
- aString
object.- Returns:
- the newly created record
- Throws:
BridgeFailedException
- if identifier is not valid pubmed or if the pubmed id is already registered in IMEx central
-
fetchPublicationImexAccession
public Publication fetchPublicationImexAccession(String identifier, String source, boolean create) throws BridgeFailedException
Create a new IMEx id if requested for a given pubmed id- Specified by:
fetchPublicationImexAccession
in interfaceImexCentralClient
- Parameters:
identifier
- : a valid pubmed identifiersource
- : a valid source (imex, pubmed or doi)create
- : true if we want to assign a new IMEx id, false otherwise- Returns:
- the updated record in IMEx central
- Throws:
BridgeFailedException
- if not a valid pubmed id, not existing record and cannot generate a new IMEx id
-
-