mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
DS-3447: ORCID v2 integration (port to master from PR#2039)
This commit is contained in:
@@ -734,6 +734,18 @@
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- For ORCID v2 integration -->
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>orcid-jaxb-api</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20180130</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||
*/
|
||||
public interface SolrAuthorityInterface {
|
||||
|
||||
List<AuthorityValue> queryAuthorities(String text, int max);
|
||||
|
||||
AuthorityValue queryAuthorityID(String id);
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.orcid.model.Bio;
|
||||
import org.dspace.authority.orcid.model.Work;
|
||||
import org.dspace.authority.orcid.xml.XMLtoBio;
|
||||
import org.dspace.authority.orcid.xml.XMLtoWork;
|
||||
import org.dspace.authority.rest.RestSource;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class Orcid extends RestSource {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(Orcid.class);
|
||||
|
||||
private static Orcid orcid;
|
||||
|
||||
public static Orcid getOrcid() {
|
||||
if (orcid == null) {
|
||||
orcid = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName("OrcidSource", Orcid.class);
|
||||
}
|
||||
return orcid;
|
||||
}
|
||||
|
||||
private Orcid(String url) {
|
||||
super(url);
|
||||
}
|
||||
|
||||
public Bio getBio(String id) {
|
||||
Document bioDocument = restConnector.get(id + "/orcid-bio");
|
||||
XMLtoBio converter = new XMLtoBio();
|
||||
Bio bio = converter.convert(bioDocument).get(0);
|
||||
bio.setOrcid(id);
|
||||
return bio;
|
||||
}
|
||||
|
||||
public List<Work> getWorks(String id) {
|
||||
Document document = restConnector.get(id + "/orcid-works");
|
||||
XMLtoWork converter = new XMLtoWork();
|
||||
return converter.convert(document);
|
||||
}
|
||||
|
||||
public List<Bio> queryBio(String name, int start, int rows) {
|
||||
Document bioDocument = restConnector
|
||||
.get("search/orcid-bio?q=" + URLEncoder.encode("\"" + name + "\"") + "&start=" + start + "&rows=" + rows);
|
||||
XMLtoBio converter = new XMLtoBio();
|
||||
return converter.convert(bioDocument);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityValue> queryAuthorities(String text, int max) {
|
||||
List<Bio> bios = queryBio(text, 0, max);
|
||||
List<AuthorityValue> authorities = new ArrayList<AuthorityValue>();
|
||||
for (Bio bio : bios) {
|
||||
authorities.add(OrcidAuthorityValue.create(bio));
|
||||
}
|
||||
return authorities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorityValue queryAuthorityID(String id) {
|
||||
Bio bio = getBio(id);
|
||||
return OrcidAuthorityValue.create(bio);
|
||||
}
|
||||
}
|
@@ -1,328 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.AuthorityValueServiceImpl;
|
||||
import org.dspace.authority.PersonAuthorityValue;
|
||||
import org.dspace.authority.orcid.model.Bio;
|
||||
import org.dspace.authority.orcid.model.BioExternalIdentifier;
|
||||
import org.dspace.authority.orcid.model.BioName;
|
||||
import org.dspace.authority.orcid.model.BioResearcherUrl;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class OrcidAuthorityValue extends PersonAuthorityValue {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(OrcidAuthorityValue.class);
|
||||
|
||||
private String orcid_id;
|
||||
private Map<String, List<String>> otherMetadata = new HashMap<String, List<String>>();
|
||||
private boolean update; // used in setValues(Bio bio)
|
||||
|
||||
|
||||
/**
|
||||
* Creates an instance of OrcidAuthorityValue with only uninitialized fields.
|
||||
* This is meant to be filled in with values from an existing record.
|
||||
* To create a brand new OrcidAuthorityValue, use create()
|
||||
*/
|
||||
public OrcidAuthorityValue() {
|
||||
}
|
||||
|
||||
public OrcidAuthorityValue(SolrDocument document) {
|
||||
super(document);
|
||||
}
|
||||
|
||||
public String getOrcid_id() {
|
||||
return orcid_id;
|
||||
}
|
||||
|
||||
public void setOrcid_id(String orcid_id) {
|
||||
this.orcid_id = orcid_id;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getOtherMetadata() {
|
||||
return otherMetadata;
|
||||
}
|
||||
|
||||
public void addOtherMetadata(String label, String data) {
|
||||
List<String> strings = otherMetadata.get(label);
|
||||
if (strings == null) {
|
||||
strings = new ArrayList<String>();
|
||||
}
|
||||
strings.add(data);
|
||||
otherMetadata.put(label, strings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrInputDocument getSolrInputDocument() {
|
||||
SolrInputDocument doc = super.getSolrInputDocument();
|
||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||
doc.addField("orcid_id", getOrcid_id());
|
||||
}
|
||||
|
||||
for (String t : otherMetadata.keySet()) {
|
||||
List<String> data = otherMetadata.get(t);
|
||||
for (String data_entry : data) {
|
||||
doc.addField("label_" + t, data_entry);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(SolrDocument document) {
|
||||
super.setValues(document);
|
||||
this.orcid_id = String.valueOf(document.getFieldValue("orcid_id"));
|
||||
|
||||
otherMetadata = new HashMap<String, List<String>>();
|
||||
for (String fieldName : document.getFieldNames()) {
|
||||
String labelPrefix = "label_";
|
||||
if (fieldName.startsWith(labelPrefix)) {
|
||||
String label = fieldName.substring(labelPrefix.length());
|
||||
List<String> list = new ArrayList<String>();
|
||||
Collection<Object> fieldValues = document.getFieldValues(fieldName);
|
||||
for (Object o : fieldValues) {
|
||||
list.add(String.valueOf(o));
|
||||
}
|
||||
otherMetadata.put(label, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static OrcidAuthorityValue create() {
|
||||
OrcidAuthorityValue orcidAuthorityValue = new OrcidAuthorityValue();
|
||||
orcidAuthorityValue.setId(UUID.randomUUID().toString());
|
||||
orcidAuthorityValue.updateLastModifiedDate();
|
||||
orcidAuthorityValue.setCreationDate(new Date());
|
||||
return orcidAuthorityValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an authority based on a given orcid bio
|
||||
*
|
||||
* @param bio Bio
|
||||
* @return OrcidAuthorityValue
|
||||
*/
|
||||
public static OrcidAuthorityValue create(Bio bio) {
|
||||
OrcidAuthorityValue authority = OrcidAuthorityValue.create();
|
||||
|
||||
authority.setValues(bio);
|
||||
|
||||
return authority;
|
||||
}
|
||||
|
||||
public boolean setValues(Bio bio) {
|
||||
BioName name = bio.getName();
|
||||
|
||||
if (updateValue(bio.getOrcid(), getOrcid_id())) {
|
||||
setOrcid_id(bio.getOrcid());
|
||||
}
|
||||
|
||||
if (updateValue(name.getFamilyName(), getLastName())) {
|
||||
setLastName(name.getFamilyName());
|
||||
}
|
||||
|
||||
if (updateValue(name.getGivenNames(), getFirstName())) {
|
||||
setFirstName(name.getGivenNames());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(name.getCreditName())) {
|
||||
if (!getNameVariants().contains(name.getCreditName())) {
|
||||
addNameVariant(name.getCreditName());
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
for (String otherName : name.getOtherNames()) {
|
||||
if (!getNameVariants().contains(otherName)) {
|
||||
addNameVariant(otherName);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updateOtherMetadata("country", bio.getCountry())) {
|
||||
addOtherMetadata("country", bio.getCountry());
|
||||
}
|
||||
|
||||
for (String keyword : bio.getKeywords()) {
|
||||
if (updateOtherMetadata("keyword", keyword)) {
|
||||
addOtherMetadata("keyword", keyword);
|
||||
}
|
||||
}
|
||||
|
||||
for (BioExternalIdentifier externalIdentifier : bio.getBioExternalIdentifiers()) {
|
||||
if (updateOtherMetadata("external_identifier", externalIdentifier.toString())) {
|
||||
addOtherMetadata("external_identifier", externalIdentifier.toString());
|
||||
}
|
||||
}
|
||||
|
||||
for (BioResearcherUrl researcherUrl : bio.getResearcherUrls()) {
|
||||
if (updateOtherMetadata("researcher_url", researcherUrl.toString())) {
|
||||
addOtherMetadata("researcher_url", researcherUrl.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (updateOtherMetadata("biography", bio.getBiography())) {
|
||||
addOtherMetadata("biography", bio.getBiography());
|
||||
}
|
||||
|
||||
setValue(getName());
|
||||
|
||||
if (update) {
|
||||
update();
|
||||
}
|
||||
boolean result = update;
|
||||
update = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean updateOtherMetadata(String label, String data) {
|
||||
List<String> strings = getOtherMetadata().get(label);
|
||||
boolean update;
|
||||
if (strings == null) {
|
||||
update = StringUtils.isNotBlank(data);
|
||||
} else {
|
||||
update = !strings.contains(data);
|
||||
}
|
||||
if (update) {
|
||||
this.update = true;
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
private boolean updateValue(String incoming, String resident) {
|
||||
boolean update = StringUtils.isNotBlank(incoming) && !incoming.equals(resident);
|
||||
if (update) {
|
||||
this.update = true;
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> choiceSelectMap() {
|
||||
|
||||
Map<String, String> map = super.choiceSelectMap();
|
||||
|
||||
map.put("orcid", getOrcid_id());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorityType() {
|
||||
return "orcid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateString() {
|
||||
String generateString = AuthorityValueServiceImpl.GENERATE + getAuthorityType() + AuthorityValueServiceImpl
|
||||
.SPLIT;
|
||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||
generateString += getOrcid_id();
|
||||
}
|
||||
return generateString;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AuthorityValue newInstance(String info) {
|
||||
AuthorityValue authorityValue = null;
|
||||
if (StringUtils.isNotBlank(info)) {
|
||||
Orcid orcid = Orcid.getOrcid();
|
||||
authorityValue = orcid.queryAuthorityID(info);
|
||||
} else {
|
||||
authorityValue = OrcidAuthorityValue.create();
|
||||
}
|
||||
return authorityValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OrcidAuthorityValue that = (OrcidAuthorityValue) o;
|
||||
|
||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return orcid_id != null ? orcid_id.hashCode() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTheSameInformationAs(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.hasTheSameInformationAs(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OrcidAuthorityValue that = (OrcidAuthorityValue) o;
|
||||
|
||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String key : otherMetadata.keySet()) {
|
||||
if (otherMetadata.get(key) != null) {
|
||||
List<String> metadata = otherMetadata.get(key);
|
||||
List<String> otherMetadata = that.otherMetadata.get(key);
|
||||
if (otherMetadata == null) {
|
||||
return false;
|
||||
} else {
|
||||
HashSet<String> metadataSet = new HashSet<String>(metadata);
|
||||
HashSet<String> otherMetadataSet = new HashSet<String>(otherMetadata);
|
||||
if (!metadataSet.equals(otherMetadataSet)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (that.otherMetadata.get(key) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
188
dspace-api/src/main/java/org/dspace/authority/orcid/Orcidv2.java
Normal file
188
dspace-api/src/main/java/org/dspace/authority/orcid/Orcidv2.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.SolrAuthorityInterface;
|
||||
import org.dspace.authority.orcid.xml.XMLtoBio;
|
||||
import org.dspace.authority.rest.RESTConnector;
|
||||
import org.json.JSONObject;
|
||||
import org.orcid.jaxb.model.record_v2.Person;
|
||||
|
||||
/**
|
||||
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||
* This class contains all methods for retrieving "Person" objects calling the ORCID (version 2) endpoints.
|
||||
* Additionally, this can also create AuthorityValues based on these returned Person objects
|
||||
*/
|
||||
public class Orcidv2 implements SolrAuthorityInterface {
|
||||
|
||||
private static Logger log = Logger.getLogger(Orcidv2.class);
|
||||
|
||||
public RESTConnector restConnector;
|
||||
private String OAUTHUrl;
|
||||
private String clientId;
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* Initialize the accessToken that is required for all subsequent calls to ORCID
|
||||
*/
|
||||
public void init() throws IOException {
|
||||
if (StringUtils.isNotBlank(accessToken) && StringUtils.isNotBlank(clientSecret)) {
|
||||
String authenticationParameters = "?client_id=" + clientId +
|
||||
"&client_secret=" + clientSecret +
|
||||
"&scope=/read-public&grant_type=client_credentials";
|
||||
HttpPost httpPost = new HttpPost(OAUTHUrl + authenticationParameters);
|
||||
httpPost.addHeader("Accept", "application/json");
|
||||
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
HttpResponse getResponse = httpClient.execute(httpPost);
|
||||
|
||||
InputStream is = getResponse.getEntity().getContent();
|
||||
BufferedReader streamReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
|
||||
JSONObject responseObject = null;
|
||||
String inputStr;
|
||||
while ((inputStr = streamReader.readLine()) != null && responseObject == null) {
|
||||
if (inputStr.startsWith("{") && inputStr.endsWith("}") && inputStr.contains("access_token")) {
|
||||
try {
|
||||
responseObject = new JSONObject(inputStr);
|
||||
} catch (Exception e) {
|
||||
//Not as valid as I'd hoped, move along
|
||||
responseObject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (responseObject != null && responseObject.has("access_token")) {
|
||||
accessToken = (String) responseObject.get("access_token");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an instance of the Orcidv2 class based on the provided parameters.
|
||||
* This constructor is called through the spring bean initialization
|
||||
*/
|
||||
private Orcidv2(String url, String OAUTHUrl, String clientId, String clientSecret) {
|
||||
this.restConnector = new RESTConnector(url);
|
||||
this.OAUTHUrl = OAUTHUrl;
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an instance of the Orcidv2 class based on the provided parameters.
|
||||
* This constructor is called through the spring bean initialization
|
||||
*/
|
||||
private Orcidv2(String url) {
|
||||
this.restConnector = new RESTConnector(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an instance of the AuthorityValue with the given information.
|
||||
* @param text search string
|
||||
* @return List<AuthorityValue>
|
||||
*/
|
||||
@Override
|
||||
public List<AuthorityValue> queryAuthorities(String text, int max) {
|
||||
List<Person> bios = queryBio(text, max);
|
||||
List<AuthorityValue> result = new ArrayList<>();
|
||||
for (Person person : bios) {
|
||||
AuthorityValue orcidAuthorityValue = Orcidv2AuthorityValue.create(person);
|
||||
if (orcidAuthorityValue != null) {
|
||||
result.add(orcidAuthorityValue);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AuthorityValue from a Person retrieved using the given orcid identifier.
|
||||
* @param id orcid identifier
|
||||
* @return AuthorityValue
|
||||
*/
|
||||
public AuthorityValue queryAuthorityID(String id) {
|
||||
Person person = getBio(id);
|
||||
AuthorityValue valueFromPerson = Orcidv2AuthorityValue.create(person);
|
||||
return valueFromPerson;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a Person object based on a given orcid identifier
|
||||
* @param id orcid identifier
|
||||
* @return Person
|
||||
*/
|
||||
public Person getBio(String id) {
|
||||
log.debug("getBio called with ID=" + id);
|
||||
if (!isValid(id)) {
|
||||
return null;
|
||||
}
|
||||
InputStream bioDocument = restConnector.get(id + ((id.endsWith("/person")) ? "" : "/person"), accessToken);
|
||||
XMLtoBio converter = new XMLtoBio();
|
||||
Person person = converter.convertSinglePerson(bioDocument);
|
||||
return person;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a list of Person objects.
|
||||
* @param text search string
|
||||
* @param start offset to use
|
||||
* @param rows how many rows to return
|
||||
* @return List<Person>
|
||||
*/
|
||||
public List<Person> queryBio(String text, int start, int rows) {
|
||||
if (rows > 100) {
|
||||
throw new IllegalArgumentException("The maximum number of results to retrieve cannot exceed 100.");
|
||||
}
|
||||
|
||||
String searchPath = "search?q=" + URLEncoder.encode(text) + "&start=" + start + "&rows=" + rows;
|
||||
log.debug("queryBio searchPath=" + searchPath + " accessToken=" + accessToken);
|
||||
InputStream bioDocument = restConnector.get(searchPath, accessToken);
|
||||
XMLtoBio converter = new XMLtoBio();
|
||||
List<Person> bios = converter.convert(bioDocument);
|
||||
return bios;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of Person objects.
|
||||
* @param text search string
|
||||
* @param max how many rows to return
|
||||
* @return List<Person>
|
||||
*/
|
||||
public List<Person> queryBio(String text, int max) {
|
||||
return queryBio(text, 0, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the provided text has the correct ORCID syntax.
|
||||
* Since only searching on ORCID id is allowed, this way, we filter out any queries that would return a
|
||||
* blank result anyway
|
||||
*/
|
||||
private boolean isValid(String text) {
|
||||
return StringUtils.isNotBlank(text) && text.matches(Orcidv2AuthorityValue.ORCID_ID_SYNTAX);
|
||||
}
|
||||
}
|
@@ -0,0 +1,342 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.AuthorityValueServiceImpl;
|
||||
import org.dspace.authority.PersonAuthorityValue;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.orcid.jaxb.model.common_v2.ExternalId;
|
||||
import org.orcid.jaxb.model.record_v2.ExternalIdentifiers;
|
||||
import org.orcid.jaxb.model.record_v2.KeywordType;
|
||||
import org.orcid.jaxb.model.record_v2.NameType;
|
||||
import org.orcid.jaxb.model.record_v2.Person;
|
||||
import org.orcid.jaxb.model.record_v2.ResearcherUrlType;
|
||||
|
||||
/**
|
||||
* @author Jonas Van Goolen (jonas at atmire dot com)
|
||||
*/
|
||||
public class Orcidv2AuthorityValue extends PersonAuthorityValue {
|
||||
|
||||
/*
|
||||
* The ORCID identifier
|
||||
*/
|
||||
private String orcid_id;
|
||||
|
||||
/*
|
||||
* Map containing key-value pairs filled in by "setValues(Person person)".
|
||||
* This represents all dynamic information of the object.
|
||||
*/
|
||||
private Map<String, List<String>> otherMetadata = new HashMap<String, List<String>>();
|
||||
|
||||
/**
|
||||
* The syntax that the ORCID id needs to conform to
|
||||
*/
|
||||
public static final String ORCID_ID_SYNTAX = "\\d{4}-\\d{4}-\\d{4}-(\\d{3}X|\\d{4})";
|
||||
|
||||
|
||||
/**
|
||||
* Creates an instance of Orcidv2AuthorityValue with only uninitialized fields.
|
||||
* This is meant to be filled in with values from an existing record.
|
||||
* To create a brand new Orcidv2AuthorityValue, use create()
|
||||
*/
|
||||
public Orcidv2AuthorityValue() {
|
||||
}
|
||||
|
||||
public Orcidv2AuthorityValue(SolrDocument document) {
|
||||
super(document);
|
||||
}
|
||||
|
||||
|
||||
public String getOrcid_id() {
|
||||
return orcid_id;
|
||||
}
|
||||
|
||||
public void setOrcid_id(String orcid_id) {
|
||||
this.orcid_id = orcid_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty authority.
|
||||
* @return OrcidAuthorityValue
|
||||
*/
|
||||
public static Orcidv2AuthorityValue create() {
|
||||
Orcidv2AuthorityValue orcidAuthorityValue = new Orcidv2AuthorityValue();
|
||||
orcidAuthorityValue.setId(UUID.randomUUID().toString());
|
||||
orcidAuthorityValue.updateLastModifiedDate();
|
||||
orcidAuthorityValue.setCreationDate(new Date());
|
||||
return orcidAuthorityValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an authority based on a given orcid bio
|
||||
* @return OrcidAuthorityValue
|
||||
*/
|
||||
public static Orcidv2AuthorityValue create(Person person) {
|
||||
if (person == null) {
|
||||
return null;
|
||||
}
|
||||
Orcidv2AuthorityValue authority = Orcidv2AuthorityValue.create();
|
||||
|
||||
authority.setValues(person);
|
||||
|
||||
return authority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this instance based on a Person object
|
||||
* @param person Person
|
||||
*/
|
||||
protected void setValues(Person person) {
|
||||
NameType name = person.getName();
|
||||
|
||||
if (!StringUtils.equals(name.getPath(), this.getOrcid_id())) {
|
||||
this.setOrcid_id(name.getPath());
|
||||
}
|
||||
|
||||
if (!StringUtils.equals(name.getFamilyName().getValue(), this.getLastName())) {
|
||||
this.setLastName(name.getFamilyName().getValue());
|
||||
}
|
||||
|
||||
if (!StringUtils.equals(name.getGivenNames().getValue(), this.getFirstName())) {
|
||||
this.setFirstName(name.getGivenNames().getValue());
|
||||
}
|
||||
|
||||
if (name.getCreditName() != null && StringUtils.isNotBlank(name.getCreditName().getValue())) {
|
||||
if (!this.getNameVariants().contains(name.getCreditName().getValue())) {
|
||||
this.addNameVariant(name.getCreditName().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (person.getKeywords() != null) {
|
||||
for (KeywordType keyword : person.getKeywords().getKeyword()) {
|
||||
if (this.isNewMetadata("keyword", keyword.getContent())) {
|
||||
this.addOtherMetadata("keyword", keyword.getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExternalIdentifiers externalIdentifiers = person.getExternalIdentifiers();
|
||||
if (externalIdentifiers != null) {
|
||||
for (ExternalId externalIdentifier : externalIdentifiers.getExternalIdentifier()) {
|
||||
if (this.isNewMetadata("external_identifier", externalIdentifier.getExternalIdValue())) {
|
||||
this.addOtherMetadata("external_identifier", externalIdentifier.getExternalIdValue());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (person.getResearcherUrls() != null) {
|
||||
for (ResearcherUrlType researcherUrl : person.getResearcherUrls().getResearcherUrl()) {
|
||||
if (this.isNewMetadata("researcher_url", researcherUrl.getUrl().getValue())) {
|
||||
this.addOtherMetadata("researcher_url", researcherUrl.getUrl().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (person.getBiography() != null) {
|
||||
if (this.isNewMetadata("biography", person.getBiography().getContent())) {
|
||||
this.addOtherMetadata("biography", person.getBiography().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
this.setValue(this.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an instance of the AuthorityValue with the given information.
|
||||
* @param info string info
|
||||
* @return AuthorityValue
|
||||
*/
|
||||
@Override
|
||||
public AuthorityValue newInstance(String info) {
|
||||
AuthorityValue authorityValue = null;
|
||||
if (StringUtils.isNotBlank(info)) {
|
||||
Orcidv2 orcid = new DSpace().getServiceManager().getServiceByName("AuthoritySource", Orcidv2.class);
|
||||
authorityValue = orcid.queryAuthorityID(info);
|
||||
} else {
|
||||
authorityValue = this.create();
|
||||
}
|
||||
return authorityValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
super.setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the provided label / data pair is already present in the "otherMetadata" or not
|
||||
* */
|
||||
public boolean isNewMetadata(String label, String data) {
|
||||
List<String> strings = getOtherMetadata().get(label);
|
||||
boolean update;
|
||||
if (strings == null) {
|
||||
update = StringUtils.isNotBlank(data);
|
||||
} else {
|
||||
update = !strings.contains(data);
|
||||
}
|
||||
return update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add additional metadata to the otherMetadata map*/
|
||||
public void addOtherMetadata(String label, String data) {
|
||||
List<String> strings = otherMetadata.get(label);
|
||||
if (strings == null) {
|
||||
strings = new ArrayList<>();
|
||||
}
|
||||
strings.add(data);
|
||||
otherMetadata.put(label, strings);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getOtherMetadata() {
|
||||
return otherMetadata;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a solr record from this instance
|
||||
* @return SolrInputDocument
|
||||
*/
|
||||
@Override
|
||||
public SolrInputDocument getSolrInputDocument() {
|
||||
SolrInputDocument doc = super.getSolrInputDocument();
|
||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||
doc.addField("orcid_id", getOrcid_id());
|
||||
}
|
||||
|
||||
for (String t : otherMetadata.keySet()) {
|
||||
List<String> data = otherMetadata.get(t);
|
||||
for (String data_entry : data) {
|
||||
doc.addField("label_" + t, data_entry);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information that can be used the choice ui
|
||||
* @return map
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> choiceSelectMap() {
|
||||
|
||||
Map<String, String> map = super.choiceSelectMap();
|
||||
|
||||
String orcid_id = getOrcid_id();
|
||||
if (StringUtils.isNotBlank(orcid_id)) {
|
||||
map.put("orcid", orcid_id);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorityType() {
|
||||
return "orcid";
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string that will allow this AuthorityType to be recognized and provides information to create a new
|
||||
* instance to be created using public Orcidv2AuthorityValue newInstance(String info).
|
||||
* @return see {@link org.dspace.authority.service.AuthorityValueService#GENERATE AuthorityValueService.GENERATE}
|
||||
*/
|
||||
@Override
|
||||
public String generateString() {
|
||||
String generateString = AuthorityValueServiceImpl.GENERATE + getAuthorityType() +
|
||||
AuthorityValueServiceImpl.SPLIT;
|
||||
if (StringUtils.isNotBlank(getOrcid_id())) {
|
||||
generateString += getOrcid_id();
|
||||
}
|
||||
return generateString;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Orcidv2AuthorityValue that = (Orcidv2AuthorityValue) o;
|
||||
|
||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return orcid_id != null ? orcid_id.hashCode() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The regular equals() only checks if both AuthorityValues describe the same authority.
|
||||
* This method checks if the AuthorityValues have different information
|
||||
* E.g. it is used to decide when lastModified should be updated.
|
||||
* @param o object
|
||||
* @return true or false
|
||||
*/
|
||||
@Override
|
||||
public boolean hasTheSameInformationAs(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
if (!super.hasTheSameInformationAs(o)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Orcidv2AuthorityValue that = (Orcidv2AuthorityValue) o;
|
||||
|
||||
if (orcid_id != null ? !orcid_id.equals(that.orcid_id) : that.orcid_id != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String key : otherMetadata.keySet()) {
|
||||
if (otherMetadata.get(key) != null) {
|
||||
List<String> metadata = otherMetadata.get(key);
|
||||
List<String> otherMetadata = that.otherMetadata.get(key);
|
||||
if (otherMetadata == null) {
|
||||
return false;
|
||||
} else {
|
||||
HashSet<String> metadataSet = new HashSet<String>(metadata);
|
||||
HashSet<String> otherMetadataSet = new HashSet<String>(otherMetadata);
|
||||
if (!metadataSet.equals(otherMetadataSet)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (that.otherMetadata.get(key) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class Bio {
|
||||
|
||||
protected String orcid;
|
||||
|
||||
protected BioName name;
|
||||
|
||||
protected String country;
|
||||
|
||||
protected Set<String> keywords;
|
||||
|
||||
protected Set<BioExternalIdentifier> bioExternalIdentifiers;
|
||||
|
||||
protected Set<BioResearcherUrl> researcherUrls;
|
||||
|
||||
protected String biography;
|
||||
|
||||
public Bio() {
|
||||
this.name = new BioName();
|
||||
keywords = new LinkedHashSet<String>();
|
||||
bioExternalIdentifiers = new LinkedHashSet<BioExternalIdentifier>();
|
||||
researcherUrls = new LinkedHashSet<BioResearcherUrl>();
|
||||
}
|
||||
|
||||
public String getOrcid() {
|
||||
return orcid;
|
||||
}
|
||||
|
||||
public void setOrcid(String orcid) {
|
||||
this.orcid = orcid;
|
||||
}
|
||||
|
||||
public BioName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(BioName name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Set<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void addKeyword(String keyword) {
|
||||
this.keywords.add(keyword);
|
||||
}
|
||||
|
||||
public Set<BioExternalIdentifier> getBioExternalIdentifiers() {
|
||||
return bioExternalIdentifiers;
|
||||
}
|
||||
|
||||
public void addExternalIdentifier(BioExternalIdentifier externalReference) {
|
||||
bioExternalIdentifiers.add(externalReference);
|
||||
}
|
||||
|
||||
public Set<BioResearcherUrl> getResearcherUrls() {
|
||||
return researcherUrls;
|
||||
}
|
||||
|
||||
public void addResearcherUrl(BioResearcherUrl researcherUrl) {
|
||||
researcherUrls.add(researcherUrl);
|
||||
}
|
||||
|
||||
public String getBiography() {
|
||||
return biography;
|
||||
}
|
||||
|
||||
public void setBiography(String biography) {
|
||||
this.biography = biography;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Bio{" +
|
||||
"orcid='" + orcid + '\'' +
|
||||
", name=" + name +
|
||||
", country='" + country + '\'' +
|
||||
", keywords=" + keywords +
|
||||
", bioExternalIdentifiers=" + bioExternalIdentifiers +
|
||||
", researcherUrls=" + researcherUrls +
|
||||
", biography='" + biography + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class BioExternalIdentifier {
|
||||
|
||||
|
||||
protected String id_orcid;
|
||||
protected String id_common_name;
|
||||
protected String id_reference;
|
||||
protected String id_url;
|
||||
|
||||
public BioExternalIdentifier(String id_orcid, String id_common_name, String id_reference, String id_url) {
|
||||
this.id_orcid = id_orcid;
|
||||
this.id_common_name = id_common_name;
|
||||
this.id_reference = id_reference;
|
||||
this.id_url = id_url;
|
||||
}
|
||||
|
||||
public String getId_orcid() {
|
||||
return id_orcid;
|
||||
}
|
||||
|
||||
public void setId_orcid(String id_orcid) {
|
||||
this.id_orcid = id_orcid;
|
||||
}
|
||||
|
||||
public String getId_common_name() {
|
||||
return id_common_name;
|
||||
}
|
||||
|
||||
public void setId_common_name(String id_common_name) {
|
||||
this.id_common_name = id_common_name;
|
||||
}
|
||||
|
||||
public String getId_reference() {
|
||||
return id_reference;
|
||||
}
|
||||
|
||||
public void setId_reference(String id_reference) {
|
||||
this.id_reference = id_reference;
|
||||
}
|
||||
|
||||
public String getId_url() {
|
||||
return id_url;
|
||||
}
|
||||
|
||||
public void setId_url(String id_url) {
|
||||
this.id_url = id_url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BioExternalIdentifier{" +
|
||||
"id_orcid='" + id_orcid + '\'' +
|
||||
", id_common_name='" + id_common_name + '\'' +
|
||||
", id_reference='" + id_reference + '\'' +
|
||||
", id_url='" + id_url + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BioExternalIdentifier that = (BioExternalIdentifier) o;
|
||||
|
||||
if (id_common_name != null ? !id_common_name.equals(that.id_common_name) : that.id_common_name != null) {
|
||||
return false;
|
||||
}
|
||||
if (id_orcid != null ? !id_orcid.equals(that.id_orcid) : that.id_orcid != null) {
|
||||
return false;
|
||||
}
|
||||
if (id_reference != null ? !id_reference.equals(that.id_reference) : that.id_reference != null) {
|
||||
return false;
|
||||
}
|
||||
if (id_url != null ? !id_url.equals(that.id_url) : that.id_url != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id_orcid != null ? id_orcid.hashCode() : 0;
|
||||
result = 31 * result + (id_common_name != null ? id_common_name.hashCode() : 0);
|
||||
result = 31 * result + (id_reference != null ? id_reference.hashCode() : 0);
|
||||
result = 31 * result + (id_url != null ? id_url.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class BioName {
|
||||
|
||||
protected String givenNames;
|
||||
protected String familyName;
|
||||
protected String creditName;
|
||||
protected List<String> otherNames;
|
||||
|
||||
BioName() {
|
||||
otherNames = new ArrayList<String>();
|
||||
}
|
||||
|
||||
BioName(String givenNames, String familyName, String creditName, List<String> otherNames) {
|
||||
this.givenNames = givenNames;
|
||||
this.familyName = familyName;
|
||||
this.creditName = creditName;
|
||||
this.otherNames = otherNames;
|
||||
}
|
||||
|
||||
public String getGivenNames() {
|
||||
return givenNames;
|
||||
}
|
||||
|
||||
public void setGivenNames(String givenNames) {
|
||||
this.givenNames = givenNames;
|
||||
}
|
||||
|
||||
public String getFamilyName() {
|
||||
return familyName;
|
||||
}
|
||||
|
||||
public void setFamilyName(String familyName) {
|
||||
this.familyName = familyName;
|
||||
}
|
||||
|
||||
public String getCreditName() {
|
||||
return creditName;
|
||||
}
|
||||
|
||||
public void setCreditName(String creditName) {
|
||||
this.creditName = creditName;
|
||||
}
|
||||
|
||||
public List<String> getOtherNames() {
|
||||
return otherNames;
|
||||
}
|
||||
|
||||
public void setOtherNames(List<String> otherNames) {
|
||||
this.otherNames = otherNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BioName{" +
|
||||
"givenNames='" + givenNames + '\'' +
|
||||
", familyName='" + familyName + '\'' +
|
||||
", creditName='" + creditName + '\'' +
|
||||
", otherNames=" + otherNames +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BioName bioName = (BioName) o;
|
||||
|
||||
if (creditName != null ? !creditName.equals(bioName.creditName) : bioName.creditName != null) {
|
||||
return false;
|
||||
}
|
||||
if (familyName != null ? !familyName.equals(bioName.familyName) : bioName.familyName != null) {
|
||||
return false;
|
||||
}
|
||||
if (givenNames != null ? !givenNames.equals(bioName.givenNames) : bioName.givenNames != null) {
|
||||
return false;
|
||||
}
|
||||
if (otherNames != null ? !otherNames.equals(bioName.otherNames) : bioName.otherNames != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = givenNames != null ? givenNames.hashCode() : 0;
|
||||
result = 31 * result + (familyName != null ? familyName.hashCode() : 0);
|
||||
result = 31 * result + (creditName != null ? creditName.hashCode() : 0);
|
||||
result = 31 * result + (otherNames != null ? otherNames.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class BioResearcherUrl {
|
||||
|
||||
protected String name;
|
||||
protected String url;
|
||||
|
||||
public BioResearcherUrl(String name, String url) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BioResearcherUrl{" +
|
||||
"name='" + name + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BioResearcherUrl that = (BioResearcherUrl) o;
|
||||
|
||||
if (name != null ? !name.equals(that.name) : that.name != null) {
|
||||
return false;
|
||||
}
|
||||
if (url != null ? !url.equals(that.url) : that.url != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = name != null ? name.hashCode() : 0;
|
||||
result = 31 * result + (url != null ? url.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class Citation {
|
||||
|
||||
private CitationType type;
|
||||
private String citation;
|
||||
|
||||
public Citation(CitationType type, String citation) {
|
||||
this.type = type;
|
||||
this.citation = citation;
|
||||
}
|
||||
|
||||
public CitationType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(CitationType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCitation() {
|
||||
return citation;
|
||||
}
|
||||
|
||||
public void setCitation(String citation) {
|
||||
this.citation = citation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Citation{" +
|
||||
"type=" + type +
|
||||
", citation='" + citation + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public enum CitationType {
|
||||
|
||||
FORMATTED_UNSPECIFIED,
|
||||
BIBTEX,
|
||||
FORMATTED_APA,
|
||||
FORMATTED_HARVARD,
|
||||
FORMATTED_IEEE,
|
||||
FORMATTED_MLA,
|
||||
FORMATTED_VANCOUVER,
|
||||
FORMATTED_CHICAGO
|
||||
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class Contributor {
|
||||
|
||||
private String orcid;
|
||||
private String creditName;
|
||||
private String email;
|
||||
private Set<ContributorAttribute> contributorAttributes;
|
||||
|
||||
public Contributor(String orcid, String creditName, String email, Set<ContributorAttribute> contributorAttributes) {
|
||||
this.orcid = orcid;
|
||||
this.creditName = creditName;
|
||||
this.email = email;
|
||||
this.contributorAttributes = contributorAttributes;
|
||||
}
|
||||
|
||||
public String getOrcid() {
|
||||
return orcid;
|
||||
}
|
||||
|
||||
public void setOrcid(String orcid) {
|
||||
this.orcid = orcid;
|
||||
}
|
||||
|
||||
public String getCreditName() {
|
||||
return creditName;
|
||||
}
|
||||
|
||||
public void setCreditName(String creditName) {
|
||||
this.creditName = creditName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Set<ContributorAttribute> getContributorAttributes() {
|
||||
return contributorAttributes;
|
||||
}
|
||||
|
||||
public void setContributorAttributes(Set<ContributorAttribute> contributorAttributes) {
|
||||
this.contributorAttributes = contributorAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Contributor{" +
|
||||
"orcid='" + orcid + '\'' +
|
||||
", creditName='" + creditName + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", contributorAttributes=" + contributorAttributes +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Contributor that = (Contributor) o;
|
||||
|
||||
if (contributorAttributes != null ? !contributorAttributes
|
||||
.equals(that.contributorAttributes) : that.contributorAttributes != null) {
|
||||
return false;
|
||||
}
|
||||
if (creditName != null ? !creditName.equals(that.creditName) : that.creditName != null) {
|
||||
return false;
|
||||
}
|
||||
if (email != null ? !email.equals(that.email) : that.email != null) {
|
||||
return false;
|
||||
}
|
||||
if (orcid != null ? !orcid.equals(that.orcid) : that.orcid != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = orcid != null ? orcid.hashCode() : 0;
|
||||
result = 31 * result + (creditName != null ? creditName.hashCode() : 0);
|
||||
result = 31 * result + (email != null ? email.hashCode() : 0);
|
||||
result = 31 * result + (contributorAttributes != null ? contributorAttributes.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class ContributorAttribute {
|
||||
|
||||
private ContributorAttributeRole role;
|
||||
private ContributorAttributeSequence sequence;
|
||||
|
||||
public ContributorAttribute(ContributorAttributeRole role, ContributorAttributeSequence sequence) {
|
||||
this.role = role;
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
public ContributorAttributeRole getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(ContributorAttributeRole role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public ContributorAttributeSequence getSequence() {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
public void setSequence(ContributorAttributeSequence sequence) {
|
||||
this.sequence = sequence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ContributorAttribute{" +
|
||||
"role=" + role +
|
||||
", sequence=" + sequence +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContributorAttribute that = (ContributorAttribute) o;
|
||||
|
||||
if (role != that.role) {
|
||||
return false;
|
||||
}
|
||||
if (sequence != that.sequence) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = role != null ? role.hashCode() : 0;
|
||||
result = 31 * result + (sequence != null ? sequence.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118843-anatomy-of-a-contributor
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public enum ContributorAttributeRole {
|
||||
|
||||
AUTHOR,
|
||||
ASSIGNEE,
|
||||
EDITOR,
|
||||
CHAIR_OR_TRANSLATOR,
|
||||
CO_INVESTIGATOR,
|
||||
CO_INVENTOR,
|
||||
GRADUATE_STUDENT,
|
||||
OTHER_INVENTOR,
|
||||
PRINCIPAL_INVESTIGATOR,
|
||||
POSTDOCTORAL_RESEARCHER,
|
||||
SUPPORT_STAFF
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118843-anatomy-of-a-contributor
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public enum ContributorAttributeSequence {
|
||||
|
||||
FIRST,
|
||||
ADDITIONAL
|
||||
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class Work {
|
||||
|
||||
private WorkTitle workTitle;
|
||||
private String description;
|
||||
private Citation citation;
|
||||
private WorkType workType;
|
||||
private String publicationDate;
|
||||
private WorkExternalIdentifier workExternalIdentifier;
|
||||
private String url;
|
||||
private Set<Contributor> contributors;
|
||||
private String workSource;
|
||||
|
||||
public WorkTitle getWorkTitle() {
|
||||
return workTitle;
|
||||
}
|
||||
|
||||
public void setWorkTitle(WorkTitle workTitle) {
|
||||
this.workTitle = workTitle;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Citation getCitation() {
|
||||
return citation;
|
||||
}
|
||||
|
||||
public void setCitation(Citation citation) {
|
||||
this.citation = citation;
|
||||
}
|
||||
|
||||
public WorkType getWorkType() {
|
||||
return workType;
|
||||
}
|
||||
|
||||
public void setWorkType(WorkType workType) {
|
||||
this.workType = workType;
|
||||
}
|
||||
|
||||
public String getPublicationDate() {
|
||||
return publicationDate;
|
||||
}
|
||||
|
||||
public void setPublicationDate(String publicationDate) {
|
||||
this.publicationDate = publicationDate;
|
||||
}
|
||||
|
||||
public WorkExternalIdentifier getWorkExternalIdentifier() {
|
||||
return workExternalIdentifier;
|
||||
}
|
||||
|
||||
public void setWorkExternalIdentifier(WorkExternalIdentifier workExternalIdentifier) {
|
||||
this.workExternalIdentifier = workExternalIdentifier;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Set<Contributor> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
public void setContributors(Set<Contributor> contributors) {
|
||||
this.contributors = contributors;
|
||||
}
|
||||
|
||||
public String getWorkSource() {
|
||||
return workSource;
|
||||
}
|
||||
|
||||
public void setWorkSource(String workSource) {
|
||||
this.workSource = workSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Work{" +
|
||||
"workTitle=" + workTitle +
|
||||
", description='" + description + '\'' +
|
||||
", citation=" + citation +
|
||||
", workType=" + workType +
|
||||
", publicationDate='" + publicationDate + '\'' +
|
||||
", workExternalIdentifier=" + workExternalIdentifier +
|
||||
", url='" + url + '\'' +
|
||||
", contributors=" + contributors +
|
||||
", workSource='" + workSource + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118807
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class WorkExternalIdentifier {
|
||||
|
||||
private WorkExternalIdentifierType workExternalIdentifierType;
|
||||
private String workExternalIdenfitierID;
|
||||
|
||||
public WorkExternalIdentifier(WorkExternalIdentifierType workExternalIdentifierType,
|
||||
String workExternalIdenfitierID) {
|
||||
this.workExternalIdentifierType = workExternalIdentifierType;
|
||||
this.workExternalIdenfitierID = workExternalIdenfitierID;
|
||||
}
|
||||
|
||||
public WorkExternalIdentifierType getWorkExternalIdentifierType() {
|
||||
return workExternalIdentifierType;
|
||||
}
|
||||
|
||||
public void setWorkExternalIdentifierType(WorkExternalIdentifierType workExternalIdentifierType) {
|
||||
this.workExternalIdentifierType = workExternalIdentifierType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkExternalIdentifier{" +
|
||||
"workExternalIdentifierType=" + workExternalIdentifierType +
|
||||
", workExternalIdenfitierID='" + workExternalIdenfitierID + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WorkExternalIdentifier that = (WorkExternalIdentifier) o;
|
||||
|
||||
if (workExternalIdenfitierID != null ? !workExternalIdenfitierID
|
||||
.equals(that.workExternalIdenfitierID) : that.workExternalIdenfitierID != null) {
|
||||
return false;
|
||||
}
|
||||
if (workExternalIdentifierType != that.workExternalIdentifierType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = workExternalIdentifierType != null ? workExternalIdentifierType.hashCode() : 0;
|
||||
result = 31 * result + (workExternalIdenfitierID != null ? workExternalIdenfitierID.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118807
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public enum WorkExternalIdentifierType {
|
||||
|
||||
// OTHER_ID,
|
||||
ARXIV,
|
||||
ASIN,
|
||||
ASIN_TLD,
|
||||
BIBCODE,
|
||||
DOI,
|
||||
EID,
|
||||
ISBN,
|
||||
ISSN,
|
||||
JFM,
|
||||
JSTOR,
|
||||
LCCN,
|
||||
MR,
|
||||
OCLC,
|
||||
OL,
|
||||
OSTI,
|
||||
PMC,
|
||||
PMID,
|
||||
RFC,
|
||||
SSRN,
|
||||
ZBL
|
||||
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118807
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class WorkTitle {
|
||||
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private Map<String, String> translatedTitles;
|
||||
|
||||
public WorkTitle(String title, String subtitle, Map<String, String> translatedTitles) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.translatedTitles = translatedTitles;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
public String getTranslatedTitles(String languageCode) {
|
||||
return translatedTitles.get(languageCode);
|
||||
}
|
||||
|
||||
public void setTranslatedTitle(String languageCode, String translatedTitle) {
|
||||
translatedTitles.put(languageCode, translatedTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WorkTitle{" +
|
||||
"title='" + title + '\'' +
|
||||
", subtitle='" + subtitle + '\'' +
|
||||
", translatedTitles=" + translatedTitles +
|
||||
'}';
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.model;
|
||||
|
||||
/**
|
||||
* http://support.orcid.org/knowledgebase/articles/118795
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public enum WorkType {
|
||||
|
||||
BOOK,
|
||||
BOOK_CHAPTER,
|
||||
BOOK_REVIEW,
|
||||
DICTIONARY_ENTRY,
|
||||
DISSERTATION,
|
||||
ENCYCLOPEDIA_ARTICLE,
|
||||
EDITED_BOOK,
|
||||
JOURNAL_ARTICLE,
|
||||
JOURNAL_ISSUE,
|
||||
MAGAZINE_ARTICLE,
|
||||
MANUAL,
|
||||
ONLINE_RESOURCE,
|
||||
NEWSLETTER_ARTICLE,
|
||||
NEWSPAPER_ARTICLE,
|
||||
REPORT,
|
||||
RESEARCH_TOOL,
|
||||
SUPERVISED_STUDENT_PUBLICATION,
|
||||
TEST,
|
||||
TRANSLATION,
|
||||
WEBSITE,
|
||||
CONFERENCE_ABSTRACT,
|
||||
CONFERENCE_PAPER,
|
||||
CONFERENCE_POSTER,
|
||||
DISCLOSURE,
|
||||
LICENSE,
|
||||
PATENT,
|
||||
REGISTERED_COPYRIGHT,
|
||||
ARTISTIC_PERFORMANCE,
|
||||
DATA_SET,
|
||||
INVENTION,
|
||||
LECTURE_SPEECH,
|
||||
RESEARCH_TECHNIQUE,
|
||||
SPIN_OFF_COMPANY,
|
||||
STANDARDS_AND_POLICY,
|
||||
TECHNICAL_STANDARD,
|
||||
OTHER
|
||||
|
||||
}
|
@@ -7,8 +7,16 @@
|
||||
*/
|
||||
package org.dspace.authority.orcid.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
/**
|
||||
* @param <T> type
|
||||
@@ -24,11 +32,15 @@ public abstract class Converter<T> {
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(Converter.class);
|
||||
|
||||
public abstract T convert(InputStream document);
|
||||
|
||||
protected void processError(Document xml) {
|
||||
String errorMessage = XMLErrors.getErrorMessage(xml);
|
||||
log.error("The orcid-message reports an error: " + errorMessage);
|
||||
protected Object unmarshall(InputStream input, Class<?> type) throws SAXException, URISyntaxException {
|
||||
try {
|
||||
JAXBContext context = JAXBContext.newInstance(type);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
return unmarshaller.unmarshal(input);
|
||||
} catch (JAXBException e) {
|
||||
throw new RuntimeException("Unable to unmarshall orcid message" + e);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T convert(Document document);
|
||||
}
|
||||
|
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.xml;
|
||||
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class XMLErrors {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(XMLErrors.class);
|
||||
|
||||
private static final String ERROR_DESC = "/orcid-message/error-desc";
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
private XMLErrors() { }
|
||||
|
||||
/**
|
||||
* Evaluates whether a given xml document contains errors or not.
|
||||
*
|
||||
* @param xml The given xml document
|
||||
* @return true if the given xml document is null
|
||||
* or if it contains errors
|
||||
*/
|
||||
public static boolean check(Document xml) {
|
||||
|
||||
if (xml == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String textContent = null;
|
||||
|
||||
try {
|
||||
textContent = XMLUtils.getTextContent(xml, ERROR_DESC);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error while checking for errors in orcid message", e);
|
||||
}
|
||||
|
||||
return textContent == null;
|
||||
}
|
||||
|
||||
public static String getErrorMessage(Document xml) {
|
||||
|
||||
if (xml == null) {
|
||||
return "Did not receive an XML document.";
|
||||
}
|
||||
|
||||
String textContent = null;
|
||||
|
||||
try {
|
||||
textContent = XMLUtils.getTextContent(xml, ERROR_DESC);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error while checking for errors in orcid message", e);
|
||||
}
|
||||
|
||||
return textContent;
|
||||
}
|
||||
|
||||
}
|
@@ -7,20 +7,21 @@
|
||||
*/
|
||||
package org.dspace.authority.orcid.xml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.orcid.model.Bio;
|
||||
import org.dspace.authority.orcid.model.BioExternalIdentifier;
|
||||
import org.dspace.authority.orcid.model.BioName;
|
||||
import org.dspace.authority.orcid.model.BioResearcherUrl;
|
||||
import org.dspace.authority.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.dspace.authority.orcid.Orcidv2;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.orcid.jaxb.model.common_v2.OrcidId;
|
||||
import org.orcid.jaxb.model.record_v2.Person;
|
||||
import org.orcid.jaxb.model.search_v2.Result;
|
||||
import org.orcid.jaxb.model.search_v2.Search;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
@@ -35,218 +36,38 @@ public class XMLtoBio extends Converter {
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(XMLtoBio.class);
|
||||
|
||||
/**
|
||||
* orcid-message XPATHs
|
||||
*/
|
||||
|
||||
protected String ORCID_BIO = "//orcid-bio";
|
||||
|
||||
// protected String ORCID = "parent::*/orcid";
|
||||
protected String ORCID = "parent::*/orcid-identifier/path";
|
||||
|
||||
protected String PERSONAL_DETAILS = "personal-details";
|
||||
protected String GIVEN_NAMES = PERSONAL_DETAILS + "/given-names";
|
||||
protected String FAMILY_NAME = PERSONAL_DETAILS + "/family-name";
|
||||
protected String CREDIT_NAME = PERSONAL_DETAILS + "/credit-name";
|
||||
protected String OTHER_NAMES = PERSONAL_DETAILS + "/other-names";
|
||||
protected String OTHER_NAME = OTHER_NAMES + "/other-name";
|
||||
|
||||
protected String CONTACT_DETAILS = "contact-details";
|
||||
protected String COUNTRY = CONTACT_DETAILS + "/address/country";
|
||||
|
||||
protected String KEYWORDS = "keywords";
|
||||
protected String KEYWORD = KEYWORDS + "/keyword";
|
||||
|
||||
protected String EXTERNAL_IDENTIFIERS = "external-identifiers";
|
||||
protected String EXTERNAL_IDENTIFIER = EXTERNAL_IDENTIFIERS + "/external-identifier";
|
||||
protected String EXTERNAL_ID_ORCID = "external-id-orcid";
|
||||
protected String EXTERNAL_ID_COMMNON_NAME = "external-id-common-name";
|
||||
protected String EXTERNAL_ID_REFERENCE = "external-id-reference";
|
||||
protected String EXTERNAL_ID_URL = "external-id-url";
|
||||
|
||||
protected String RESEARCHER_URLS = "researcher-urls";
|
||||
protected String RESEARCHER_URL = "researcher-urls/researcher-url";
|
||||
protected String URL_NAME = "url-name";
|
||||
protected String URL = "url";
|
||||
|
||||
protected String BIOGRAPHY = ORCID_BIO + "/biography";
|
||||
|
||||
protected String AFFILIATIONS = ORCID_BIO + "/affiliation";
|
||||
|
||||
/**
|
||||
* Regex
|
||||
*/
|
||||
|
||||
protected String ORCID_NOT_FOUND = "ORCID [\\d-]* not found";
|
||||
|
||||
|
||||
@Override
|
||||
public List<Bio> convert(Document xml) {
|
||||
List<Bio> result = new ArrayList<Bio>();
|
||||
|
||||
if (XMLErrors.check(xml)) {
|
||||
|
||||
public List<Person> convert(InputStream xml) {
|
||||
List<Person> bios = new ArrayList<>();
|
||||
try {
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(xml, ORCID_BIO);
|
||||
while (iterator.hasNext()) {
|
||||
Bio bio = convertBio(iterator.next());
|
||||
result.add(bio);
|
||||
Orcidv2 connector = new DSpace().getServiceManager().getServiceByName("AuthoritySource", Orcidv2.class);
|
||||
|
||||
Search search = (Search) unmarshall(xml, Search.class);
|
||||
for (Result result : search.getResult()) {
|
||||
OrcidId orcidIdentifier = result.getOrcidIdentifier();
|
||||
if (orcidIdentifier != null) {
|
||||
log.debug("Found OrcidId=" + orcidIdentifier.toString());
|
||||
String orcid = orcidIdentifier.getUriPath();
|
||||
Person bio = connector.getBio(orcid);
|
||||
if (bio != null) {
|
||||
bios.add(bio);
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in xpath syntax", e);
|
||||
}
|
||||
} else {
|
||||
processError(xml);
|
||||
}
|
||||
} catch (SAXException | URISyntaxException e) {
|
||||
log.error(e);
|
||||
}
|
||||
return bios;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Bio convertBio(Node node) {
|
||||
Bio bio = new Bio();
|
||||
|
||||
setOrcid(node, bio);
|
||||
setPersonalDetails(node, bio);
|
||||
setContactDetails(node, bio);
|
||||
setKeywords(node, bio);
|
||||
setExternalIdentifiers(node, bio);
|
||||
setResearcherUrls(node, bio);
|
||||
setBiography(node, bio);
|
||||
|
||||
return bio;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processError(Document xml) {
|
||||
String errorMessage = XMLErrors.getErrorMessage(xml);
|
||||
|
||||
if (errorMessage.matches(ORCID_NOT_FOUND)) {
|
||||
// do something?
|
||||
}
|
||||
|
||||
log.error("The orcid-message reports an error: " + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
private void setOrcid(Node node, Bio bio) {
|
||||
public Person convertSinglePerson(InputStream xml) {
|
||||
Person person = null;
|
||||
try {
|
||||
String orcid = XMLUtils.getTextContent(node, ORCID);
|
||||
bio.setOrcid(orcid);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.debug("Error in finding the biography in bio xml.", e);
|
||||
person = (Person) unmarshall(xml, Person.class);
|
||||
return person;
|
||||
} catch (SAXException | URISyntaxException e) {
|
||||
log.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void setBiography(Node xml, Bio bio) {
|
||||
try {
|
||||
String biography = XMLUtils.getTextContent(xml, BIOGRAPHY);
|
||||
bio.setBiography(biography);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the biography in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setResearcherUrls(Node xml, Bio bio) {
|
||||
try {
|
||||
NodeList researcher_urls = XMLUtils.getNodeList(xml, RESEARCHER_URL);
|
||||
if (researcher_urls != null) {
|
||||
for (int i = 0; i < researcher_urls.getLength(); i++) {
|
||||
Node researcher_url = researcher_urls.item(i);
|
||||
if (researcher_url.getNodeType() != Node.TEXT_NODE) {
|
||||
String url_name = XMLUtils.getTextContent(researcher_url, URL_NAME);
|
||||
String url = XMLUtils.getTextContent(researcher_url, URL);
|
||||
BioResearcherUrl researcherUrl = new BioResearcherUrl(url_name, url);
|
||||
bio.addResearcherUrl(researcherUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the researcher url in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setExternalIdentifiers(Node xml, Bio bio) {
|
||||
try {
|
||||
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(xml, EXTERNAL_IDENTIFIER);
|
||||
while (iterator.hasNext()) {
|
||||
Node external_identifier = iterator.next();
|
||||
String id_orcid = XMLUtils.getTextContent(external_identifier, EXTERNAL_ID_ORCID);
|
||||
String id_common_name = XMLUtils.getTextContent(external_identifier, EXTERNAL_ID_COMMNON_NAME);
|
||||
String id_reference = XMLUtils.getTextContent(external_identifier, EXTERNAL_ID_REFERENCE);
|
||||
String id_url = XMLUtils.getTextContent(external_identifier, EXTERNAL_ID_URL);
|
||||
BioExternalIdentifier externalIdentifier = new BioExternalIdentifier(id_orcid, id_common_name,
|
||||
id_reference, id_url);
|
||||
bio.addExternalIdentifier(externalIdentifier);
|
||||
}
|
||||
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the external identifier in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setKeywords(Node xml, Bio bio) {
|
||||
try {
|
||||
NodeList keywords = XMLUtils.getNodeList(xml, KEYWORD);
|
||||
if (keywords != null) {
|
||||
for (int i = 0; i < keywords.getLength(); i++) {
|
||||
String keyword = keywords.item(i).getTextContent();
|
||||
String[] split = keyword.split(",");
|
||||
for (String k : split) {
|
||||
bio.addKeyword(k.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the keywords in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setContactDetails(Node xml, Bio bio) {
|
||||
try {
|
||||
String country = XMLUtils.getTextContent(xml, COUNTRY);
|
||||
bio.setCountry(country);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the country in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setPersonalDetails(Node xml, Bio bio) {
|
||||
BioName name = bio.getName();
|
||||
|
||||
try {
|
||||
String givenNames = XMLUtils.getTextContent(xml, GIVEN_NAMES);
|
||||
name.setGivenNames(givenNames);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the given names in bio xml.", e);
|
||||
}
|
||||
|
||||
try {
|
||||
String familyName = XMLUtils.getTextContent(xml, FAMILY_NAME);
|
||||
name.setFamilyName(familyName);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the family name in bio xml.", e);
|
||||
}
|
||||
|
||||
try {
|
||||
String creditName = XMLUtils.getTextContent(xml, CREDIT_NAME);
|
||||
name.setCreditName(creditName);
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the credit name in bio xml.", e);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(xml, OTHER_NAME);
|
||||
while (iterator.hasNext()) {
|
||||
Node otherName = iterator.next();
|
||||
String textContent = otherName.getTextContent();
|
||||
name.getOtherNames().add(textContent.trim());
|
||||
}
|
||||
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in finding the other names in bio xml.", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,257 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.authority.orcid.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.orcid.model.Citation;
|
||||
import org.dspace.authority.orcid.model.CitationType;
|
||||
import org.dspace.authority.orcid.model.Contributor;
|
||||
import org.dspace.authority.orcid.model.ContributorAttribute;
|
||||
import org.dspace.authority.orcid.model.ContributorAttributeRole;
|
||||
import org.dspace.authority.orcid.model.ContributorAttributeSequence;
|
||||
import org.dspace.authority.orcid.model.Work;
|
||||
import org.dspace.authority.orcid.model.WorkExternalIdentifier;
|
||||
import org.dspace.authority.orcid.model.WorkExternalIdentifierType;
|
||||
import org.dspace.authority.orcid.model.WorkTitle;
|
||||
import org.dspace.authority.orcid.model.WorkType;
|
||||
import org.dspace.authority.util.EnumUtils;
|
||||
import org.dspace.authority.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public class XMLtoWork extends Converter {
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = Logger.getLogger(XMLtoWork.class);
|
||||
|
||||
/**
|
||||
* orcid-message XPATHs
|
||||
*/
|
||||
|
||||
protected String ORCID_WORKS = "//orcid-works";
|
||||
protected String ORCID_WORK = ORCID_WORKS + "/orcid-work";
|
||||
|
||||
protected String WORK_TITLE = "work-title";
|
||||
protected String TITLE = WORK_TITLE + "/title";
|
||||
protected String SUBTITLE = WORK_TITLE + "/subtitle";
|
||||
protected String TRANSLATED_TITLES = WORK_TITLE + "/translated-title";
|
||||
protected String TRANSLATED_TITLES_LANGUAGE = "@language-code";
|
||||
|
||||
protected String SHORT_DESCRIPTION = "short-description";
|
||||
|
||||
protected String WORK_CITATION = "work-citation";
|
||||
protected String CITATION_TYPE = WORK_CITATION + "/work-citation-type";
|
||||
protected String CITATION = WORK_CITATION + "/citation";
|
||||
|
||||
protected String WORK_TYPE = "work-type";
|
||||
|
||||
protected String PUBLICATION_DATE = "publication-date";
|
||||
protected String YEAR = PUBLICATION_DATE + "/year";
|
||||
protected String MONTH = PUBLICATION_DATE + "/month";
|
||||
protected String DAY = PUBLICATION_DATE + "/day";
|
||||
|
||||
protected String WORK_EXTERNAL_IDENTIFIERS = "work-external-identifiers";
|
||||
protected String WORK_EXTERNAL_IDENTIFIER = WORK_EXTERNAL_IDENTIFIERS + "/work-external-identifier";
|
||||
protected String WORK_EXTERNAL_IDENTIFIER_TYPE = "work-external-identifier-type";
|
||||
protected String WORK_EXTERNAL_IDENTIFIER_ID = "work-external-identifier-id";
|
||||
|
||||
protected String URL = "url";
|
||||
|
||||
protected String WORK_CONTRIBUTOR = "work-contributors";
|
||||
protected String CONTRIBUTOR = WORK_CONTRIBUTOR + "/contributor";
|
||||
protected String CONTRIBUTOR_ORCID = "contributor-orcid";
|
||||
protected String CREDIT_NAME = "credit-name";
|
||||
protected String CONTRIBUTOR_EMAIL = "contributor-email";
|
||||
protected String CONTRIBUTOR_ATTRIBUTES = "contributor-attributes";
|
||||
protected String CONTRIBUTOR_SEQUENCE = "contributor-sequence";
|
||||
protected String CONTRIBUTOR_ROLE = "contributor-role";
|
||||
|
||||
protected String WORK_SOURCE = "work-source";
|
||||
|
||||
|
||||
@Override
|
||||
public List<Work> convert(Document document) {
|
||||
List<Work> result = new ArrayList<Work>();
|
||||
|
||||
if (XMLErrors.check(document)) {
|
||||
|
||||
try {
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(document, ORCID_WORK);
|
||||
while (iterator.hasNext()) {
|
||||
Work work = convertWork(iterator.next());
|
||||
result.add(work);
|
||||
}
|
||||
} catch (XPathExpressionException e) {
|
||||
log.error("Error in xpath syntax", e);
|
||||
}
|
||||
} else {
|
||||
processError(document);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected Work convertWork(Node node) throws XPathExpressionException {
|
||||
Work work = new Work();
|
||||
setTitle(node, work);
|
||||
setDescription(node, work);
|
||||
setCitation(node, work);
|
||||
setWorkType(node, work);
|
||||
setPublicationDate(node, work);
|
||||
setExternalIdentifiers(node, work);
|
||||
setUrl(node, work);
|
||||
setContributors(node, work);
|
||||
setWorkSource(node, work);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
||||
protected void setWorkSource(Node node, Work work) throws XPathExpressionException {
|
||||
String workSource = XMLUtils.getTextContent(node, WORK_SOURCE);
|
||||
work.setWorkSource(workSource);
|
||||
}
|
||||
|
||||
protected void setContributors(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
Set<Contributor> contributors = new HashSet<Contributor>();
|
||||
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(node, CONTRIBUTOR);
|
||||
while (iterator.hasNext()) {
|
||||
Node nextContributorNode = iterator.next();
|
||||
String orcid = XMLUtils.getTextContent(nextContributorNode, CONTRIBUTOR_ORCID);
|
||||
String creditName = XMLUtils.getTextContent(nextContributorNode, CREDIT_NAME);
|
||||
String email = XMLUtils.getTextContent(nextContributorNode, CONTRIBUTOR_EMAIL);
|
||||
|
||||
Set<ContributorAttribute> contributorAttributes = new HashSet<ContributorAttribute>();
|
||||
NodeList attributeNodes = XMLUtils.getNodeList(nextContributorNode, CONTRIBUTOR_ATTRIBUTES);
|
||||
Iterator<Node> attributesIterator = XMLUtils.getNodeListIterator(attributeNodes);
|
||||
while (attributesIterator.hasNext()) {
|
||||
Node nextAttribute = attributesIterator.next();
|
||||
|
||||
String roleText = XMLUtils.getTextContent(nextAttribute, CONTRIBUTOR_ROLE);
|
||||
ContributorAttributeRole role = EnumUtils.lookup(ContributorAttributeRole.class, roleText);
|
||||
|
||||
String sequenceText = XMLUtils.getTextContent(nextAttribute, CONTRIBUTOR_SEQUENCE);
|
||||
ContributorAttributeSequence sequence = EnumUtils
|
||||
.lookup(ContributorAttributeSequence.class, sequenceText);
|
||||
|
||||
ContributorAttribute attribute = new ContributorAttribute(role, sequence);
|
||||
contributorAttributes.add(attribute);
|
||||
}
|
||||
|
||||
Contributor contributor = new Contributor(orcid, creditName, email, contributorAttributes);
|
||||
contributors.add(contributor);
|
||||
}
|
||||
|
||||
work.setContributors(contributors);
|
||||
}
|
||||
|
||||
protected void setUrl(Node node, Work work) throws XPathExpressionException {
|
||||
String url = XMLUtils.getTextContent(node, URL);
|
||||
work.setUrl(url);
|
||||
}
|
||||
|
||||
protected void setExternalIdentifiers(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(node, WORK_EXTERNAL_IDENTIFIER);
|
||||
while (iterator.hasNext()) {
|
||||
Node work_external_identifier = iterator.next();
|
||||
String typeText = XMLUtils.getTextContent(work_external_identifier, WORK_EXTERNAL_IDENTIFIER_TYPE);
|
||||
|
||||
WorkExternalIdentifierType type = EnumUtils.lookup(WorkExternalIdentifierType.class, typeText);
|
||||
|
||||
String id = XMLUtils.getTextContent(work_external_identifier, WORK_EXTERNAL_IDENTIFIER_ID);
|
||||
|
||||
WorkExternalIdentifier externalID = new WorkExternalIdentifier(type, id);
|
||||
work.setWorkExternalIdentifier(externalID);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setPublicationDate(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
String year = XMLUtils.getTextContent(node, YEAR);
|
||||
String month = XMLUtils.getTextContent(node, MONTH);
|
||||
String day = XMLUtils.getTextContent(node, DAY);
|
||||
|
||||
String publicationDate = year;
|
||||
if (StringUtils.isNotBlank(month)) {
|
||||
publicationDate += "-" + month;
|
||||
if (StringUtils.isNotBlank(day)) {
|
||||
publicationDate += "-" + day;
|
||||
}
|
||||
}
|
||||
|
||||
work.setPublicationDate(publicationDate);
|
||||
}
|
||||
|
||||
protected void setWorkType(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
String workTypeText = XMLUtils.getTextContent(node, WORK_TYPE);
|
||||
WorkType workType = EnumUtils.lookup(WorkType.class, workTypeText);
|
||||
|
||||
work.setWorkType(workType);
|
||||
}
|
||||
|
||||
protected void setCitation(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
String typeText = XMLUtils.getTextContent(node, CITATION_TYPE);
|
||||
CitationType type = EnumUtils.lookup(CitationType.class, typeText);
|
||||
|
||||
String citationtext = XMLUtils.getTextContent(node, CITATION);
|
||||
|
||||
Citation citation = new Citation(type, citationtext);
|
||||
work.setCitation(citation);
|
||||
}
|
||||
|
||||
protected void setDescription(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
String description = null;
|
||||
description = XMLUtils.getTextContent(node, SHORT_DESCRIPTION);
|
||||
work.setDescription(description);
|
||||
}
|
||||
|
||||
protected void setTitle(Node node, Work work) throws XPathExpressionException {
|
||||
|
||||
String title = XMLUtils.getTextContent(node, TITLE);
|
||||
|
||||
String subtitle = XMLUtils.getTextContent(node, SUBTITLE);
|
||||
|
||||
Map<String, String> translatedTitles = new HashMap<String, String>();
|
||||
NodeList nodeList = XMLUtils.getNodeList(node, TRANSLATED_TITLES);
|
||||
Iterator<Node> iterator = XMLUtils.getNodeListIterator(nodeList);
|
||||
while (iterator.hasNext()) {
|
||||
Node languageNode = iterator.next();
|
||||
String language = XMLUtils.getTextContent(languageNode, TRANSLATED_TITLES_LANGUAGE);
|
||||
String translated_title = XMLUtils.getTextContent(languageNode, ".");
|
||||
translatedTitles.put(language, translated_title);
|
||||
}
|
||||
|
||||
WorkTitle workTitle = new WorkTitle(title, subtitle, translatedTitles);
|
||||
work.setWorkTitle(workTitle);
|
||||
}
|
||||
|
||||
}
|
@@ -10,13 +10,12 @@ package org.dspace.authority.rest;
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authority.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
@@ -37,26 +36,26 @@ public class RESTConnector {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Document get(String path) {
|
||||
Document document = null;
|
||||
|
||||
public InputStream get(String path, String accessToken) {
|
||||
InputStream result = null;
|
||||
path = trimSlashes(path);
|
||||
|
||||
String fullPath = url + '/' + path;
|
||||
HttpGet httpGet = new HttpGet(fullPath);
|
||||
if (StringUtils.isNotBlank(accessToken)) {
|
||||
httpGet.addHeader("Content-Type", "application/vnd.orcid+xml");
|
||||
httpGet.addHeader("Authorization","Bearer " + accessToken);
|
||||
}
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
HttpResponse getResponse = httpClient.execute(httpGet);
|
||||
//do not close this httpClient
|
||||
result = getResponse.getEntity().getContent();
|
||||
document = XMLUtils.convertStreamToXML(result);
|
||||
|
||||
} catch (Exception e) {
|
||||
getGotError(e, fullPath);
|
||||
}
|
||||
|
||||
return document;
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void getGotError(Exception e, String fullPath) {
|
||||
|
@@ -7,9 +7,7 @@
|
||||
*/
|
||||
package org.dspace.authority.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.SolrAuthorityInterface;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
@@ -17,15 +15,11 @@ import org.dspace.authority.AuthorityValue;
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
*/
|
||||
public abstract class RestSource {
|
||||
public abstract class RestSource implements SolrAuthorityInterface {
|
||||
|
||||
protected RESTConnector restConnector;
|
||||
|
||||
public RestSource(String url) {
|
||||
this.restConnector = new RESTConnector(url);
|
||||
}
|
||||
|
||||
public abstract List<AuthorityValue> queryAuthorities(String text, int max);
|
||||
|
||||
public abstract AuthorityValue queryAuthorityID(String id);
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@ import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.dspace.authority.AuthoritySearchService;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.SolrAuthorityInterface;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.rest.RestSource;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
@@ -37,8 +37,9 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
public class SolrAuthority implements ChoiceAuthority {
|
||||
|
||||
private static final Logger log = Logger.getLogger(SolrAuthority.class);
|
||||
protected RestSource source = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName("AuthoritySource", RestSource.class);
|
||||
protected SolrAuthorityInterface source =
|
||||
DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName("AuthoritySource", SolrAuthorityInterface.class);
|
||||
protected boolean externalResults = false;
|
||||
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance()
|
||||
.getAuthorityValueService();
|
||||
|
@@ -1433,6 +1433,10 @@ sherpa.romeo.url = http://www.sherpa.ac.uk/romeo/api29.php
|
||||
#plugin.named.org.dspace.content.authority.ChoiceAuthority = \
|
||||
# org.dspace.content.authority.SolrAuthority = SolrAuthorAuthority
|
||||
|
||||
# URL of ORCID API
|
||||
# Defaults to using the Public API (pub.orcid.org)
|
||||
orcid.api.url = https://pub.orcid.org/v2.1
|
||||
|
||||
## The DCInputAuthority plugin is automatically configured with every
|
||||
## value-pairs element in input-forms.xml, namely:
|
||||
## common_identifiers, common_types, common_iso_languages
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<bean name="AuthorityTypes" class="org.dspace.authority.AuthorityTypes">
|
||||
<property name="types">
|
||||
<list>
|
||||
<bean class="org.dspace.authority.orcid.OrcidAuthorityValue"/>
|
||||
<bean class="org.dspace.authority.orcid.Orcidv2AuthorityValue"/>
|
||||
<bean class="org.dspace.authority.PersonAuthorityValue"/>
|
||||
</list>
|
||||
</property>
|
||||
@@ -32,8 +32,8 @@
|
||||
</bean>
|
||||
|
||||
<alias name="OrcidSource" alias="AuthoritySource"/>
|
||||
<bean name="OrcidSource" class="org.dspace.authority.orcid.Orcid">
|
||||
<constructor-arg value="http://pub.orcid.org"/>
|
||||
<bean name="OrcidSource" class="org.dspace.authority.orcid.Orcidv2" init-method="init">
|
||||
<constructor-arg value="${orcid.api.url}"/>
|
||||
</bean>
|
||||
|
||||
|
||||
|
15
pom.xml
15
pom.xml
@@ -1658,6 +1658,21 @@
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<!-- Enable access to artifacts in Sonatype's snapshot repo for Snapshots ONLY -->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<layout>default</layout>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
|
Reference in New Issue
Block a user