From 9b4c5e2654db2de31ac4922fe7fa7861bf66a51b Mon Sep 17 00:00:00 2001 From: mbrodhu <brodhun@sub.uni-goettingen.de> Date: Wed, 10 Dec 2014 21:13:21 +0100 Subject: [PATCH] added: sets to ListRecords textgrid: prefix in getRecord code Refactoring --- oaipmh-core/pom.xml | 4 +- .../middleware/IdentifierListDeliverer.java | 1 - .../info/textgrid/middleware/OAIPMHImpl.java | 34 ++- .../textgrid/middleware/RecordDeliverer.java | 158 ++++++---- .../middleware/RecordListDeliverer.java | 281 +++++++++++++++++- .../info/textgrid/middleware/OaiPmhTest.java | 19 +- oaipmh-webapp/pom.xml | 4 +- pom.xml | 2 +- 8 files changed, 430 insertions(+), 73 deletions(-) diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index c34fec17..ee1cb577 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -4,11 +4,11 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>1.3.2-SNAPSHOT</version> + <version>1.3.3-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> - <version>1.3.2-SNAPSHOT</version> + <version>1.3.3-SNAPSHOT</version> <packaging>jar</packaging> <name>TextGrid :: TG-OAI-PMH :: Core</name> <url>http://maven.apache.org</url> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java index f67da829..cf7de915 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java @@ -27,7 +27,6 @@ public class IdentifierListDeliverer { private static org.apache.commons.logging.Log log = LogFactory.getLog(IdentifierListDeliverer.class); private String datestamp; - //private String identifier = "textgrid:"; private ListIdentifiersType lit = new ListIdentifiersType(); private boolean idExist = true; private OAI_ESClient oaiEsClient; 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 e1d8c1fc..a52daa2b 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -169,6 +169,7 @@ public class OAIPMHImpl implements OAIPMHProducer{ /** * checks the GetRecord request of correctness and response including errors in case of an incorrect request */ + public JAXBElement<OAIPMHType> getRecordRequest(ObjectFactory obf, OAIPMHType oai, RequestType request){ List<String> errorValues = new ArrayList<String>(); RecordDeliverer recDeliv = new RecordDeliverer(oaiEsClient); @@ -349,23 +350,40 @@ public class OAIPMHImpl implements OAIPMHProducer{ if(recordList.requestChecker(request)){ - if(request.getSet()!=null){ + /*if(request.getSet()!=null){ error.setError(TGConstants.OAI_NO_SET_HIERARCHY).setValue("The repository does not support sets"); oai.getError().add(error.setError(TGConstants.OAI_NO_SET_HIERARCHY)); } - else if(!request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)){ + else*/ + + if(!request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)){ error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR).setValue("The value of the metadataPrefix: " + request.getMetadataPrefix() + " is not supported by the item identified by the value of: " + request.getIdentifier()); oai.getError().add(error.setError(TGConstants.OAI_METADATA_FORMAT_ERROR)); }else{ - listRecords = recordList.getRecords(request.getFrom(), request.getUntil()); - if(listRecords!=null){ - oai.setListRecords(listRecords); - }else{ - error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The combination of the values " + request.getFrom() + " and " + + + if(request.getSet()==null){ + + listRecords = recordList.getRecords(request.getFrom(), request.getUntil()); + if(listRecords!=null){ + oai.setListRecords(listRecords); + }else{ + error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The combination of the values " + request.getFrom() + " and " + request.getUntil() + " results in an empty list"); - oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); + oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); + } + } + else{ + listRecords = recordList.getRecordsWithSet(request.getFrom(), request.getUntil(), request.getSet()); + if(listRecords!=null){ + + oai.setListRecords(listRecords); + }else{ + error.setError(TGConstants.OAI_NO_RECORD_MATCH).setValue("The combination of the values " + request.getFrom() + " and " + + request.getUntil() + " results in an empty list"); + oai.getError().add(error.setError(TGConstants.OAI_NO_RECORD_MATCH)); + } } } }else{ diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java index 6acd99b0..157c87b5 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDeliverer.java @@ -29,6 +29,39 @@ import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; public class RecordDeliverer { + private static final String CREATED = "created"; + private static final String FORMAT = "format"; + private static final String IDENTIFIER = "identifier"; + private static final String DATA_CONTRIBUTOR = "dataContributor"; + private static final String URI = "textgridUri"; + private static final String PROJECT_ID = "project.id"; + private static final String IS_DERIVED_FROM = "relations.isDerivedFrom"; + private static final String TITLE = "title"; + private static final String PID = "pid.value"; + private static final String EDITION_ISEDITIONOF = "edition.isEditionOf"; + private static final String EDITION_AGENT = "edition.agent.value"; + private static final String EDITION_LICENSEURI = "edition.license.licenseUri"; + private static final String EDITION_LANGUAGE = "edition.language"; + private static final String BIBCIT_AUTHOR = "edition.source.bibliographicCitation.author.value"; + private static final String BIBCIT_EDITOR = "edition.source.bibliographicCitation.editor.value"; + private static final String BIBCIT_TITLE = "edition.source.bibliographicCitation.editionTitle"; + private static final String BIBCIT_PLACEPUB = "edition.source.bibliographicCitation.placeOfPublication.value"; + private static final String BIBCIT_PUBLISHER = "edition.source.bibliographicCitation.publisher.value"; + private static final String BIBCIT_NO = "edition.source.bibliographicCitation.editionNo"; + private static final String BIBCIT_SERIES = "edition.source.bibliographicCitation.series"; + private static final String BIBCIT_VOLUME = "edition.source.bibliographicCitation.volume"; + private static final String BIBCIT_ISSUE = "edition.source.bibliographicCitation.issue"; + private static final String BIBCIT_EPAGE = "edition.source.bibliographicCitation.epage"; + private static final String BIBCIT_SPAGE = "edition.source.bibliographicCitation.spage"; + private static final String BIBCIT_BIBID = "edition.source.bibliographicCitation.bibidentifier"; + private static final String WORK_ABSTRACT = "work.abstract"; + private static final String WORK_GENRE = "work.genre"; + private static final String WORK_TYPE = "work.type"; + private static final String WORK_SPATIAL = "work.spatial.value"; + private static final String WORK_TEMPORAL = "work.temporal.value"; + private static final String WORK_AGENT = "work.agent.value"; + private static final String WORK_ID = "work.subject.id.value"; + /* * Lists for the Dublin Core elements. Lists are needed since each DC fields is possible to occures several times */ @@ -49,6 +82,8 @@ public class RecordDeliverer { private List<String> titles = new ArrayList<String>(); private List<String> types = new ArrayList<String>(); + private static final String TEXTGRID_IDENTIFIER_PREFIX = "textgrid:"; + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDeliverer.class); private boolean idExist = true; public boolean correctFormat = true; @@ -76,19 +111,23 @@ public class RecordDeliverer { public GetRecordType getRecordById(String id){ + String changedId = id; + + if(id.startsWith(TEXTGRID_IDENTIFIER_PREFIX)){ + changedId = changedId.replace(TEXTGRID_IDENTIFIER_PREFIX, ""); + } + GetRequestBuilder recordById = oaiEsClient.getOaiESClient().prepareGet() .setIndex(oaiEsClient.getEsIndex()) .setType(oaiEsClient.getEsType()) - .setFields("format", "created", "edition.isEditionOf", "edition.agent.value", "dataContributor", - "textgridUri", "project.id", "relations.isDerivedFrom", "edition.license.licenseUri", - "title", "edition.language", "pid.value", "edition.source.bibliographicCitation.author.value", - "edition.source.bibliographicCitation.editor.value", "edition.source.bibliographicCitation.editionTitle", - "edition.source.bibliographicCitation.placeOfPublication.value","edition.source.bibliographicCitation.publisher.value", - "edition.source.bibliographicCitation.editionNo", "edition.source.bibliographicCitation.series", - "edition.source.bibliographicCitation.volume", "edition.source.bibliographicCitation.issue", - "edition.source.bibliographicCitation.epage", "edition.source.bibliographicCitation.spage", - "edition.source.bibliographicCitation.bibidentifier") - .setId(id); + .setFields(FORMAT, CREATED, EDITION_ISEDITIONOF, EDITION_AGENT, + DATA_CONTRIBUTOR, URI, PROJECT_ID, IS_DERIVED_FROM, + EDITION_LICENSEURI, TITLE, EDITION_LANGUAGE, PID, + BIBCIT_AUTHOR, BIBCIT_EDITOR, BIBCIT_TITLE, + BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, + BIBCIT_SERIES, BIBCIT_VOLUME, BIBCIT_ISSUE, + BIBCIT_EPAGE, BIBCIT_SPAGE, BIBCIT_BIBID) + .setId(changedId); GetResponse tgObject = recordById.execute().actionGet(); @@ -113,44 +152,44 @@ public class RecordDeliverer { /* * DC-Format */ - formats.add(tgObject.getField("format").getValue().toString()); + formats.add(tgObject.getField(FORMAT).getValue().toString()); /* * DC-Identifier */ - identifiers.add(tgObject.getField("textgridUri").getValue().toString()); + identifiers.add(tgObject.getField(URI).getValue().toString()); String identifier = identifiers.get(0); - if(tgObject.getField("pid.value")!=null){ - identifiers.add(tgObject.getField("pid.value").getValue().toString()); + if(tgObject.getField(PID)!=null){ + identifiers.add(tgObject.getField(PID).getValue().toString()); } if(tgObject.getField("identifier")!=null){ - identifiers.add(tgObject.getField("identifier").getValue().toString()); + identifiers.add(tgObject.getField(IDENTIFIER).getValue().toString()); } /* * DC-Languages */ - if(tgObject.getField("edition.language")!=null){ - languages.add(tgObject.getField("edition.language").getValue().toString()); + if(tgObject.getField(EDITION_LANGUAGE)!=null){ + languages.add(tgObject.getField(EDITION_LANGUAGE).getValue().toString()); } /* * DC-Publisher */ - if(tgObject.getField("edition.source.bibliographicCitation.publisher")!=null){ - publishers.add(tgObject.getField("edition.source.bibliographicCitation.publisher").getValue().toString()); + if(tgObject.getField(BIBCIT_PUBLISHER)!=null){ + publishers.add(tgObject.getField(BIBCIT_PUBLISHER).getValue().toString()); } /* * DC-Relation */ - relations.add(tgObject.getField("project.id").getValue().toString()); + relations.add(tgObject.getField(PROJECT_ID).getValue().toString()); - if(tgObject.getField("relations.isDerivedFrom")!=null){ - relations.add(tgObject.getField("relations.isDerivedFrom").getValue().toString()); + if(tgObject.getField(IS_DERIVED_FROM)!=null){ + relations.add(tgObject.getField(IS_DERIVED_FROM).getValue().toString()); } //relations.add(aggregatorURL.concat(tgObject.getField("textgridUri").getValue().toString())); @@ -158,8 +197,8 @@ public class RecordDeliverer { * DC-Rights */ - if(tgObject.getField("edition.license.licenseUri")!=null){ - rights.add(tgObject.getField("edition.license.licenseUri").getValue().toString()); + if(tgObject.getField(EDITION_LICENSEURI)!=null){ + rights.add(tgObject.getField(EDITION_LICENSEURI).getValue().toString()); } /* @@ -234,44 +273,52 @@ public class RecordDeliverer { public void furtherDCElements(String id){ - System.out.println("yo"); + GetRequestBuilder getWorkValues = oaiEsClient.getOaiESClient().prepareGet() .setIndex(oaiEsClient.getEsIndex()) .setType(oaiEsClient.getEsType()) .setId(id) - .setFields("created", - "work.abstract", "relations.isDerivedFrom", "textgridUri", - "work.genre","title", "work.type","work.spatial.value", "work.temporal.value", - "work.agent.value", "work.subject.id.value"); + .setFields(CREATED, WORK_ABSTRACT, IS_DERIVED_FROM, URI, + WORK_GENRE, TITLE, WORK_TYPE, WORK_SPATIAL, + WORK_TEMPORAL, WORK_AGENT, WORK_ID); GetResponse responseWorkValues = getWorkValues.execute().actionGet(); - /** + /* * DC-Coverages */ - if(responseWorkValues.getField("work.spatial.value")!=null){ - coverages.add(responseWorkValues.getField("work.spatial.value").getValue().toString()); - coverages.add(responseWorkValues.getField("work.temporal.value").getValue().toString()); + if (responseWorkValues.getField(WORK_SPATIAL) != null) { + coverages.add(responseWorkValues.getField(WORK_SPATIAL) + .getValue().toString()); + } + if (responseWorkValues.getField(WORK_TEMPORAL) != null) { + coverages.add(responseWorkValues.getField(WORK_TEMPORAL) + .getValue().toString()); } - /** + /* * DC-Creators */ - if(responseWorkValues.getField("work.agent.value")!=null){ - creators.add(responseWorkValues.getField("work.agent.value").getValue().toString()); + if (responseWorkValues.getField(WORK_AGENT) != null) { + creators.add(responseWorkValues.getField(WORK_AGENT).getValue() + .toString()); } - String singleDate = responseWorkValues.getField("created").getValue().toString(); + //String singleDate = responseWorkValues.getField("created").getValue().toString(); /* * DC-Date */ try { - dates.add(OAIPMHUtillities.convertDateFormat(singleDate).toXMLFormat()); + if (responseWorkValues.getField(CREATED) != null) { + dates.add(OAIPMHUtillities.convertDateFormat( + responseWorkValues.getField(CREATED).getValue() + .toString()).toXMLFormat()); + } } catch (ParseException e) { log.debug(e); } catch (DatatypeConfigurationException e) { @@ -281,35 +328,46 @@ public class RecordDeliverer { /* * DC-Description */ - if(responseWorkValues.getField("work.abstract")!=null){ - descriptions.add(responseWorkValues.getField("work.abstract").getValue().toString()); + if (responseWorkValues.getField(WORK_ABSTRACT) != null) { + descriptions.add(responseWorkValues.getField(WORK_ABSTRACT) + .getValue().toString()); } /* * DC-Relation */ - if(responseWorkValues.getField("relations.isDerivedFrom")!=null){ - relations.add(responseWorkValues.getField("relations.isDerivedFrom").getValue().toString()); + if (responseWorkValues.getField(IS_DERIVED_FROM) != null) { + relations.add(responseWorkValues.getField(IS_DERIVED_FROM) + .getValue().toString()); + } + if (responseWorkValues.getField(TITLE) != null) { + relations.add(responseWorkValues.getField(TITLE).getValue() + .toString()); + } + if (responseWorkValues.getField(URI) != null) { + relations.add(responseWorkValues.getField(URI).getValue() + .toString()); } - relations.add(responseWorkValues.getField("title").getValue().toString()); - relations.add(responseWorkValues.getField("textgridUri").getValue().toString()); /* * DC-Subject */ - if(responseWorkValues.getField("work.subject.id.value")!=null){ - subjects.add(responseWorkValues.getField("work.subject.id.value").getValue().toString()); + if (responseWorkValues.getField(WORK_ID) != null) { + subjects.add(responseWorkValues.getField(WORK_ID).getValue() + .toString()); } /* * DC-Type */ - if(responseWorkValues.getField("work.genre")!=null){ - types.add(responseWorkValues.getField("work.genre").getValue().toString()); + if (responseWorkValues.getField(WORK_GENRE) != null) { + types.add(responseWorkValues.getField(WORK_GENRE).getValue() + .toString()); } - if(responseWorkValues.getField("work.type")!=null){ - types.add(responseWorkValues.getField("work.type").getValue().toString()); + if (responseWorkValues.getField(WORK_TYPE) != null) { + types.add(responseWorkValues.getField(WORK_TYPE).getValue() + .toString()); } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java index a554301d..8ad5acc9 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java @@ -121,7 +121,7 @@ public class RecordListDeliverer { QueryBuilder queryBuilder = QueryBuilders.rangeQuery(CREATED) .from(from).to(to); - + SearchRequestBuilder getRecordList = oaiEsClient .getOaiESClient() .prepareSearch(oaiEsClient.getEsIndex()) @@ -182,14 +182,11 @@ public class RecordListDeliverer { /* * DC-Contributor */ - // System.out.println(hit.getFields().get("textgridUri").values().get(0).toString()); + if (hit.getFields().get(EDITION_AGENT) != null) { - // String contributorUnformatted = - // hit.getFields().get(AGENT).values().get(0).toString(); contributors.add(hit.getFields() .get(DATA_CONTRIBUTOR).values().get(0) .toString()); - // contributors.add(contributorUnformatted); } /* @@ -465,6 +462,280 @@ public class RecordListDeliverer { } } + + public ListRecordsType getRecordsWithSet(String from, String to, String set) { + + String[] setParts = set.split(":"); + + if(setParts[0].equals("project")){ + setParts[0] = setParts[0].concat(".value"); + } + + QueryBuilder rangeQuery = QueryBuilders.rangeQuery(CREATED) + .from(from).to(to); + + QueryBuilder matchQuery = QueryBuilders.matchPhraseQuery(setParts[0], setParts[1]); + + QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery); + + + + + SearchRequestBuilder getRecordList = oaiEsClient + .getOaiESClient() + .prepareSearch(oaiEsClient.getEsIndex()) + .setTypes(oaiEsClient.getEsType()) + .addFields(FORMAT, CREATED, EDITION_ISEDITIONOF, EDITION_AGENT, + DATA_CONTRIBUTOR, URI, PROJECT_ID, IS_DERIVED_FROM, + RDITION_LICENSEURI, TITLE, EDITION_LANGUAGE, PID, + BIBCIT_AUTHOR, BIBCIT_EDITOR, BIBCIT_TITLE, + BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, + BIBCIT_SERIES, BIBCIT_VOLUME, BIBCIT_ISSUE, + BIBCIT_EPAGE, BIBCIT_SPAGE, BIBCIT_BIBID) + .setQuery(boolQuery) + .setPostFilter(FilterBuilders.existsFilter(EDITION_ISEDITIONOF)) + .setSize(10); + + + System.out.println(getRecordList); + + SearchResponse getRecordListItems = getRecordList.execute().actionGet(); + + + + if (getRecordListItems != null + && getRecordListItems.getHits().totalHits() > 0) { + + for (SearchHit hit : getRecordListItems.getHits().getHits()) { + + Map<String, SearchHitField> hits = hit.getFields(); + + // Only if we have a search response AND a hit field map... + if (hit != null && hits != null) { + + if (hit.getFields().get(FORMAT).values().get(0).toString() + .equals(TextGridMimetypes.EDITION)) { + + ObjectFactory of = new ObjectFactory(); + OaiDcType odt = new OaiDcType(); + DublinCoreBuilder newDbc = new DublinCoreBuilder(odt, + of); + MetadataType metadata = new MetadataType(); + RecordType record = new RecordType(); + HeaderType recordHeader = new HeaderType(); + + String datestamp = hit.getFields().get(CREATED) + .getValue().toString(); + + try { + datestamp = OAIPMHUtillities.convertDateFormat( + datestamp).toXMLFormat(); + } catch (ParseException e1) { + log.debug(e1); + } catch (DatatypeConfigurationException e1) { + log.debug(e1); + } + + String workUri = hit.getFields() + .get(EDITION_ISEDITIONOF).values().get(0) + .toString(); + workUri = workUri + .substring(TGConstants.TG_ITEM_IDENTIFIER_PREFIX + .length()); + + /* + * DC-Contributor + */ + // System.out.println(hit.getFields().get("textgridUri").values().get(0).toString()); + if (hit.getFields().get(EDITION_AGENT) != null) { + // String contributorUnformatted = + // hit.getFields().get(AGENT).values().get(0).toString(); + contributors.add(hit.getFields() + .get(DATA_CONTRIBUTOR).values().get(0) + .toString()); + // contributors.add(contributorUnformatted); + } + + /* + * DC-Format + */ + if (hit.getFields().get(FORMAT) != null) { + formats.add(hit.getFields().get(FORMAT).values() + .get(0).toString()); + } + + /* + * DC-Identifier + */ + String identifier = ""; + if (hit.getFields().get(URI) != null) { + identifiers.add(hit.getFields().get(URI).values() + .get(0).toString()); + identifier = identifiers.get(0); + } + if (hit.getFields().get(PID) != null) { + identifiers.add(hit.getFields().get(PID).values() + .get(0).toString()); + } + if (hit.getFields().get(IDENTIFIER) != null) { + identifiers.add(hit.getFields().get(IDENTIFIER) + .values().get(0).toString()); + } + + /* + * DC-Languages + */ + if (hit.getFields().get(EDITION_LANGUAGE) != null) { + languages.add(hit.getFields().get(EDITION_LANGUAGE) + .values().get(0).toString()); + } + + /* + * DC-Publisher + */ + if (hit.getFields().get(BIBCIT_PUBLISHER) != null) { + publishers.add(hit.getFields() + .get(BIBCIT_PUBLISHER).values().get(0) + .toString()); + } + + /* + * DC-Relation + */ + if (hit.getFields().get(PROJECT_ID) != null) { + relations.add(hit.getFields().get(PROJECT_ID) + .values().get(0).toString()); + } + if (hit.getFields().get(IS_DERIVED_FROM) != null) { + relations.add(hit.getFields().get(IS_DERIVED_FROM) + .values().get(0).toString()); + } + /*if (hit.getFields().get(URI) != null) { + relations.add(aggregatorURL.concat(hit.getFields() + .get(URI).values().get(0).toString())); + }*/ + + /* + * DC-Rights + */ + // System.out.println(hit.getFields().get("textgridUri").values().get(0).toString()); + if (hit.getFields().get(RDITION_LICENSEURI) != null) { + rights.add(hit.getFields().get(RDITION_LICENSEURI) + .values().get(0).toString()); + } + + /* + * DC-Source + */ + if (hit.getFields().get(BIBCIT_AUTHOR) != null) { + sources.add(hit.getFields().get(BIBCIT_AUTHOR) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_EDITOR) != null) { + sources.add(hit.getFields().get(BIBCIT_EDITOR) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_TITLE) != null) { + sources.add(hit.getFields().get(BIBCIT_TITLE) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_PLACEPUB) != null) { + sources.add(hit.getFields().get(BIBCIT_PLACEPUB) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_PUBLISHER) != null) { + sources.add(hit.getFields().get(BIBCIT_PUBLISHER) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_NO) != null) { + sources.add(hit.getFields().get(BIBCIT_NO).values() + .get(0).toString()); + } + if (hit.getFields().get(BIBCIT_SERIES) != null) { + sources.add(hit.getFields().get(BIBCIT_SERIES) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_VOLUME) != null) { + sources.add(hit.getFields().get(BIBCIT_VOLUME) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_ISSUE) != null) { + sources.add(hit.getFields().get(BIBCIT_ISSUE) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_SPAGE) != null) { + sources.add(hit.getFields().get(BIBCIT_SPAGE) + .values().get(0).toString()); + } + if (hit.getFields().get(BIBCIT_EPAGE) != null) { + sources.add(hit.getFields().get(BIBCIT_EPAGE) + .values().get(0).toString()); + } + if (hit.getFields().get(IDENTIFIER) != null) { + sources.add(hit.getFields().get(BIBCIT_EPAGE) + .values().get(0).toString()); + } + + /* + * DC-Title + */ + if (hit.getFields().get(TITLE) != null) { + for (int i = 0; i < hit.getFields().get(TITLE) + .getValues().size(); i++) { + titles.add(hit.getFields().get(TITLE).values() + .get(i).toString()); + } + } + + /* + * More DC elements + */ + furtherDCElements(workUri, oaiEsClient); + setDCObject(odt, of); + + /* + * Set identifier and date + */ + if (!identifiers.isEmpty()) { + recordHeader.setIdentifier(identifiers.get(0)); + } + // TODO Why take the 0th date here? + if (!dates.isEmpty()) { + recordHeader.setDatestamp(dates.get(0)); + } + + /* + * Clear list and create record list + */ + listClearer(); + + metadata = newDbc.getDC(); + record.setMetadata(metadata); + + HeaderType header = new HeaderType(); + header.setDatestamp(datestamp); + header.setIdentifier(identifier); + header.getSetSpec().add(set); + + record.setHeader(header); + recordList.getRecord().add(record); + } + } + } + } + //fieldLoader(getRecordList, set); + + return recordList; + } + + public void fieldLoader(SearchRequestBuilder getRecordList, String set){ + + + + + } + + /** * @param odt * @param of 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 13c67390..ba84ba4f 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -85,7 +85,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testListSets() throws ParseException { JAXBElement<OAIPMHType> r = testRequest.getRequest("ListSets", "", "", @@ -96,7 +96,7 @@ public class OaiPmhTest { @Test - //@Ignore + @Ignore public void testListIdentifiers() throws ParseException{ JAXBElement<OAIPMHType> r = testRequest.getRequest("ListIdentifiers", "", @@ -142,7 +142,7 @@ public class OaiPmhTest { public void testGetRequestGetRecordError() throws ParseException{ System.out.println("Test for the verb \"GetRecord\" with succesfull response" ); JAXBElement<OAIPMHType> t = testRequest.getRequest("GetRecord", - "vqn0.0", "oai_dc", "", "", "", ""); JAXB.marshal(t, System.out); + "textgrid:vqn0.0", "oai_dc", "", "", "", ""); JAXB.marshal(t, System.out); System.out.println("-----------------------------------\n"); } @@ -173,7 +173,7 @@ public class OaiPmhTest { @Test - //@Ignore + @Ignore public void testListIdentifierSets() throws ParseException { System.out.println("Test for the verb \"GetRecord\" with succesfull response"); JAXBElement<OAIPMHType> p = testRequest.getRequest("ListIdentifiers", @@ -182,4 +182,15 @@ public class OaiPmhTest { System.out.println("-----------------------------------\n"); } + + @Test + @Ignore + public void testListRecordSets() throws ParseException { + System.out.println("Test for the verb \"GetRecord\" with succesfull response"); + JAXBElement<OAIPMHType> p = testRequest.getRequest("ListRecords", + "", "oai_dc", "project.value:St. Matthias Test 07", "", "", ""); + JAXB.marshal(p, System.out); + System.out.println("-----------------------------------\n"); + + } } diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index 6db26062..379dd689 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -4,12 +4,12 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>1.3.2-SNAPSHOT</version> + <version>1.3.3-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> <packaging>war</packaging> - <version>1.3.2-SNAPSHOT</version> + <version>1.3.3-SNAPSHOT</version> <name>TextGrid :: OAI-PMH :: Webapp</name> <url>http://maven.apache.org</url> <profiles> diff --git a/pom.xml b/pom.xml index 2b5128d7..4b075a33 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh</artifactId> - <version>1.3.2-SNAPSHOT</version> + <version>1.3.3-SNAPSHOT</version> <packaging>pom</packaging> <name>TextGrid :: TG-OAI-PMH :: Parent</name> <properties> -- GitLab