Skip to content
Snippets Groups Projects
Commit 4421de89 authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

mc

parent 327f675d
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,6 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.json.JSONObject;
import org.springframework.util.SystemPropertyUtils;
import info.textgrid.middleware.oaipmh.HeaderType;
import info.textgrid.middleware.oaipmh.ListRecordsType;
import info.textgrid.middleware.oaipmh.MetadataType;
......@@ -157,8 +156,10 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
DublinCoreBuilder dublinCoreBuilder = new DublinCoreBuilder();
if (this.dariah == true) {
// All objects!
recordFilter = query;
} else {
// All editions only!
recordFilter = QueryBuilders.boolQuery().must(query)
.must(QueryBuilders.matchPhraseQuery(this.formatField, this.formatToFilter));
}
......@@ -171,7 +172,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
searchSourceBuilder.query(recordFilter);
searchSourceBuilder.size(100);
searchRequest.source(searchSourceBuilder);
if (resumptionToken != null) {
SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken);
scrollRequest.scroll(TimeValue.timeValueSeconds(LIFETIME_RES_TOKEN));
......@@ -220,76 +221,84 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
} catch (DatatypeConfigurationException e) {
log.debug(e);
}
// ES6
JSONObject json = new JSONObject(hit.getSourceAsMap());
this.modifiedValue = OAIPMHUtilities.fieldLoader(json, this.modifiedField);
// OLD
//this.modifiedValue = hit.getSourceAsMap().get(this.modifiedField).toString();
// this.modifiedValue = hit.getSourceAsMap().get(this.modifiedField).toString();
// TextGrid search!
String workUri = "";
String[] blaFields = new String[] {this.relationToFurtherMetadataObject};
if (this.textgrid == true && hit.getSourceAsMap().get(this.formatField)
.toString().equals(this.formatToFilter)) {
String setSpec = "project:" + DublinCoreFieldLoader.fillList(hit, TGConstants.RELATIONS_LIST).get(0);
if (DublinCoreFieldLoader.fillList(hit, blaFields).get(0) != null) {
workUri = DublinCoreFieldLoader.fillList(hit, blaFields).get(0)
.substring(this.repositoryObjectURIPrefix.length());
if (!workUri.endsWith(".0")) {
workUri = workUri.concat(".0");
if (this.textgrid) {
String workUri = "";
String[] blaFields = new String[] {this.relationToFurtherMetadataObject};
if (hit.getSourceAsMap().get(this.formatField).toString().equals(this.formatToFilter)) {
String setSpec = "project:"
+ DublinCoreFieldLoader.fillList(hit, TGConstants.RELATIONS_LIST).get(0);
if (DublinCoreFieldLoader.fillList(hit, blaFields).get(0) != null) {
workUri = DublinCoreFieldLoader.fillList(hit, blaFields).get(0)
.substring(this.repositoryObjectURIPrefix.length());
if (!workUri.endsWith(".0")) {
workUri = workUri.concat(".0");
}
}
try {
dublinCoreBuilder = putContentIntoDCFieldLists(hit,
furtherDCElements(workUri, OAI_ESClient.getEsClient()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DatatypeConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
buildRecord(recordList, set,
hit.getSourceAsMap().get(this.identifierField).toString(), dublinCoreBuilder,
setSpec);
}
}
// DARIAH search!
else if (this.dariah == true) {
System.out.println(" ## kramsblablaZWO --> "
+ DublinCoreFieldLoader.fillList(hit, DARIAHConstants.IDENTIFIER_LIST));
String setSpec = "hdl:"
+ DublinCoreFieldLoader.fillList(hit, DARIAHConstants.IDENTIFIER_LIST).get(0);
System.out.println(" ## setSpec --> " + setSpec);
try {
dublinCoreBuilder = putContentIntoDCFieldLists(hit,
furtherDCElements(workUri, OAI_ESClient.getEsClient()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DatatypeConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dublinCoreBuilder = putContentIntoDCFieldLists2(hit,
furtherDCElements(hit.getId(), OAI_ESClient.getEsClient()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DatatypeConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
buildRecord(recordList, set, hit.getSourceAsMap().get(this.identifierField).toString(),
dublinCoreBuilder, setSpec);
}
if (this.dariah == true) {
String setSpec = "hdl:" + DublinCoreFieldLoader.fillList(hit, DARIAHConstants.IDENTIFIER_LIST).get(0);
System.out.println(" ## setSpec --> " + setSpec);
try {
dublinCoreBuilder = putContentIntoDCFieldLists2(hit,
furtherDCElements(hit.getId(), OAI_ESClient.getEsClient()));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DatatypeConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
buildRecord(recordList, set,
hit.getSourceAsMap().get(this.identifierField).toString(), dublinCoreBuilder, setSpec);
}
}
}
// Check the need for a resumption token!
ResumptionTokenType resTokenForResponse = OAIPMHUtilities.getResumptionToken(
completeListSize, resumptionToken, cursorCollector, scrollID, this.searchResponseSize, i);
//if (resTokenForResponse != null) {
recordList.setResumptionToken(resTokenForResponse);
System.out.println("RESTOKEN: ");
System.out.println(recordList.getResumptionToken());
//}
// if (resTokenForResponse != null) {
recordList.setResumptionToken(resTokenForResponse);
System.out.println("RESTOKEN: ");
System.out.println(recordList.getResumptionToken());
// }
} else {
setFoundItems(false);
......@@ -300,8 +309,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
* @param hit
* @param responseWorkValues
* @return
* @throws DatatypeConfigurationException
* @throws ParseException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
public DublinCoreBuilder putContentIntoDCFieldLists(SearchHit hit,
GetResponse responseWorkValues) throws ParseException, DatatypeConfigurationException {
......@@ -335,8 +344,8 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
* @param hit
* @param responseWorkValues
* @return
* @throws DatatypeConfigurationException
* @throws ParseException
* @throws DatatypeConfigurationException
* @throws ParseException
*/
public DublinCoreBuilder putContentIntoDCFieldLists2(SearchHit hit,
GetResponse responseWorkValues) throws ParseException, DatatypeConfigurationException {
......@@ -410,7 +419,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
if (this.textgrid == true) {
String[] setParts = set.split(":");
if (setParts[0].equals("project")) {
queryField = "project.id";
queryField = "project.id";
valueField = setParts[1];
}
}
......@@ -419,19 +428,20 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
QueryBuilder boolQuery = QueryBuilders.boolQuery().must(rangeQuery).must(matchQuery);
System.out.println(boolQuery);
query = boolQuery;
} else {
query = rangeQuery;
}
try {
System.out.println(" ## getRecords() --> " + (query!=null?query.getName():"query=NULL") +
" - " + (recordList!=null?recordList:"recordList=NULL") +
" - " + (resumptionToken!=null?resumptionToken:"resumptionToken=NULL")
+ " - " + (set!=null?set:"set:NULL"));
System.out.println(" ## getRecords() --> "
+ (query != null ? "queryName=" + query.getName() : "query=NULL") + " - "
+ (recordList != null ? recordList : "recordList=NULL") + " - "
+ (resumptionToken != null ? resumptionToken : "resumptionToken=NULL") + " - "
+ (set != null ? set : "set=NULL"));
fetchFields(query, recordList, resumptionToken, set);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
......@@ -467,7 +477,7 @@ public class RecordListDelivererDC extends RecordListDelivererAbstract {
}
header.setIdentifier(identifierForHeader);
// Set set :-)
if (set != null) {
header.getSetSpec().add(setSpec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment