From effccfc1c215d9d66faf0559cd70fc496859fea5 Mon Sep 17 00:00:00 2001 From: "Stefan E. Funk" <funk@sub.uni-goettingen.de> Date: Tue, 20 Jul 2021 17:57:34 +0200 Subject: [PATCH] Refactor some method names Add recordListDelivererDatacite method Mark (for now) unused methods deprecated Adapt beans and impl files --- .../textgrid/middleware/DARIAHConstants.java | 9 +- .../info/textgrid/middleware/OAIPMHImpl.java | 4 +- .../RecordListDelivererAbstract.java | 73 ++++++- .../RecordListDelivererDATACITE.java | 65 ++++-- .../middleware/RecordListDelivererDC.java | 2 + ...etDeliverer.java => SetListDeliverer.java} | 20 +- .../info/textgrid/middleware/TGConstants.java | 10 +- .../middleware/OaiPmhDariahdeOnlineTests.java | 195 ++++++++++++++++-- .../textgrid/middleware/OaiPmhTestDH.java | 2 +- .../textgrid/middleware/OaiPmhTestTG.java | 4 +- .../middleware/OaiPmhTextgridOnlineTests.java | 83 +++++++- .../src/main/webapp/WEB-INF/beans.xml | 27 ++- 12 files changed, 425 insertions(+), 69 deletions(-) rename oaipmh-core/src/main/java/info/textgrid/middleware/{SetDeliverer.java => SetListDeliverer.java} (95%) diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java index b3d49380..ec23d0ab 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java @@ -13,12 +13,9 @@ import java.util.List; public final class DARIAHConstants { - /** - * - */ - private DARIAHConstants() { - // - } + // FIXME Put all TG or DH specific values into configuration file! + + // FIXME Put all other values in a single Constants class! public static final String ITEM_IDENTIFIER_PREFIX = "hdl:"; public static final String COLLECTIONREGISTRY_PREFIX = "dariah:collection:"; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java index f88784be..0d9d8f64 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -69,7 +69,7 @@ public class OAIPMHImpl implements OAIPMHProducer { private IdentifierListDelivererDATACITE identifierListDATACITE; private MetadataFormatListDelivererInterface metadataFormatList; - private SetDeliverer setList; + private SetListDeliverer setList; // ** // PUBLIC @@ -100,7 +100,7 @@ public class OAIPMHImpl implements OAIPMHProducer { // OpenAireRecordList openAireRecordList, // 6 RecordListDelivererDATACITE recordListDATACITE, // 6 MetadataFormatListDelivererInterface metadataFormatList, // 7 - SetDeliverer setList, // 8 + SetListDeliverer setList, // 8 IdentifierListDelivererDC identifierList, // 9 IdentifierListDelivererIDIOM identifierListIDIOM, // 10 // OpenAireIdentifierList openAireIdentifierList // 11 diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java index b5614f93..067d9432 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererAbstract.java @@ -72,12 +72,19 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer */ public List<String> getUriList(String from, String to, String set, String resumptionToken) { + List<String> result = new ArrayList<String>(); + QueryBuilder query; + // FIXME Use values from config! + + // FIXME Unite with method getUriListDARIAH()! + + // FIXME Avoid useless logging! + log.debug("RANGEFIELD: " + "created"); QueryBuilder rangeQuery = QueryBuilders.rangeQuery("created").from(from).to(to); - QueryBuilder filterSandBox = QueryBuilders.matchPhraseQuery("nearlyPublished", "true"); if (set != null && !set.equals("openaire_data")) { @@ -91,6 +98,8 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer valueField = setParts[1]; } + // FIXME Unite with query from class SetListDeliverer! + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery).mustNot(filterSandBox); @@ -101,7 +110,56 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer query = QueryBuilders.boolQuery().must(rangeQuery).mustNot(filterSandBox); } - return getFieldsFromESIndex(query, resumptionToken, set); + System.out.println(" ## QUERY:\n" + query); + + result = getFieldsFromESIndex(query, resumptionToken, set); + + System.out.println(" ## RESULT: " + result); + + return result; + } + + /** + * @param from + * @param to + * @param set + * @param resumptionToken + * @return + */ + public List<String> getUriListDARIAH(String from, String to, String set, String resumptionToken) { + + List<String> result = new ArrayList<String>(); + + QueryBuilder query; + + System.out.println(" ## RANGEFIELD: " + this.dateOfObjectCreation); + + QueryBuilder rangeQuery = QueryBuilders.rangeQuery(this.dateOfObjectCreation).from(from).to(to); + + // TODO We must set the set's range as in SetListDeliverer using query scripts! + if (set != null && !set.equals("openaire_data")) { + String[] setParts = set.split(":"); + String queryField = setParts[0]; + String valueField = setParts[1]; + + System.out.println(" ## queryField: " + queryField); + System.out.println(" ## valueField: " + valueField); + + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); + QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); + + query = boolQuery; + } else { + query = QueryBuilders.boolQuery().must(rangeQuery); + } + + System.out.println(" ## QUERY:\n" + query); + + result = getFieldsFromESIndex(query, resumptionToken, set); + + System.out.println(" ## RESULT: " + result); + + return result; } /** @@ -115,12 +173,11 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer List<String> uriList = new ArrayList<String>(); QueryBuilder recordFilter = QueryBuilders.boolQuery().must(query) - .must(QueryBuilders.matchPhraseQuery("format", "text/tg.edition+tg.aggregation+xml")); + .must(QueryBuilders.matchPhraseQuery("format", this.formatToFilter)); SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - searchSourceBuilder.query(recordFilter); searchSourceBuilder.size(100); searchRequest.source(searchSourceBuilder); @@ -169,7 +226,7 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer try { cursorCollector.remove(resumptionToken); } catch (NullPointerException couldNotRemove) { - log.info("Could net remove hash value: " + resumptionToken + " from hash map"); + log.info("Could not remove hash value: " + resumptionToken + " from hash map"); } this.resTokenForResponse.setValue(""); } else { @@ -184,8 +241,10 @@ public abstract class RecordListDelivererAbstract implements RecordListDeliverer setFoundItems(false); } - log.debug("restok value: " + this.resTokenForResponse.getValue()); - log.debug("restok cursor: " + this.resTokenForResponse.getCursor()); + if (this.resTokenForResponse != null) { + log.debug("restok value: " + this.resTokenForResponse.getValue()); + log.debug("restok cursor: " + this.resTokenForResponse.getCursor()); + } return uriList; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java index 7e73bdc4..b35d0530 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDATACITE.java @@ -3,6 +3,9 @@ package info.textgrid.middleware; import java.io.IOException; import java.text.ParseException; import javax.xml.datatype.DatatypeConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import info.textgrid.middleware.common.RDFConstants; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.ListRecordsType; @@ -12,6 +15,8 @@ import info.textgrid.middleware.oaipmh.ListRecordsType; public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { + private static Log log = LogFactory.getLog(RecordListDelivererDATACITE.class); + /** * @param textgrid * @param dariah @@ -32,24 +37,60 @@ public class RecordListDelivererDATACITE extends RecordListDelivererAbstract { RecordDelivererDATACITE openAireRecord; - for (String uri : getUriList(from, to, set, resumptionToken)) { - try { + // ** + // TextGrid + // ** + + if (this.textgrid) { + for (String uri : getUriList(from, to, set, resumptionToken)) { try { - openAireRecord = new RecordDelivererDATACITE(true, false); - GetRecordType grt = openAireRecord.getRecordById(uri.replace("textgrid:", "")); - openAireRecordList.getRecord().add(grt.getRecord()); - } catch (IOException e) { + try { + openAireRecord = new RecordDelivererDATACITE(true, false); + GetRecordType grt = openAireRecord.getRecordById(uri.replace("textgrid:", "")); + openAireRecordList.getRecord().add(grt.getRecord()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DatatypeConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } + } + } + + // ** + // DARIAH + // ** + + else if (this.dariah) { + for (String uri : getUriListDARIAH(from, to, set, resumptionToken)) { - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + log.debug("uri: " + uri); - } catch (DatatypeConfigurationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + System.out.println(" ## URI: " + uri); + + try { + try { + openAireRecord = new RecordDelivererDATACITE(true, false); + // We must remove the prefix, as ElasticSearch is storing the IDa without it. + GetRecordType grt = + openAireRecord.getRecordById(uri.replace(RDFConstants.HDL_PREFIX, "")); + openAireRecordList.getRecord().add(grt.getRecord()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (DatatypeConfigurationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java index 0b01ffef..2ea711ae 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java @@ -467,6 +467,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract { query = rangeQuery; } + System.out.println(" ## query:\n" + query); + try { log.debug("getRecords(): " + (query != null ? "queryName=" + query.getName() : "query=NULL") diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java similarity index 95% rename from oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java rename to oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java index 01d59502..39038c22 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetListDeliverer.java @@ -25,9 +25,9 @@ import info.textgrid.middleware.oaipmh.SetType; /** * */ -public class SetDeliverer { +public class SetListDeliverer { - private static Log log = LogFactory.getLog(SetDeliverer.class); + private static Log log = LogFactory.getLog(SetListDeliverer.class); private static final int DH_SIZE = 100000; @@ -51,7 +51,7 @@ public class SetDeliverer { * @param textgrid * @param dariah */ - public SetDeliverer(boolean textgrid, boolean dariah) { + public SetListDeliverer(boolean textgrid, boolean dariah) { this.textgrid = textgrid; this.dariah = dariah; } @@ -154,17 +154,10 @@ public class SetDeliverer { } } } - - // Set for OpenAIRE. - SetType setOpenAire = new SetType(); - setOpenAire.setSetName("OpenAIRE"); - setOpenAire.setSetSpec("openaire_data"); - setList.getSet().add(setOpenAire); } // ...for DH else if (this.dariah) { - for (Entry<String, Aggregation> entry : getRecordListItems.getAggregations().asMap() .entrySet()) { @@ -203,6 +196,13 @@ public class SetDeliverer { } } + // Add OpenAIRE data set for OpenAIRE. + // TODO Document for what this is used or necessary! + SetType setOpenAire = new SetType(); + setOpenAire.setSetName("OpenAIRE"); + setOpenAire.setSetSpec("openaire_data"); + setList.getSet().add(setOpenAire); + return setList; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java index c94ae980..9490cdc5 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java @@ -13,14 +13,9 @@ import java.util.List; public final class TGConstants { - /** - * - */ - private TGConstants() { - // - } - + // FIXME Put all TG or DH specific values into configuration file! + // FIXME Put all other values in a single Constants class! public static final String SET_FIELD_FOR_TEXTGRID = "project"; public static final String PROJECT_ID_FOR_TEXTGRID = "project.id"; @@ -115,5 +110,4 @@ public final class TGConstants { public static final String[] TYPE_LIST = {WORK_GENRE, WORK_TYPE}; public static final String[] IDENTIFIER_LIST_FIELDS = {URI, CREATED, FORMAT}; public static final String RANGE_FIELD = CREATED; - } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java index 239202fd..80804be8 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDariahdeOnlineTests.java @@ -29,8 +29,8 @@ public class OaiPmhDariahdeOnlineTests { // The OAIPMH host to be tested. // private static String host = "https://repository.de.dariah.eu/1.0/oaipmh/"; // private static String host = "https://dhrepworkshop.de.dariah.eu/1.0/oaipmh/"; - // private static String host = "https://trep.de.dariah.eu/1.0/oaipmh/"; - private static String host = "http://vm1.dariah.local/1.0/oaipmh/"; + private static String host = "http://trep.de.dariah.eu/1.0/oaipmh/"; + // private static String host = "http://vm1.dariah.local/1.0/oaipmh/"; // Some output finals. private static final String ERROR = ">>> ERROR"; @@ -179,7 +179,7 @@ public class OaiPmhDariahdeOnlineTests { * @throws IOException */ @Test - public void testListRecordsSinglePage() throws IOException { + public void testListRecordsSinglePageDC() throws IOException { System.out.println(TESTING + "#LISTRECORDS with expected single page (without token)"); @@ -187,14 +187,14 @@ public class OaiPmhDariahdeOnlineTests { // String set = "21.11113/0000-000B-CAD1-5"; String set = ""; - testList("ListRecords", set); + int pageAmount = testList("ListRecords", "oai_dc", set); } /** * @throws IOException */ @Test - public void testListRecordsMorePages() throws IOException { + public void testListRecordsMorePagesDC() throws IOException { System.out.println(TESTING + "#LISTRECORDS with expected resumption token usage"); @@ -202,14 +202,125 @@ public class OaiPmhDariahdeOnlineTests { // String set = "21.11113/0000-000B-CAD1-5"; String set = ""; - testList("ListRecords", set); + int pageAmount = testList("ListRecords", "oai_dc", set); } /** * @throws IOException */ @Test - public void testListIdentifierSinglePage() throws IOException { + public void testListRecordsMorePagesDCFromUntil() throws IOException { + + System.out.println(TESTING + "#LISTRECORDS with expected resumption token usage"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + // FIXME Values for vm1 only! + String from = "2016-03-03"; + String until = "2018-05-04"; + int expectedPages = 5; + + int pageAmount = testList("ListRecords", "oai_dc", set, from, until); + + if (pageAmount != expectedPages) { + assertTrue(false); + } + } + + /** + * @throws IOException + */ + @Test + public void testListRecordsSinglePageDATACITE() throws IOException { + + System.out.println(TESTING + "#LISTRECORDS with expected single page (without token)"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + int pageAmount = testList("ListRecords", "oai_datasite", set); + } + + /** + * @throws IOException + */ + @Test + public void testListRecordsMorePagesDATASITE() throws IOException { + + System.out.println(TESTING + "#LISTRECORDS with expected resumption token usage"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + int pageAmount = testList("ListRecords", "oai_datasite", set); + } + + /** + * @throws IOException + */ + @Test + public void testListRecordsMorePagesDATASITEFromUntil() throws IOException { + + System.out.println(TESTING + "#LISTRECORDS with expected resumption token usage"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + // FIXME Values for vm1 only! + String from = "2016-03-03"; + String until = "2018-05-04"; + int expectedPages = 5; + + int pageAmount = testList("ListRecords", "oai_datasite", set, from, until); + + if (pageAmount != expectedPages) { + assertTrue(false); + } + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordDC() throws IOException { + + System.out.println(TESTING + "#GETRECORD with expected single page (without token)"); + + String identifier = ""; + String shouldContain = ""; + + String url = host + "oai?verb=GetRecord&identifier=" + identifier + "&metadataPrefix=oai_dc"; + + // FIXME Complete test! + } + + /** + * @throws IOException + */ + @Test + public void testGetRecordDATASITE() throws IOException { + + System.out.println(TESTING + "#GETRECORD with expected single page (without token)"); + + String identifier = ""; + String shouldContain = ""; + + String url = + host + "oai?verb=GetRecord&identifier=" + identifier + "&metadataPrefix=oai_datacite"; + + // FIXME Complete test! + } + + /** + * @throws IOException + */ + @Test + public void testListIdentifierSinglePageDC() throws IOException { System.out.println(TESTING + "#LISTIDENTIFIERS with expected single page (without token)"); @@ -217,14 +328,14 @@ public class OaiPmhDariahdeOnlineTests { // String set = "21.11113/0000-000B-CAD1-5"; String set = ""; - testList("ListIdentifiers", set); + int pageAmount = testList("ListIdentifiers", "oai_dc", set); } /** * @throws IOException */ @Test - public void testListIdentifiersMorePages() throws IOException { + public void testListIdentifiersMorePagesDC() throws IOException { System.out.println(TESTING + "#LISTIDENTIFIERS with expected resumption token usage"); @@ -232,7 +343,37 @@ public class OaiPmhDariahdeOnlineTests { // String set = "21.11113/0000-000B-CAD1-5"; String set = ""; - testList("ListIdentifiers", set); + int pageAmount = testList("ListIdentifiers", "oai_dc", set); + } + + /** + * @throws IOException + */ + @Test + public void testListIdentifierSinglePageDATACITE() throws IOException { + + System.out.println(TESTING + "#LISTIDENTIFIERS with expected single page (without token)"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + int pageAmount = testList("ListIdentifiers", "oai_datasite", set); + } + + /** + * @throws IOException + */ + @Test + public void testListIdentifiersMorePagesDATASITE() throws IOException { + + System.out.println(TESTING + "#LISTIDENTIFIERS with expected resumption token usage"); + + // Testing set: Bahnsen 1670_Erschließung_20161017.xlsx + // String set = "21.11113/0000-000B-CAD1-5"; + String set = ""; + + int pageAmount = testList("ListIdentifiers", "oai_datasite", set); } // ** @@ -388,9 +529,30 @@ public class OaiPmhDariahdeOnlineTests { /** * @param theVerb + * @param theMetadataPrefix + * @param theSet + * @return + * @throws IOException + */ + private static int testList(String theVerb, String theMetadataPrefix, String theSet) + throws IOException { + return testList(theVerb, theSet, theMetadataPrefix, null, null); + } + + /** + * @param theVerb + * @param theMetadataPrefix + * @param theSet + * @param from + * @param until + * @return How many pages were delivered * @throws IOException */ - private static void testList(String theVerb, String theSet) throws IOException { + private static int testList(String theVerb, String theMetadataPrefix, String theSet, String from, + String until) + throws IOException { + + int result; long startTime = System.currentTimeMillis(); @@ -399,13 +561,16 @@ public class OaiPmhDariahdeOnlineTests { testOccurance = "record"; } - String prefix = "oai_dc"; + String url = host + "oai?verb=" + theVerb + "&metadataPrefix=" + theMetadataPrefix; - String url = host + "oai?verb=" + theVerb + "&metadataPrefix=" + prefix; if (theSet != null && !theSet.isEmpty()) { url += "&set=" + theSet; } + if (from != null && until != null) { + url += "&from=" + from + "&until=" + until; + } + TGHttpResponse httpResponse = getHttpResponse(url); int status = httpResponse.getStatusCode(); @@ -414,15 +579,19 @@ public class OaiPmhDariahdeOnlineTests { String restok = examineResumptionTokenTag(httpResponse, testOccurance, ""); + result = 1; while (status == HttpStatus.SC_OK && !restok.equals("-1")) { url = host + "/oai?verb=" + theVerb + "&resumptionToken=" + restok; httpResponse = getHttpResponse(url); timeRunning = System.currentTimeMillis() - startTime; System.out.println("\ttime: " + getDurationInSecs(timeRunning)); restok = examineResumptionTokenTag(httpResponse, testOccurance, restok); + result++; } System.out.println(OK); + + return result; } /** diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java index a6e2889e..92a7fb0b 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestDH.java @@ -21,7 +21,7 @@ public class OaiPmhTestDH { private static IdentifierListDelivererDC identifierList; private static MetadataFormatListDelivererInterface metadataFormatList = new MetadataFormatListDelivererDH(); - private static SetDeliverer setListDARIAH = new SetDeliverer(false, true); + private static SetListDeliverer setListDARIAH = new SetListDeliverer(false, true); // private static OpenAireRecord openAireRecord; private static RecordDelivererDATACITE recordDATACITE; diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java index 24ac5e08..d527d3db 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTestTG.java @@ -42,7 +42,7 @@ public class OaiPmhTestTG { new IdentifierListDelivererDC(true, false); private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false); - private static SetDeliverer setListTextGrid; + private static SetListDeliverer setListTextGrid; // ** // CLASS @@ -109,7 +109,7 @@ public class OaiPmhTestTG { identifierList.setOaiEsClient(oaiEsClient); identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); - setListTextGrid = new SetDeliverer(true, false); + setListTextGrid = new SetListDeliverer(true, false); } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java index 9ebd7779..4a258ee9 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTextgridOnlineTests.java @@ -26,7 +26,7 @@ import info.textgrid.utils.httpclient.TGHttpResponse; * * @author Stefan E. Funk, SUB Göttingen */ -@Ignore +// @Ignore public class OaiPmhTextgridOnlineTests { private static final String OAI_DC_PREFIX = "oai_dc"; @@ -350,7 +350,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(TESTING + "testGetRecordDATACITE()"); String identifier = "textgrid:mq05.0"; - String shouldContain = "Wer dich kennt - der kaufft dich nit"; + String shouldContain = "Spraach-en Höfflichkeit"; String url = host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" @@ -377,7 +377,7 @@ public class OaiPmhTextgridOnlineTests { System.out.println(TESTING + "testGetRecordDATACITENoPrefix()"); String identifier = "mq05.0"; - String shouldContain = "Wer dich kennt - der kaufft dich nit"; + String shouldContain = "Spraach-en Höfflichkeit"; String url = host + "oai?verb=" + VERB_GET_RECORD + "&identifier=" + identifier + "&metadataPrefix=" @@ -427,6 +427,24 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OK); } + /** + * @throws IOException + */ + @Test + public void testListRecordsOAIDCMorePagesFromUntil() throws IOException { + + System.out.println(TESTING + "testListRecordsOAIDCMorePagesFromUntil()"); + + // Testing set: Digitale Bibliothek (on prod and dev available only...) + String set = "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c"; + String from = "2012-01-04T01:00:00"; + String until = "2012-01-04T12:00:00"; + + testList(VERB_LIST_RECORDS, set, OAI_DC_PREFIX, 0, 100, NO_THREAD_NAME, from, until); + + System.out.println(OK); + } + /** * @throws IOException */ @@ -440,6 +458,22 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OK); } + /** + * @throws IOException + */ + @Test + public void testListRecordsIDIOMMETSMorePagesFromUntil() throws IOException { + + System.out.println(TESTING + "testListRecordsIDIOMMETSMorePagesFromUntil()"); + + String from = "2012-01-04T01:00:00"; + String until = "2012-01-04T12:00:00"; + + testList(VERB_LIST_RECORDS, NO_SET, OAI_IDIOMMETS_PREFIX, 100, 30, NO_THREAD_NAME, from, until); + + System.out.println(OK); + } + /** * @throws IOException */ @@ -453,6 +487,22 @@ public class OaiPmhTextgridOnlineTests { System.out.println(OK); } + /** + * @throws IOException + */ + @Test + public void testListRecordsDATACITEMorePagesFromUntil() throws IOException { + + System.out.println(TESTING + "testListRecordsDATACITEMorePagesFromUntil()"); + + String from = "2012-01-04T01:00:00"; + String until = "2012-01-04T12:00:00"; + + testList(VERB_LIST_RECORDS, NO_SET, OAI_DATACITE_PREFIX, 15, 100, NO_THREAD_NAME, from, until); + + System.out.println(OK); + } + /** * @throws IOException */ @@ -1005,15 +1055,34 @@ public class OaiPmhTextgridOnlineTests { /** * @param theVerb * @param theSet - * @param metadataPrefix + * @param theMetadataPrefix * @param maxNumberOfPagesToTest * @param recordsExpectedPerRequest - * @param threadName + * @param theThreadName * @throws IOException */ protected static void testList(final String theVerb, final String theSet, final String theMetadataPrefix, final int maxNumberOfPagesToTest, final int recordsExpectedPerRequest, final String theThreadName) throws IOException { + testList(theVerb, theSet, theMetadataPrefix, maxNumberOfPagesToTest, recordsExpectedPerRequest, + theThreadName, null, null); + } + + /** + * @param theVerb + * @param theSet + * @param theMetadataPrefix + * @param maxNumberOfPagesToTest + * @param recordsExpectedPerRequest + * @param theThreadName + * @param from + * @param until + * @throws IOException + */ + protected static void testList(final String theVerb, final String theSet, + final String theMetadataPrefix, final int maxNumberOfPagesToTest, + final int recordsExpectedPerRequest, final String theThreadName, final String from, + final String until) throws IOException { long startTime = System.currentTimeMillis(); @@ -1028,6 +1097,10 @@ public class OaiPmhTextgridOnlineTests { url += "&set=" + theSet; } + if (from != null && until != null) { + url += "&from=" + from + "&until=" + until; + } + TGHttpResponse httpResponse = getHttpResponse(url, theThreadName); int status = httpResponse.getStatusCode(); diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index 333f3d47..f20e5a42 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -58,7 +58,7 @@ <!-- constructor-arg ref="OpenAireRecordList" / --> <constructor-arg ref="RecordListDATACITE" /> <constructor-arg ref="${metadataFormatListInstance}" /> - <constructor-arg ref="SetDeliverer" /> + <constructor-arg ref="ListSet" /> <constructor-arg ref="ListIdentifierDC" /> <constructor-arg ref="ListIdentifierIDIOM" /> <constructor-arg ref="ListIdentifierDATACITE" /> <!-- constructor-arg ref="OpenAireIdentifierList" / --> @@ -314,6 +314,9 @@ class="info.textgrid.middleware.RecordListDelivererIDIOM"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + + <!-- TODO Why we don't need any property definitions here? --> + </bean> <!-- <bean id="OpenAireRecordList" class="info.textgrid.middleware.OpenAireRecordList"> @@ -323,6 +326,24 @@ class="info.textgrid.middleware.RecordListDelivererDATACITE"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> + + <!-- Properties from abstract class --> + <property name="fields" value="${fields}" /> + <property name="workFields" value="${workFields}" /> + + <property name="dateOfObjectCreation" + value="${dateOfObjectCreation}" /> + <property name="relationToFurtherMetadataObject" + value="${relationToFurtherMetadataObject}" /> + <property name="repositoryObjectURIPrefix" + value="${repositoryObjectURIPrefix}" /> + <property name="modifiedField" value="${modifiedField}" /> + <property name="identifierField" value="${identifierField}" /> + <property name="rangeField" value="${rangeField}" /> + <property name="formatField" value="${formatField}" /> + <property name="formatToFilter" value="${formatToFilter}" /> + <property name="searchResponseSize" + value="${searchResponseSize}" /> </bean> <!-- Beans for verb=ListIdentifiers --> @@ -390,8 +411,8 @@ <!-- Bean for verb=ListSets --> - <bean id="SetDeliverer" - class="info.textgrid.middleware.SetDeliverer"> + <bean id="ListSet" + class="info.textgrid.middleware.SetListDeliverer"> <constructor-arg index="0" value="${textgrid}" /> <constructor-arg index="1" value="${dariah}" /> <property name="formatField" value="${formatField}" /> -- GitLab