From e92a0d798dd6dddd1ee2e8c95dd34ea9e011bf6f Mon Sep 17 00:00:00 2001 From: Maximilian Brodhun <brodhun@sub.uni-goettingen.de> Date: Wed, 13 Mar 2019 12:46:25 +0100 Subject: [PATCH] implemented GetRecord und ListRecords for IDIOM --- oaipmh-core/pom.xml | 4 +- .../info/textgrid/middleware/OAIPMHImpl.java | 79 ++++------ .../middleware/RecordDelivererDC.java | 25 ++-- .../middleware/RecordDelivererIDIOM.java | 140 +++++++++++------- ...iverer.java => RecordListDelivererDC.java} | 100 ++++++++----- .../info/textgrid/middleware/OaiPmhTest.java | 118 ++++++++------- 6 files changed, 248 insertions(+), 218 deletions(-) rename oaipmh-core/src/main/java/info/textgrid/middleware/{RecordListDeliverer.java => RecordListDelivererDC.java} (94%) diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 48195d85..3947887b 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -54,11 +54,11 @@ <version>${junit.version}</version> <scope>test</scope> </dependency> - <dependency> + <!--dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.1</version> - </dependency> + </dependency--> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> 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 8bb9bdbb..5993d953 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -33,7 +33,8 @@ public class OAIPMHImpl implements OAIPMHProducer { private ErrorHandler error = new ErrorHandler(); private org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); private RepIdentification rep; - private RecordListDeliverer recordList; + private RecordListDelivererDC recordListDC; + private RecordListDelivererIDIOM recordListIDIOM; private RecordDelivererDC recDelivDC; private RecordDelivererIDIOM recDelivIDIOM; private MetadataFormatListDeliverer metadataFormatList; @@ -54,12 +55,13 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param identifierList */ public OAIPMHImpl(RepIdentification rep, RecordDelivererDC recDelivDC,RecordDelivererIDIOM recDelivIDIOM, - RecordListDeliverer recordList, MetadataFormatListDeliverer metadataFormatList, + RecordListDelivererDC recordListDC,RecordListDelivererIDIOM recordListIDIOM, MetadataFormatListDeliverer metadataFormatList, SetDeliverer setList, IdentifierListDeliverer identifierList) { this.rep = rep; this.recDelivDC = recDelivDC; this.recDelivIDIOM = recDelivIDIOM; - this.recordList = recordList; + this.recordListDC = recordListDC; + this.recordListIDIOM = recordListIDIOM; this.metadataFormatList = metadataFormatList; this.setList = setList; this.identifierList = identifierList; @@ -181,9 +183,10 @@ public class OAIPMHImpl implements OAIPMHProducer { // Default is DC. RecordDelivererInterface recDeliv = this.recDelivDC; - + // Take IDIOM if IDIOM prefix. if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + recDeliv = this.recDelivIDIOM; } @@ -248,7 +251,7 @@ public class OAIPMHImpl implements OAIPMHProducer { } else { // System.out.println("bla1000"); if (request.getResumptionToken() != null - && RecordListDeliverer.cursorCollector.containsKey(request.getResumptionToken())) { + && RecordListDelivererDC.cursorCollector.containsKey(request.getResumptionToken())) { this.error.setError(TGConstants.OAI_BAD_RESUMPTION_TOKEN, "The value of the resumptionToken argument is invalid or expired"); oai.getError().add(this.error.getError()); @@ -351,51 +354,33 @@ public class OAIPMHImpl implements OAIPMHProducer { * @return */ public JAXBElement<OAIPMHType> listRecordsRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) { + RequestType request) { - // System.out.println("blablablabla"); - List<String> errorValues = new ArrayList<String>(); - ListRecordsType listRecords = new ListRecordsType(); - // RecordListDeliverer recordList = new - // RecordListDeliverer(oaiEsClient,// TGConstants.TGFields); JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - - if (request.getResumptionToken() != null && request.getMetadataPrefix() != null) { - errorValues.add("MetadataPrefix"); - this.error.setError(TGConstants.OAI_BAD_ARGUMENT, - "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(this.error.getError()); - } else if (request.getResumptionToken() != null && request.getSet() != null) { - errorValues.add("Set"); - this.error.setError(TGConstants.OAI_BAD_ARGUMENT, - "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(this.error.getError()); - } else if (request.getResumptionToken() == null && request.getMetadataPrefix() == null) { - errorValues.add("MetadataPrefix"); - this.error.setError(TGConstants.OAI_BAD_ARGUMENT, - "The request includes illegal arguments or missing requiered arguments:" + errorValues); - oai.getError().add(this.error.getError()); - } else if (request.getMetadataPrefix() != null - && !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { - this.error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR, - "The value of the metadataPrefix: " + request.getMetadataPrefix() - + " is not supported by the item identified by the value of: " - + request.getIdentifier()); - oai.getError().add(this.error.getError()); - } else { - listRecords = - this.recordList.getRecords(request.getFrom(), request.getUntil(), request.getSet(), - request.getResumptionToken()); - if (listRecords != null) { - oai.setListRecords(listRecords); - } else { - this.error.setError(TGConstants.OAI_NO_RECORD_MATCH, "The combination of the values " - + request.getFrom() + " and " + request.getUntil() + " results in an empty list"); - oai.getError().add(this.error.getError()); - } + + ErrorHandler requestErrors = RecordListDelivererAbstract.requestChecker(request); + + if (requestErrors.getError().getCode() != null) { + oai.getError().add(requestErrors.getError()); + }else { + // Default is DC. + RecordListDelivererInterface recListDeliv = this.recordListDC; + + // Take IDIOM if IDIOM prefix. + if (request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) { + System.out.println("Enter IDIOM"); + recListDeliv = this.recordListIDIOM; + } + + ListRecordsType listRecords = new ListRecordsType(); + listRecords = recListDeliv.getRecords(request.getFrom(), request.getUntil(), request.getSet(), + request.getResumptionToken()); + + if (listRecords != null) { + oai.setListRecords(listRecords); + } } - - return oaipmhRoot; + return oaipmhRoot; } /** diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java index d2f4e46a..2c2290c3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -90,7 +90,6 @@ public class RecordDelivererDC extends RecordDelivererAbstract { * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ public GetRecordType getRecordById(String id) { - System.out.println("DC"); ObjectFactory of = new ObjectFactory(); OaiDcType odt = new OaiDcType(); GetRecordType grt = new GetRecordType(); @@ -100,7 +99,6 @@ public class RecordDelivererDC extends RecordDelivererAbstract { if (id.startsWith(this.repositoryObjectURIPrefix)) { changedId = changedId.replace(this.repositoryObjectURIPrefix, ""); - // System.out.println("CHANGEDID: " + changedId); } GetRequestBuilder recordById = OAI_ESClient.getOaiESClient() @@ -180,7 +178,7 @@ public class RecordDelivererDC extends RecordDelivererAbstract { RecordType record, DublinCoreBuilder dbc) { HeaderType recordHeader = new HeaderType(); - // System.out.println("IDENTIFIRE::: " + identifier); + recordHeader.setIdentifier(identifier); recordHeader.setDatestamp(dateOfCreation); record.setMetadata(dbc.getDC()); @@ -369,14 +367,6 @@ public class RecordDelivererDC extends RecordDelivererAbstract { this.identifierField = identifierPrefix; } - public void setFields(String[] fields) { - this.fields = fields; - } - - public String[] getFields() { - return this.fields; - } - public void setContributor(String[] contributorList) { this.contributorList = contributorList; } @@ -466,11 +456,18 @@ public class RecordDelivererDC extends RecordDelivererAbstract { return this.workFields; } - /** - * @param workFields - */ public void setWorkFields(String[] workFields) { this.workFields = workFields; } + + public void setFields(String[] fields) { + this.fields = fields; + } + + public String[] getFields() { + return this.fields; + } + + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java index fb1879d6..2ac55982 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java @@ -1,41 +1,42 @@ package info.textgrid.middleware; - - import java.io.StringReader; +import java.text.ParseException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.apache.commons.logging.LogFactory; import org.classicmayan.tools.ClassicMayanMetsMods; +import org.elasticsearch.action.get.GetRequestBuilder; +import org.elasticsearch.action.get.GetResponse; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.MetadataType; import info.textgrid.middleware.oaipmh.RecordType; +/** + * + * @author Maximilian Brodhun, SUB Göttingen + * @since 2019-03-08 + * @version 2019-03-12 + * + */ public class RecordDelivererIDIOM extends RecordDelivererAbstract { - private String[] fields; - private String[] workFields; private String dateOfObjectCreation; - private String repositoryObjectURIPrefix; - static MetadataType metadataMets = new MetadataType(); - - private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererDC.class); - + private String dateOfLastOblectModification; + static MetadataType metadataMets = new MetadataType(); + RecordType record = new RecordType(); + ClassicMayanMetsMods metsmods; + + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererIDIOM.class); /** * @param textgrid @@ -44,34 +45,81 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { public RecordDelivererIDIOM(boolean textgrid, boolean dariah) { super(textgrid, dariah); } - - - - + /* * (non-Javadoc) * * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ + + /** + * ElasticSearch request in non-public index to get the datestamps for + * the object creation and last modification date in TextGrid-Repo + * + * @param idInDatabase + */ + + public void setDatestamps(String idInDatabase) { + + System.out.println(idInDatabase.replace("textgrid:", "")); + + GetRequestBuilder recordById = OAI_ESClient.getOaiESClient() + .prepareGet() + .setIndex("textgrid-nonpublic") + .setType(OAI_ESClient.getEsType()) + .setFields(TGConstants.CREATED, TGConstants.MODIFIED_FIELD) + .setId(idInDatabase.replace("textgrid:", "") + ".0"); + + GetResponse objectInDatabase = recordById.execute().actionGet(); + + dateOfObjectCreation = objectInDatabase.getField(TGConstants.CREATED).getValue().toString(); + dateOfLastOblectModification = objectInDatabase.getField(TGConstants.MODIFIED_FIELD).getValue().toString(); + } + + /** + * building the record XML object for the OAI-PMH response + */ + public GetRecordType getRecordById(String id) { - + GetRecordType grt = new GetRecordType(); - RecordType record = new RecordType(); - + + setDatestamps(id); + String textgridBaseURI_FromID; + if(!id.startsWith("textgrid:")) { + textgridBaseURI_FromID = "textgrid:" + id.replace(".0", ""); + }else { + textgridBaseURI_FromID = id; + } + + metsmods = new ClassicMayanMetsMods( + textgridBaseURI_FromID, + dateOfObjectCreation, + dateOfLastOblectModification); record.setMetadata(idiomMets()); + try { + setRecordHeader(dateOfObjectCreation, "textgrid:" + id); + } catch (ParseException e) { + e.printStackTrace(); + //log.error(e.printStackTrace()); + } + grt.setRecord(record); return grt; } - - public MetadataType idiomMets(){ - - ClassicMayanMetsMods metsmods = new ClassicMayanMetsMods("textgrid:2557q", - "2016-02-18T11:15:19.899+01:00", "2018-02-02T12:12:34.113+01:00"); - String signsToTrim = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + - "<?xml-model href=\"http://www.loc.gov/standards/mods/v3/mods-3-7.xsd\" type=\"application/xml\" schematypens=\"http://purl.oclc.org/dsdl/schematron\"?>"; - String trimmedMets = metsmods.getMets().replace(signsToTrim, ""); - //System.out.println(trimmedMets); + + // ** + // PRIVATE METHODS + // ** + + /** + * Getting the Mets/Mods object for the ClassicMayan artefact + * and put them into metadata element of the OAI-PMH response + * @return metadata XML-Elment + */ + + private MetadataType idiomMets(){ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; @@ -79,46 +127,30 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { try { builder = factory.newDocumentBuilder(); - Document doc = builder.parse( new InputSource( new StringReader( trimmedMets ) ) ); + Document doc = builder.parse( new InputSource( new StringReader( metsmods.getMets() ) ) ); metadataMets.setAny(doc.getDocumentElement()); } catch (Exception e) { e.printStackTrace(); - } - + } - - // metadataMets.setAny(doc); - //metadataMets.setAny(value); return metadataMets; } - // ** - // PRIVATE METHODS - // ** + /** * @param dateOfCreation * @param identifier - * @param record * @return + * @throws ParseException */ - private static RecordType setRecordHeader(String dateOfCreation, String identifier, - RecordType record) { + private void setRecordHeader(String dateOfCreation, String identifier) throws ParseException { HeaderType recordHeader = new HeaderType(); recordHeader.setIdentifier(identifier); - recordHeader.setDatestamp(dateOfCreation); - // record.setMetadata(metadataMets); + recordHeader.setDatestamp(OAIPMHUtillities.datestampAsString(dateOfCreation)); record.setHeader(recordHeader); - - return record; + //return recordHeader; } - /** - * @param id - * @return - */ - - - } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java similarity index 94% rename from oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java rename to oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java index 96851389..cff9212f 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDelivererDC.java @@ -29,7 +29,7 @@ import info.textgrid.middleware.oaipmh.ResumptionTokenType; /** * FIXME Care about all repeatable fields as done in TITLE! */ -public class RecordListDeliverer { +public class RecordListDelivererDC extends RecordListDelivererAbstract{ // ** // STATICS @@ -41,11 +41,9 @@ public class RecordListDeliverer { // CLASS VARIABLES // ** - // private OAI_ESClient oaiEsClient; + private OAI_ESClient oaiEsClient; private String[] fields; private String[] workFields; - private boolean textgrid; - private boolean dariah; private String formatField; private String formatToFilter; private String dateOfObjectCreation; @@ -105,13 +103,8 @@ public class RecordListDeliverer { * @param textgrid * @param dariah */ - public RecordListDeliverer(String[] fields, String[] workFields, boolean textgrid, - boolean dariah) { - // this.oaiEsClient = oaiEsClient; - this.fields = fields; - this.workFields = workFields; - this.textgrid = textgrid; - this.dariah = dariah; + public RecordListDelivererDC(boolean textgrid, boolean dariah) { + super(textgrid, dariah); } /** @@ -169,9 +162,15 @@ public class RecordListDeliverer { } if (resumptionToken == null) { - scrollResp = OAI_ESClient.getOaiESClient().prepareSearch(OAI_ESClient.getEsIndex()) - .setScroll(new TimeValue(lifeTimeResToken)).setTypes(OAI_ESClient.getEsType()) - .addFields(this.fields).setQuery(recordFilter).setSize(searchResponseSize).execute() + + scrollResp = OAI_ESClient.getOaiESClient() + .prepareSearch(OAI_ESClient.getEsIndex()) + .setScroll(new TimeValue(lifeTimeResToken)) + .setTypes(OAI_ESClient.getEsType()) + .addFields(this.fields) + .setQuery(recordFilter) + .setSize(searchResponseSize) + .execute() .actionGet(); } else { scrollResp = OAI_ESClient.getOaiESClient().prepareSearchScroll(resumptionToken) @@ -179,15 +178,14 @@ public class RecordListDeliverer { } scrollID = scrollResp.getScrollId(); - long completeListSize = scrollResp.getHits().totalHits(); - // System.out.println("LISTSIZE: " + completeListSize); + long completeListSize = scrollResp.getHits().totalHits(); if (completeListSize > 0) { setFoundItems(true); - + int i = 0; - + for (SearchHit hit : scrollResp.getHits().getHits()) { i++; @@ -205,14 +203,16 @@ public class RecordListDeliverer { log.debug(e1); } modifiedValue = hit.getFields().get(this.modifiedField).getValue().toString(); + // TextGrid search! String workUri = ""; + if (this.textgrid == true && hit.getFields().get(formatField).values().get(0).toString() .equals(formatToFilter)) { if (hit.getFields().get(this.relationToFurtherMetadataObject) != null) { workUri = hit.getFields().get(this.relationToFurtherMetadataObject).values().get(0) .toString().substring(this.repositoryObjectURIPrefix.length()); - + if (!workUri.endsWith(".0")) { workUri = workUri.concat(".0"); } @@ -220,8 +220,9 @@ public class RecordListDeliverer { putContentIntoDCFieldLists(hit, furtherDCElements(workUri, OAI_ESClient.getOaiESClient())); + buildRecord(recordList, set, - hit.getFields().get(this.identifierField).getValue().toString()); + hit.getFields().get(this.identifierField).getValue().toString()); listClearer(); } @@ -361,9 +362,6 @@ public class RecordListDeliverer { QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(queryField, valueField); QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); query = boolQuery; - -// System.out.println(query); - } else { query = rangeQuery; } @@ -651,24 +649,6 @@ public class RecordListDeliverer { this.typeList = typesList; } - /** - * @param request - * @return - */ - public boolean requestChecker(RequestType request) { - - boolean requestCheck; - - if (request.getIdentifier() != null || request.getMetadataPrefix() == null) { - - requestCheck = false; - } else { - requestCheck = true; - } - - return requestCheck; - } - /** * @return */ @@ -707,6 +687,10 @@ public class RecordListDeliverer { this.searchResponseSize = Integer.parseInt(searchResponseSize); } + public boolean getTextGrid() { + return textgrid; + } + // public String getCollectionTitle() { // return collectionTitle; // } @@ -714,5 +698,39 @@ public class RecordListDeliverer { // public void setCollectionTitle(GetResponse responseWorkValues) { // this.collectionTitle = responseWorkValues.getField("metadata.dc:title").getValue().toString(); // } + /** + * @return + */ + public String[] getWorkFields() { + return this.workFields; + } + + /** + * @param workFields + */ + public void setWorkFields(String[] workFields) { + this.workFields = workFields; + } + + public void setFields(String[] fields) { + this.fields = fields; + } + + public String[] getFields() { + return this.fields; + } + + /** + * @return + */ + public OAI_ESClient getOaiEsClient() { + return this.oaiEsClient; + } + /** + * @param oaiEsClient + */ + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java index 945e9721..61baceb0 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -39,20 +39,18 @@ public class OaiPmhTest { // private RecordListDeliverer recordList = new RecordListDeliverer(TGConstants.TGFields, // TGConstants.TGWorkFields, true, false); - private RecordListDeliverer recordList = new RecordListDeliverer(DARIAHConstants.DARIAHFields, - DARIAHConstants.DARIAHFields, false, true); + private static RecordListDelivererDC recordList; + private static RecordListDelivererIDIOM recordListIDIOM; // TGConstants.TGWorkFields, true, false); - private MetadataFormatListDeliverer metadataFormatList = - new MetadataFormatListDeliverer(oaiEsClient); + private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(oaiEsClient); private SetDeliverer setListDARIAH = new SetDeliverer(oaiEsClient, false, true); private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false); // private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, // false, true); - private IdentifierListDeliverer identifierList = - new IdentifierListDeliverer(oaiEsClient, true, false); - private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, this.recordList, - this.metadataFormatList, this.setListDARIAH, this.identifierList); + private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, true, false); + private OAIPMHImpl request = new OAIPMHImpl(this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.recordList, + OaiPmhTest.recordListIDIOM, this.metadataFormatList, this.setListDARIAH, this.identifierList); /** * @throws Exception @@ -72,9 +70,19 @@ public class OaiPmhTest { // Set OSI client for record. record = new RecordDelivererDC(true, false); record.setOaiEsClient(oaiEsClient); - record.setWorkFields(TGConstants.TGWorkFields); + record.setWorkFields(TGConstants.TGWorkFields); recordIDIOM = new RecordDelivererIDIOM(true, false); + + + recordList = new RecordListDelivererDC(true, false); + recordList.setFields(TGConstants.TGFields); + recordList.setWorkFields(TGConstants.TGWorkFields); + recordList.setOaiEsClient(oaiEsClient); + recordList.setSearchResponseSize("10"); + + recordListIDIOM = new RecordListDelivererIDIOM(true, false); + recordListIDIOM.setOaiEsClient(oaiEsClient); } /** @@ -223,36 +231,12 @@ public class OaiPmhTest { * @throws ParseException */ @Test - //@Ignore + @Ignore public void testGetRequestGetRecordIDIOM() throws ParseException { - /*record.setContributor(TGConstants.CONTRIBUTOR_LIST); - record.setCoverage(TGConstants.COVERAGE_LIST); - record.setCreator(TGConstants.CREATOR_LIST); - record.setDates(TGConstants.DATE_LIST); - record.setDescriptions(TGConstants.DESCRIPTION_LIST); - record.setFormats(TGConstants.FORMAT_LIST); - record.setIdentifiers(TGConstants.IDENTIFIER_LIST); - record.setLanguages(TGConstants.LANGUAGE_LIST); - record.setPublishers(TGConstants.PUBLISHER_LIST); - record.setRelations(TGConstants.RELATIONS_LIST); - record.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); - record.setRights(TGConstants.RIGHTS_LIST); - record.setSources(TGConstants.SOURCE_LIST); - record.setSubjects(TGConstants.SUBJECT_LIST); - record.setTitles(TGConstants.TITLE_LIST); - record.setTypes(TGConstants.TYPE_LIST); - record.setFields(TGConstants.TGFields); - record.setFormatField(TGConstants.FORMAT); - record.setFormatToFilter(TextGridMimetypes.EDITION); - record.setDateOfObjectCreation(TGConstants.CREATED); - record.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - record.setIdentifierField("textgridUri");*/ - System.out.println("Test for the verb \"GetRecord\" with succesfull response"); JAXBElement<OAIPMHType> p = - this.request.getRequest("GetRecord", "2557q.0", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); + this.request.getRequest("ListRecords", "", TGConstants.METADATA_IDIOM_PREFIX, "project:TGPR-0e926f53-1aba-d415-ecf6-539edcd8a318", "", "", ""); JAXB.marshal(p, System.out); System.out.println("-----------------------------------\n"); } @@ -337,31 +321,32 @@ public class OaiPmhTest { @Test @Ignore public void testListRecordSets() throws ParseException { - this.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); - this.recordList.setCoverage(TGConstants.COVERAGE_LIST); - this.recordList.setCreators(TGConstants.CREATOR_LIST); - this.recordList.setDates(TGConstants.DATE_LIST); - this.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); - this.recordList.setFormats(TGConstants.FORMAT_LIST); - this.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); - this.recordList.setLanguages(TGConstants.LANGUAGE_LIST); - this.recordList.setPublishers(TGConstants.PUBLISHER_LIST); - this.recordList.setRelations(TGConstants.RELATIONS_LIST); - this.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); - this.recordList.setRights(TGConstants.RIGHTS_LIST); - this.recordList.setSources(TGConstants.SOURCE_LIST); - this.recordList.setSubjects(TGConstants.SUBJECT_LIST); - this.recordList.setTitles(TGConstants.TITLE_LIST); - this.recordList.setTypes(TGConstants.TYPE_LIST); - this.recordList.setFormatField(TGConstants.FORMAT); - this.recordList.setFormatToFilter(TextGridMimetypes.EDITION); - this.recordList.setDateOfObjectCreation(TGConstants.CREATED); - this.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - this.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); - this.recordList.setFieldForRange(TGConstants.CREATED); - this.recordList.setModifiedField(TGConstants.MODIFIED_FIELD); - - System.out.println("Test for the verb \"ListRecord\" with sets with succesfull response"); + OaiPmhTest.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); + OaiPmhTest.recordList.setCoverage(TGConstants.COVERAGE_LIST); + OaiPmhTest.recordList.setCreators(TGConstants.CREATOR_LIST); + OaiPmhTest.recordList.setDates(TGConstants.DATE_LIST); + OaiPmhTest.recordList.setDescriptions(TGConstants.DESCRIPTION_LIST); + OaiPmhTest.recordList.setFormats(TGConstants.FORMAT_LIST); + OaiPmhTest.recordList.setIdentifiers(TGConstants.IDENTIFIER_LIST); + OaiPmhTest.recordList.setLanguages(TGConstants.LANGUAGE_LIST); + OaiPmhTest.recordList.setPublishers(TGConstants.PUBLISHER_LIST); + OaiPmhTest.recordList.setRelations(TGConstants.RELATIONS_LIST); + OaiPmhTest.recordList.setRelationsForWork(TGConstants.RELATIONS_FOR_WORK_LIST); + OaiPmhTest.recordList.setRights(TGConstants.RIGHTS_LIST); + OaiPmhTest.recordList.setSources(TGConstants.SOURCE_LIST); + OaiPmhTest.recordList.setSubjects(TGConstants.SUBJECT_LIST); + OaiPmhTest.recordList.setTitles(TGConstants.TITLE_LIST); + OaiPmhTest.recordList.setTypes(TGConstants.TYPE_LIST); + OaiPmhTest.recordList.setFormatField(TGConstants.FORMAT); + OaiPmhTest.recordList.setFormatToFilter(TextGridMimetypes.EDITION); + OaiPmhTest.recordList.setDateOfObjectCreation(TGConstants.CREATED); + OaiPmhTest.recordList.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); + OaiPmhTest.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + OaiPmhTest.recordList.setFieldForRange(TGConstants.CREATED); + OaiPmhTest.recordList.setModifiedField(TGConstants.MODIFIED_FIELD); + OaiPmhTest.recordList.setIdentifierField("textgridUri"); + + System.out.println("Test for the verb \"ListRecords\" with sets with succesfull response"); JAXBElement<OAIPMHType> p = this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); JAXB.marshal(p, System.out); @@ -369,6 +354,19 @@ public class OaiPmhTest { } + @Test + @Ignore + public void testListRecordSetsForIDIOM() throws ParseException { + + System.out.println("Test for the verb \"ListRecords\" for IDIOM with succesfull response"); + JAXBElement<OAIPMHType> p = + this.request.getRequest("ListRecords", "", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + + } + + /** * @throws ParseException */ -- GitLab