diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 4cd3edad5a8b74e293480882fe2ade1115d639e9..ef0e740f09ef3c43ef598577651654effc697949 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.6-SNAPSHOT</version> + <version>1.3.7-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> - <version>1.3.6-SNAPSHOT</version> + <version>1.3.7-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/OAIPMHUtillities.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java index 7cc785e746bf026aaefa730493592944e7394b00..66ebb64e7cae1f563c63b9c73e2d27ee323bb46f 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java @@ -110,4 +110,6 @@ public class OAIPMHUtillities { return dateOutputAsString; } + + } 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 e7954349ece0e760d55c590c73fb2cd869e17f6b..04922f3365d4f730578ec0a8af8b180e584ca2ca 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordListDeliverer.java @@ -12,8 +12,6 @@ import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.index.get.GetField; -import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; @@ -34,7 +32,7 @@ import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; * TODO Care about repeatable fields as done in TITLE! */ -public class RecordListDeliverer{ +public class RecordListDeliverer { //private static final String BIBCIT_BIBID = "edition.source.bibliographicCitation.bibidentifier"; @@ -94,7 +92,7 @@ public class RecordListDeliverer{ * @param esClient */ - public void furtherDCElements(String id, OAI_ESClient esClient) { + public GetResponse furtherDCElements(String id, OAI_ESClient esClient) { GetRequestBuilder getWorkValues = esClient .getOaiESClient() @@ -105,19 +103,9 @@ public class RecordListDeliverer{ .setFields(TGConstants.TGWorkFields); GetResponse responseWorkValues = getWorkValues.execute().actionGet(); - Map<String, GetField> fieldsMap = responseWorkValues.getFields(); - - // Only if a value AND a fields map is existing... - if (responseWorkValues != null && fieldsMap != null) { - - setCoverage(responseWorkValues, TGConstants.COVERAGE_LIST); - setCreator(responseWorkValues, TGConstants.WORK_AGENT); - setDate(responseWorkValues, TGConstants.DATE_LIST); - setDescription(responseWorkValues, TGConstants.DESCRIPTION_LIST); - setRelationForWork(responseWorkValues, TGConstants.RELATIONS_FOR_WORK_LIST); - setSubject(responseWorkValues, TGConstants.SUBJECT_LIST); - setType(responseWorkValues, TGConstants.TYPE_LIST); - } + + + return responseWorkValues; } /** @@ -134,7 +122,6 @@ public class RecordListDeliverer{ .setTypes(oaiEsClient.getEsType()) .addFields(fields) .setQuery(query) - .setPostFilter(FilterBuilders.existsFilter(TGConstants.EDITION_ISEDITIONOF)) .setSize(1000); SearchResponse getRecordListItems = getRecordList.execute().actionGet(); @@ -149,13 +136,14 @@ public class RecordListDeliverer{ // Only if we have a search response AND a hit field map... if (hit != null && hits != null) { + //The response should also contains the editions if (hit.getFields().get(TGConstants.FORMAT).values().get(0).toString() .equals(TextGridMimetypes.EDITION)) { - String datestamp = hit.getFields().get(TGConstants.CREATED) - .getValue().toString(); - + //The datestamp from textgrid is in not compatible format so it has to be transformed try { + String datestamp = hit.getFields().get(TGConstants.CREATED) + .getValue().toString(); datestamp = OAIPMHUtillities.convertDateFormat( datestamp).toXMLFormat(); } catch (ParseException e1) { @@ -164,23 +152,18 @@ public class RecordListDeliverer{ log.debug(e1); } - setContributor(hit, TGConstants.CONTRIBUTOR_LIST); - setFormat(hit, TGConstants.FORMAT_LIST); - setIdentifier(hit, TGConstants.FORMAT_LIST); - setLanguage(hit, TGConstants.LANGUAGE_LIST); - setPublisher(hit, TGConstants.PUBLISHER_LIST); - setRelation(hit, TGConstants.RELATIONS_LIST); - setRights(hit, TGConstants.RIGHTS_LIST); - setSources(hit, TGConstants.SOURCE_LIST); - setTitle(hit, TGConstants.TITLE_LIST); - - //Uri of the work Object to get further DC-Fields - String workUri = hit.getFields() + //Uri of the work Object to get further DC-Fields (only necessary if metadata for the object + //is in an other object than just the edition + + if(TGConstants.furtherElements == true){ + String workUri = hit.getFields() .get(TGConstants.EDITION_ISEDITIONOF).values().get(0) .toString().substring(TGConstants.TG_ITEM_IDENTIFIER_PREFIX .length()); + + putContentIntoDCFieldLists(hit, furtherDCElements(workUri, oaiEsClient)); + } - furtherDCElements(workUri, oaiEsClient); buildRecord(); listClearer(); } @@ -189,6 +172,27 @@ public class RecordListDeliverer{ } } + public void putContentIntoDCFieldLists(SearchHit hit, GetResponse responseWorkValues){ + + contributors = DublinCoreFieldLoader.setContributor(hit, TGConstants.CONTRIBUTOR_LIST); + formats = DublinCoreFieldLoader.setFormat(hit, TGConstants.FORMAT_LIST); + identifiers = DublinCoreFieldLoader.setIdentifier(hit, TGConstants.IDENTIFIER_LIST); + languages = DublinCoreFieldLoader.setLanguage(hit, TGConstants.LANGUAGE_LIST); + publishers = DublinCoreFieldLoader.setPublisher(hit, TGConstants.PUBLISHER_LIST); + relations = DublinCoreFieldLoader.setRelation(hit, TGConstants.RELATIONS_LIST); + rights = DublinCoreFieldLoader.setRights(hit, TGConstants.RIGHTS_LIST); + sources = DublinCoreFieldLoader.setSources(hit, TGConstants.SOURCE_LIST); + titles = DublinCoreFieldLoader.setTitle(hit, TGConstants.TITLE_LIST); + coverages = DublinCoreFieldLoader.setCoverage(responseWorkValues, TGConstants.COVERAGE_LIST); + creators = DublinCoreFieldLoader.setCreator(responseWorkValues, TGConstants.WORK_AGENT); + dates = DublinCoreFieldLoader.setDate(responseWorkValues, TGConstants.DATE_LIST); + descriptions = DublinCoreFieldLoader.setDescription(responseWorkValues, TGConstants.DESCRIPTION_LIST); + relations = DublinCoreFieldLoader.setRelationForWork(responseWorkValues, TGConstants.RELATIONS_FOR_WORK_LIST); + subjects = DublinCoreFieldLoader.setSubject(responseWorkValues, TGConstants.SUBJECT_LIST); + types = DublinCoreFieldLoader.setType(responseWorkValues, TGConstants.TYPE_LIST); + + } + public RecordType buildRecord(){ ObjectFactory of = new ObjectFactory(); @@ -222,8 +226,7 @@ public class RecordListDeliverer{ QueryBuilder query; QueryBuilder rangeQuery = QueryBuilders.rangeQuery(TGConstants.CREATED).from(from).to(to); - - + if(set!=null){ this.set = set; String[] setParts = set.split(":"); @@ -260,187 +263,7 @@ public class RecordListDeliverer{ return header; } - public void setContributor(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - contributors.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setCreator(GetResponse responseWorkValues, String field){ - - if (responseWorkValues.getField(field) != null) { - creators.add(responseWorkValues.getField(field).getValue() - .toString()); - } - } - - - public void setCoverage(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - if (responseWorkValues.getField(field) != null) { - coverages.add(responseWorkValues.getField(field) - .getValue().toString()); - } - } - } - - public void setDate(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - try { - if (responseWorkValues.getField(field) != null) { - dates.add(OAIPMHUtillities.convertDateFormat( - responseWorkValues.getField(field).getValue() - .toString()).toXMLFormat()); - } - } catch (ParseException e) { - log.debug(e); - } catch (DatatypeConfigurationException e) { - log.debug(e); - } - } - - } - - public void setDescription(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - if (responseWorkValues.getField(field) != null) { - descriptions.add(responseWorkValues.getField(field) - .getValue().toString()); - } - } - } - - public void setFormat(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - formats.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setIdentifier(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - identifiers.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setLanguage(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - languages.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setPublisher(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - publishers.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setRelation(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - relations.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setRelationForWork(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - if (responseWorkValues.getField(field) != null) { - descriptions.add(responseWorkValues.getField(field) - .getValue().toString()); - } - } - - } - - public void setRights(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - rights.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setSources(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - sources.add(hit.getFields().get(field) - .values().get(0).toString()); - } - } - } - - public void setSubject(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - if (responseWorkValues.getField(field) != null) { - subjects.add(responseWorkValues.getField(field) - .getValue().toString()); - } - } - } - - public void setTitle(SearchHit hit, String[] values){ - - for(String field : values){ - if (hit.getFields().get(field) != null) { - for (int i = 0; i < hit.getFields().get(field) - .getValues().size(); i++) { - titles.add(hit.getFields().get(field).values() - .get(i).toString()); - } - } - } - } - - public void setType(GetResponse responseWorkValues, String[] values){ - - for(String field : values){ - if (responseWorkValues.getField(field) != null) { - types.add(responseWorkValues.getField(field) - .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()); - }*/ - - } /** * @param odt @@ -450,7 +273,7 @@ public class RecordListDeliverer{ public DublinCoreBuilder setDCObject(OaiDcType odt, ObjectFactory of) { DublinCoreBuilder dbc = new DublinCoreBuilder(odt, of); - + dbc.setContributor(this.contributors); dbc.setCoverage(this.coverages); dbc.setCreator(this.creators); 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 1782bb907065d66a6903d917e2945ffe355b7592..3d4c2c88a95a6f6e704d468e1cd70e4f2d2a8b79 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/TGConstants.java @@ -17,6 +17,8 @@ public final class TGConstants { //not called } + public static boolean furtherElements = true; + public static final String TG_ITEM_IDENTIFIER_PREFIX = "textgrid:"; public static final List<String> TEXTGRID_REP_ADMIN_CONTACT = Arrays.asList("textgrid-support@gwdg.de"); @@ -80,7 +82,7 @@ public final class TGConstants { EDITION_LANGUAGE, BIBCIT_AUTHOR, BIBCIT_EDITOR, BIBCIT_TITLE, BIBCIT_PLACEPUB, BIBCIT_PUBLISHER, BIBCIT_NO, BIBCIT_SERIES, BIBCIT_VOLUME, BIBCIT_ISSUE, BIBCIT_EPAGE, BIBCIT_SPAGE, BIBCIT_BIBID, WORK_ABSTRACT, WORK_GENRE, WORK_TYPE, - WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT, WORK_ID}; + WORK_SPATIAL, WORK_TEMPORAL, WORK_AGENT}; public static final String[] TGWorkFields = {CREATED, WORK_ABSTRACT, IS_DERIVED_FROM, URI, WORK_GENRE, TITLE, WORK_TYPE, WORK_SPATIAL, diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index a4fbb8b34d1ffc92f68646943a88d3b485ad5cf3..a907e1729aa00da5f1f680d1eb9582f1a82dcf87 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.6-SNAPSHOT</version> + <version>1.3.7-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> <packaging>war</packaging> - <version>1.3.6-SNAPSHOT</version> + <version>1.3.7-SNAPSHOT</version> <name>TextGrid :: OAI-PMH :: Webapp</name> <url>http://maven.apache.org</url> <profiles> diff --git a/pom.xml b/pom.xml index f553ad780921e3ac0a0cda37872b4b37e3c05463..c39ea7da0cb0f0df01fa5bbe0d58eadb4908326c 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.6-SNAPSHOT</version> + <version>1.3.7-SNAPSHOT</version> <packaging>pom</packaging> <name>TextGrid :: TG-OAI-PMH :: Parent</name> <properties>