Package org.dspace.orcid.service.impl
Class OrcidSynchronizationServiceImpl
- java.lang.Object
-
- org.dspace.orcid.service.impl.OrcidSynchronizationServiceImpl
-
- All Implemented Interfaces:
OrcidSynchronizationService
public class OrcidSynchronizationServiceImpl extends Object implements OrcidSynchronizationService
Implementation ofOrcidSynchronizationService.- Author:
- Luca Giamminonni (luca.giamminonni at 4science.it)
-
-
Constructor Summary
Constructors Constructor Description OrcidSynchronizationServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Item>findProfilesByOrcid(Context context, String orcid)Returns all the profiles with the given orcid id.OrcidProfileDisconnectionModegetDisconnectionMode()Returns the configuration ORCID profile's disconnection mode.Optional<OrcidEntitySyncPreference>getEntityPreference(Item item, OrcidEntityType entityType)Returns the ORCID synchronization preference related to the given entity type configured for the given profile item.Optional<String>getOrcid(Item item)List<OrcidProfileSyncPreference>getProfilePreferences(Item item)Returns the ORCID synchronization preferences related to the profile itself configured for the given profile item.Optional<OrcidSynchronizationMode>getSynchronizationMode(Item item)Returns the ORCID synchronization mode configured for the given profile item.booleanisLinkedToOrcid(Context context, Item item)Check if the given item is linked to an ORCID profile.booleanisSynchronizationAllowed(Item profile, Item item)Check if the given researcher profile item is configured to synchronize the given item with ORCID.voidlinkProfile(Context context, Item profile, OrcidTokenResponseDTO token)Configure the given profile with the data present in the given ORCID token.booleansetEntityPreference(Context context, Item profile, OrcidEntityType type, OrcidEntitySyncPreference value)Set the synchronization preference for the given profile related to the given ORCID entity type.booleansetProfilePreference(Context context, Item profile, List<OrcidProfileSyncPreference> values)Update the profile's synchronization preference for the given profile.booleansetSynchronizationMode(Context context, Item profile, OrcidSynchronizationMode value)Set the ORCID synchronization mode for the given profile.voidunlinkProfile(Context context, Item profile)Disconnect the given profile from ORCID.
-
-
-
Method Detail
-
linkProfile
public void linkProfile(Context context, Item profile, OrcidTokenResponseDTO token) throws SQLException
Description copied from interface:OrcidSynchronizationServiceConfigure the given profile with the data present in the given ORCID token. This action is required to synchronize profile and related entities with ORCID. No security check is done, it is therefore the caller's responsibility to verify for example that the current user has permission to connect the profile to ORCID (if necessary).- Specified by:
linkProfilein interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.profile- the profile to configuretoken- the ORCID token- Throws:
SQLException- if a SQL error occurs during the profile update
-
unlinkProfile
public void unlinkProfile(Context context, Item profile) throws SQLException
Description copied from interface:OrcidSynchronizationServiceDisconnect the given profile from ORCID.- Specified by:
unlinkProfilein interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.profile- the profile to disconnect- Throws:
SQLException- if a SQL error occurs during the profile update
-
setEntityPreference
public boolean setEntityPreference(Context context, Item profile, OrcidEntityType type, OrcidEntitySyncPreference value) throws SQLException
Description copied from interface:OrcidSynchronizationServiceSet the synchronization preference for the given profile related to the given ORCID entity type.- Specified by:
setEntityPreferencein interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.profile- the researcher profile to updatetype- the orcid entity typevalue- the new synchronization preference value- Returns:
- true if the value has actually been updated, false if the value to be set is the same as the one already configured
- Throws:
SQLException- if a SQL error occurs during the profile update
-
setProfilePreference
public boolean setProfilePreference(Context context, Item profile, List<OrcidProfileSyncPreference> values) throws SQLException
Description copied from interface:OrcidSynchronizationServiceUpdate the profile's synchronization preference for the given profile.- Specified by:
setProfilePreferencein interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.profile- the researcher profile to updatevalues- the new synchronization preference values- Returns:
- true if the value has actually been updated, false if the value to be set is the same as the one already configured
- Throws:
SQLException- if a SQL error occurs during the profile update
-
setSynchronizationMode
public boolean setSynchronizationMode(Context context, Item profile, OrcidSynchronizationMode value) throws SQLException
Description copied from interface:OrcidSynchronizationServiceSet the ORCID synchronization mode for the given profile.- Specified by:
setSynchronizationModein interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.profile- the researcher profile to updatevalue- the new synchronization mode value- Returns:
- true if the value has actually been updated, false if the value to be set is the same as the one already configured
- Throws:
SQLException- if a SQL error occurs during the profile update
-
isSynchronizationAllowed
public boolean isSynchronizationAllowed(Item profile, Item item)
Description copied from interface:OrcidSynchronizationServiceCheck if the given researcher profile item is configured to synchronize the given item with ORCID.- Specified by:
isSynchronizationAllowedin interfaceOrcidSynchronizationService- Parameters:
profile- the researcher profile itemitem- the entity type to check- Returns:
- true if the given entity type can be synchronize with ORCID, false otherwise
-
getSynchronizationMode
public Optional<OrcidSynchronizationMode> getSynchronizationMode(Item item)
Description copied from interface:OrcidSynchronizationServiceReturns the ORCID synchronization mode configured for the given profile item.- Specified by:
getSynchronizationModein interfaceOrcidSynchronizationService- Parameters:
item- the researcher profile item- Returns:
- the synchronization mode
-
getEntityPreference
public Optional<OrcidEntitySyncPreference> getEntityPreference(Item item, OrcidEntityType entityType)
Description copied from interface:OrcidSynchronizationServiceReturns the ORCID synchronization preference related to the given entity type configured for the given profile item.- Specified by:
getEntityPreferencein interfaceOrcidSynchronizationService- Parameters:
item- the researcher profile itementityType- the orcid entity type- Returns:
- the configured preference
-
getProfilePreferences
public List<OrcidProfileSyncPreference> getProfilePreferences(Item item)
Description copied from interface:OrcidSynchronizationServiceReturns the ORCID synchronization preferences related to the profile itself configured for the given profile item.- Specified by:
getProfilePreferencesin interfaceOrcidSynchronizationService- Parameters:
item- the researcher profile item- Returns:
- the synchronization mode
-
isLinkedToOrcid
public boolean isLinkedToOrcid(Context context, Item item)
Description copied from interface:OrcidSynchronizationServiceCheck if the given item is linked to an ORCID profile.- Specified by:
isLinkedToOrcidin interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.item- the item to check- Returns:
- true if the given item is linked to ORCID
-
getDisconnectionMode
public OrcidProfileDisconnectionMode getDisconnectionMode()
Description copied from interface:OrcidSynchronizationServiceReturns the configuration ORCID profile's disconnection mode. If that mode is not configured or the configuration is wrong, the value DISABLED is returned.- Specified by:
getDisconnectionModein interfaceOrcidSynchronizationService- Returns:
- the disconnection mode
-
findProfilesByOrcid
public List<Item> findProfilesByOrcid(Context context, String orcid)
Description copied from interface:OrcidSynchronizationServiceReturns all the profiles with the given orcid id.- Specified by:
findProfilesByOrcidin interfaceOrcidSynchronizationService- Parameters:
context- the relevant DSpace Context.orcid- the orcid id to search for- Returns:
- the found profile items
-
-