[CST-5303] added missing JavaDoc

This commit is contained in:
Mykhaylo
2022-05-11 16:23:22 +02:00
parent 9c2c9132bb
commit a436639ca7
7 changed files with 107 additions and 15 deletions

View File

@@ -113,6 +113,14 @@ public class ADSImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
this.apiKey = apiKey;
}
/**
* This class is a Callable implementation to get ADS entries based on query object.
* This Callable use as query value the string queryString passed to constructor.
* If the object will be construct through Query.class instance, a Query's map entry with key "query" will be used.
* Pagination is supported too, using the value of the Query's map with keys "start" and "count".
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class SearchByQueryCallable implements Callable<List<ImportRecord>> {
private Query query;
@@ -137,6 +145,12 @@ public class ADSImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
}
}
/**
* This class is a Callable implementation to get an ADS entry using bibcode
* The bibcode to use can be passed through the constructor as a String or as Query's map entry, with the key "id".
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class SearchByIdCallable implements Callable<List<ImportRecord>> {
private Query query;
@@ -156,6 +170,13 @@ public class ADSImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
}
}
/**
* This class is a Callable implementation to search ADS entries
* using author and title and year.
* Pagination is supported too, using the value of the Query's map with keys "start" and "count".
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class FindMatchingRecordCallable implements Callable<List<ImportRecord>> {
private Query query;
@@ -176,6 +197,14 @@ public class ADSImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
}
/**
* This class is a Callable implementation to count the number of entries for an ADS query.
* This Callable use as query value to ADS the string queryString passed to constructor.
* If the object will be construct through Query.class instance, the value of the Query's
* map with the key "query" will be used.
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class CountByQueryCallable implements Callable<Integer> {
private Query query;

View File

@@ -257,10 +257,18 @@ public class EpoImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
return null;
}
/**
* This class is a Callable implementation to count the number of entries for an EPO query.
* This Callable use as query value to EPO the string queryString passed to constructor.
* If the object will be construct through Query.class instance, the value of the Query's
* map with the key "query" will be used.
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class CountRecordsCallable implements Callable<Integer> {
String bearer;
String query;
private String bearer;
private String query;
private CountRecordsCallable(Query query, String bearer) {
this.query = query.getParameterAsClass("query", String.class);
@@ -277,9 +285,16 @@ public class EpoImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
}
}
/**
* This class is a Callable implementation to get an EPO entry using epodocID (epodoc:AB1234567T)
* The epodocID to use can be passed through the constructor as a String or as Query's map entry, with the key "id".
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class SearchByIdCallable implements Callable<List<ImportRecord>> {
String bearer;
String id;
private String id;
private String bearer;
private SearchByIdCallable(String id, String bearer) {
this.id = id;
@@ -315,11 +330,20 @@ public class EpoImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
}
}
/**
* This class is a Callable implementation to get EPO entries based on query object.
* This Callable use as query value the string queryString passed to constructor.
* If the object will be construct through Query.class instance, a Query's map entry with key "query" will be used.
* Pagination is supported too, using the value of the Query's map with keys "start" and "count".
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
private class SearchByQueryCallable implements Callable<List<ImportRecord>> {
private Query query;
private String bearer;
private Integer start;
private Integer count;
private String bearer;
private SearchByQueryCallable(Query query, String bearer) {
this.query = query;
@@ -481,7 +505,7 @@ public class EpoImportMetadataSourceServiceImpl extends AbstractImportMetadataSo
List<Object> nodes = xpath.evaluate(document);
//exactly one element expected for any field
if (CollectionUtils.isEmpty(nodes)) {
return "";
return StringUtils.EMPTY;
} else {
return getValue(nodes.get(0));
}

View File

@@ -16,8 +16,25 @@ import java.util.Map;
*/
public interface LiveImportClient {
/**
* Http GET request
*
* @param timeout The connect timeout in milliseconds
* @param URL URL
* @param requestParams This map contains the parameters to be included in the request.
* Each parameter will be added to the url?(key=value)
* @return The response in String type converted from InputStream
*/
public String executeHttpGetRequest(int timeout, String URL, Map<String, Map<String, String>> params);
/**
* Http POST request
*
* @param URL URL
* @param params This map contains the header params to be included in the request.
* @param entry the entity value
* @return the response in String type converted from InputStream
*/
public String executeHttpPostRequest(String URL, Map<String, Map<String, String>> params, String entry);
}

View File

@@ -60,7 +60,7 @@ public class LiveImportClientImpl implements LiveImportClient {
requestConfigBuilder.setConnectionRequestTimeout(timeout);
RequestConfig defaultRequestConfig = requestConfigBuilder.build();
method = new HttpGet(getSearchUrl(URL, params.get(URI_PARAMETERS)));
method = new HttpGet(buildUrl(URL, params.get(URI_PARAMETERS)));
method.setConfig(defaultRequestConfig);
Map<String, String> headerParams = params.get(HEADER_PARAMETERS);
@@ -97,7 +97,7 @@ public class LiveImportClientImpl implements LiveImportClient {
Builder requestConfigBuilder = RequestConfig.custom();
RequestConfig defaultRequestConfig = requestConfigBuilder.build();
method = new HttpPost(getSearchUrl(URL, params.get(URI_PARAMETERS)));
method = new HttpPost(buildUrl(URL, params.get(URI_PARAMETERS)));
method.setConfig(defaultRequestConfig);
if (StringUtils.isNotBlank(entry)) {
method.setEntity(new StringEntity(entry));
@@ -133,6 +133,12 @@ public class LiveImportClientImpl implements LiveImportClient {
}
}
/**
* Allows to set the header parameters to the HTTP Post method
*
* @param method HttpPost method
* @param params This map contains the header params to be included in the request.
*/
private void setHeaderParams(HttpPost method, Map<String, Map<String, String>> params) {
Map<String, String> headerParams = params.get(HEADER_PARAMETERS);
if (MapUtils.isNotEmpty(headerParams)) {
@@ -142,7 +148,16 @@ public class LiveImportClientImpl implements LiveImportClient {
}
}
private String getSearchUrl(String URL, Map<String, String> requestParams) throws URISyntaxException {
/**
* This method allows you to add the parameters contained in the requestParams map to the URL
*
* @param URL URL
* @param requestParams This map contains the parameters to be included in the request.
* Each parameter will be added to the url?(key=value)
* @return
* @throws URISyntaxException
*/
private String buildUrl(String URL, Map<String, String> requestParams) throws URISyntaxException {
URIBuilder uriBuilder = new URIBuilder(URL);
if (MapUtils.isNotEmpty(requestParams)) {
for (String param : requestParams.keySet()) {

View File

@@ -9,6 +9,13 @@ package org.dspace.importer.external.metadatamapping.contributor;
import java.util.Collection;
/**
* Service interface class for processing json object.
* The implementation of this class is responsible for all business logic calls
* for extracting of values from json object.
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
*/
public interface JsonPathMetadataProcessor {
public Collection<String> processMetadata(String json);

View File

@@ -26,6 +26,11 @@ import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
/**
* This contributor can be used when parsing an XML file,
* particularly to extract a date and convert it to a specific format.
* In the variable dateFormatFrom the read format should be configured,
* instead in the variable dateFormatTo the format you want to obtain.
*
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.com)
*/
public class SimpleXpathDateFormatMetadataContributor extends SimpleXpathMetadatumContributor {

View File

@@ -13,9 +13,4 @@ test.folder.assetstore = ./target/testing/dspace/assetstore
test.bitstream = ./target/testing/dspace/assetstore/ConstitutionofIreland.pdf
#Path for a test Taskfile for the curate script
test.curateTaskFile = ./target/testing/dspace/assetstore/curate.txt
test.epo-resp = ./target/testing/dspace/assetstore/epo-resp.xml
test.epo-first = ./target/testing/dspace/assetstore/epo-first.xml
test.epo-second = ./target/testing/dspace/assetstore/epo-second.xml
test.epo-token = ./target/testing/dspace/assetstore/epo-token.json
test.curateTaskFile = ./target/testing/dspace/assetstore/curate.txt