public class ORCIDHelper
extends java.lang.Object
client
.
Provides support for asynchronous communication with ORCID
although it is only active for GET requests due to resource
limitations.Modifier and Type | Class and Description |
---|---|
static class |
ORCIDHelper.EIdType |
Modifier and Type | Field and Description |
---|---|
ORCIDClient |
client
The client used to communicate with ORCID.
|
static java.lang.String |
INVALID_EXTERNALIDENTIFIERS |
static java.lang.String |
INVALID_PUBLICATIONDATE |
static java.lang.String |
INVALID_TITLE |
static java.lang.String |
INVALID_TYPE |
static java.lang.String |
INVALID_YEAR |
Constructor and Description |
---|
ORCIDHelper(ORCIDClient orcidClient)
Initializes the helper with a given ORCID client.
|
Modifier and Type | Method and Description |
---|---|
java.math.BigInteger |
addWork(org.um.dsi.gavea.orcid.model.work.Work work)
Synchronously adds a work to an ORCID profile.
|
static org.um.dsi.gavea.orcid.model.work.Work |
clone(org.um.dsi.gavea.orcid.model.work.Work work)
Clones a work summary.
|
static org.um.dsi.gavea.orcid.model.work.WorkSummary |
clone(org.um.dsi.gavea.orcid.model.work.WorkSummary work)
Clones a work summary.
|
void |
deleteAllSourcedWorks()
Deletes the entire set of work summaries in the ORCID profile whose
source is the Member API id defined in the ORCID client.
|
void |
deleteWork(java.math.BigInteger putcode)
Synchronously deletes a work in an ORCID profile.
|
static java.math.BigInteger |
getActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary act)
Retrieves the local key of an activity, currently assumed to be stored in
the put-code field.
|
java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> |
getAllWorkSummaries()
Retrieves the entire set of work summaries from the set ORCID profile
that have at least an external identifier set.
|
static java.util.Map<org.um.dsi.gavea.orcid.model.work.Work,ExternalIdsDiff> |
getExternalIdsDiff(org.um.dsi.gavea.orcid.model.work.WorkSummary work,
java.util.Collection<org.um.dsi.gavea.orcid.model.work.Work> works)
Calculates the symmetric difference of
external
identifiers between a work and a set of works. |
org.um.dsi.gavea.orcid.model.work.Work |
getFullWork(org.um.dsi.gavea.orcid.model.work.WorkSummary mergedWork)
Synchronously gets a full work from an ORCID profile.
|
void |
getFullWork(org.um.dsi.gavea.orcid.model.work.WorkSummary mergedWork,
java.util.Map<java.math.BigInteger,java.lang.Object> cb)
Asynchronously gets a full work from an ORCID profile.
|
java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> |
getSourcedWorkSummaries()
Retrieves the entire set of work summaries in the ORCID profile whose
source is the Member API id defined in the ORCID client.
|
static boolean |
hasNewIDs(org.um.dsi.gavea.orcid.model.work.Work preWork,
org.um.dsi.gavea.orcid.model.work.WorkSummary posWork)
Checks whether a work is already up to date regarding another one, i.e.,
whether a work has the same
external
identifiers as another one. |
static boolean |
isUpToDate(org.um.dsi.gavea.orcid.model.work.Work preWork,
org.um.dsi.gavea.orcid.model.work.Work posWork)
Checks whether a work is already up to date regarding another one,
considering the
external identifiers and
additional meta-data. |
static boolean |
isUpToDate(org.um.dsi.gavea.orcid.model.work.Work preWork,
org.um.dsi.gavea.orcid.model.work.WorkSummary posWork)
Checks whether a work is already up to date regarding another one,
considering the
external identifiers and
additional meta-data. |
static void |
setWorkLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary act,
java.math.BigInteger key)
Retrieves the local key of an activity, currently assumed to be stored in
the put-code field.
|
static java.util.Set<java.lang.String> |
testMinimalQuality(org.um.dsi.gavea.orcid.model.work.Work work)
Tests whether a work has minimal quality to be synchronized, by
inspecting its meta-data, returns the detected invalid fields.
|
static java.util.Set<java.lang.String> |
testMinimalQuality(org.um.dsi.gavea.orcid.model.work.WorkSummary work)
Tests whether a work has minimal quality to be synchronized, by
inspecting its meta-data, returns the detected invalid fields.
|
static void |
tryMinimalQuality(org.um.dsi.gavea.orcid.model.work.Work work)
Tests whether a work has minimal quality to be synchronized, by
inspecting its meta-data.
|
static void |
tryMinimalQuality(org.um.dsi.gavea.orcid.model.work.WorkSummary work)
Tests whether a work has minimal quality to be synchronized, by
inspecting its meta-data.
|
void |
updateWork(java.math.BigInteger remotePutcode,
org.um.dsi.gavea.orcid.model.work.Work updatedWork)
Synchronously updates a work in an ORCID profile.
|
boolean |
waitWorkers()
Waits for all active asynchronous workers communicating with ORCID to
finish (if multi-threading is enabled, otherwise it is always true).
|
public static final java.lang.String INVALID_EXTERNALIDENTIFIERS
public static final java.lang.String INVALID_TITLE
public static final java.lang.String INVALID_PUBLICATIONDATE
public static final java.lang.String INVALID_YEAR
public static final java.lang.String INVALID_TYPE
public final ORCIDClient client
public ORCIDHelper(ORCIDClient orcidClient)
orcidClient
- the ORCID clientpublic java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> getAllWorkSummaries() throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
groupToWork(org.um.dsi.gavea.orcid.model.activities.WorkGroup)
.org.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if the communication with ORCID failspublic java.util.List<org.um.dsi.gavea.orcid.model.work.WorkSummary> getSourcedWorkSummaries() throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
org.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if the communication with ORCID failspublic void getFullWork(org.um.dsi.gavea.orcid.model.work.WorkSummary mergedWork, java.util.Map<java.math.BigInteger,java.lang.Object> cb) throws java.lang.NullPointerException
mergedWork
- the work summary representing a merged groupcb
- the callback objectjava.lang.NullPointerException
- if the merged work is nullORCIDClient.getWork(BigInteger)
public org.um.dsi.gavea.orcid.model.work.Work getFullWork(org.um.dsi.gavea.orcid.model.work.WorkSummary mergedWork) throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException, java.lang.NullPointerException
mergedWork
- the work summary representing a merged grouporg.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if communication with the ORCID API failsjava.lang.NullPointerException
- if the merged work is nullORCIDClient.getWork(BigInteger)
public java.math.BigInteger addWork(org.um.dsi.gavea.orcid.model.work.Work work) throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException, java.lang.NullPointerException
work
- the new work to be addedorg.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if communication with the ORCID API failsjava.lang.NullPointerException
- if the work is nullORCIDClient.addWork(Work)
public void updateWork(java.math.BigInteger remotePutcode, org.um.dsi.gavea.orcid.model.work.Work updatedWork) throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException, java.lang.NullPointerException
remotePutcode
- the put-code of the remote ORCID work that will be updatedupdatedWork
- the new state of the work that will be updatedorg.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if communication with the ORCID API failsjava.lang.NullPointerException
- if either parameter is nullORCIDClient.updateWork(BigInteger, Work)
public void deleteAllSourcedWorks() throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException
org.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if the communication with ORCID failspublic void deleteWork(java.math.BigInteger putcode) throws org.um.dsi.gavea.orcid.client.exception.OrcidClientException, java.lang.NullPointerException
putcode
- the remote put-code of the work to be deletedorg.um.dsi.gavea.orcid.client.exception.OrcidClientException
- if the communication with ORCID failsjava.lang.NullPointerException
- if the put-code is nullORCIDClient.deleteWork(BigInteger)
public boolean waitWorkers() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the process was interruptedpublic static java.math.BigInteger getActivityLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary act) throws java.lang.NullPointerException
act
- the activity from which to get the local keyjava.lang.NullPointerException
- if the activity is nullpublic static void setWorkLocalKey(org.um.dsi.gavea.orcid.model.common.ElementSummary act, java.math.BigInteger key) throws java.lang.NullPointerException
act
- the activity to which to set the local keykey
- the local keyjava.lang.NullPointerException
- if the activity is nullpublic static java.util.Map<org.um.dsi.gavea.orcid.model.work.Work,ExternalIdsDiff> getExternalIdsDiff(org.um.dsi.gavea.orcid.model.work.WorkSummary work, java.util.Collection<org.um.dsi.gavea.orcid.model.work.Work> works) throws java.lang.NullPointerException
external
identifiers
between a work and a set of works. Works that do not match
(i.e., no identifier is common) are ignored.work
- the work summary to be compared with other worksworks
- the set of works against which the work summary is comparedjava.lang.NullPointerException
- if either of the parameters is nullpublic static boolean hasNewIDs(org.um.dsi.gavea.orcid.model.work.Work preWork, org.um.dsi.gavea.orcid.model.work.WorkSummary posWork)
external
identifiers
as another one.
This test is expected to be used by the import algorithms, where only new
external identifiers are to be considered.preWork
- The potentially out of date work.posWork
- The up to date work.public static boolean isUpToDate(org.um.dsi.gavea.orcid.model.work.Work preWork, org.um.dsi.gavea.orcid.model.work.WorkSummary posWork)
external identifiers
and
additional meta-data.
This test is expected to be used by the export algorithms, where the
meta-data is expected to be up-to-date on the remote profile.preWork
- the potentially out of date workposWork
- the up to date workpublic static boolean isUpToDate(org.um.dsi.gavea.orcid.model.work.Work preWork, org.um.dsi.gavea.orcid.model.work.Work posWork)
external identifiers
and
additional meta-data.preWork
- the potentially out of date workposWork
- the up to date workpublic static java.util.Set<java.lang.String> testMinimalQuality(org.um.dsi.gavea.orcid.model.work.Work work) throws java.lang.NullPointerException
work
- the work to test for qualityjava.lang.NullPointerException
- if the work is nullpublic static java.util.Set<java.lang.String> testMinimalQuality(org.um.dsi.gavea.orcid.model.work.WorkSummary work) throws java.lang.NullPointerException
work
- the work to test for qualityjava.lang.NullPointerException
- if the work is nullpublic static void tryMinimalQuality(org.um.dsi.gavea.orcid.model.work.Work work) throws InvalidWorkException
work
- the work to test for qualityInvalidWorkException
- if the quality test fails, containing the reasons for failingjava.lang.NullPointerException
- if the work is nullpublic static void tryMinimalQuality(org.um.dsi.gavea.orcid.model.work.WorkSummary work) throws InvalidWorkException
work
- the work to test for qualityInvalidWorkException
- if the quality test fails, containing the reasons for failingjava.lang.NullPointerException
- if the work is nullpublic static org.um.dsi.gavea.orcid.model.work.WorkSummary clone(org.um.dsi.gavea.orcid.model.work.WorkSummary work)
work
- the summary to be clonedpublic static org.um.dsi.gavea.orcid.model.work.Work clone(org.um.dsi.gavea.orcid.model.work.Work work)
work
- the summary to be cloned