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

Implement listsets for dhrep

parent 3243d6c6
No related branches found
No related tags found
No related merge requests found
......@@ -118,21 +118,13 @@ public class SetDeliverer {
}
// Assemble DH ES request.
if (this.dariah) {
AggregationBuilder filterCollection = AggregationBuilders.filter("ttlCollection",
QueryBuilders.boolQuery()
.must(QueryBuilders.matchPhraseQuery("descriptiveMetada.dc:format", TextGridMimetypes.DARIAH_COLLECTION)));
/*AggregationBuilder aggregations = AggregationBuilders
.terms("descriptiveMetadata.dc:format")
.field("descriptiveMetadata.dc:format")
.size(10000);*/
searchSourceBuilder.aggregation(filterCollection);
else if (this.dariah) {
AggregationBuilder filterCollections = AggregationBuilders.filter("collection",
QueryBuilders.boolQuery().must(QueryBuilders.matchPhraseQuery(
"descriptiveMetada.dc:format", TextGridMimetypes.DARIAH_COLLECTION)));
searchSourceBuilder.aggregation(filterCollections);
}
// FIXME Where do we need THIS?
......@@ -165,19 +157,16 @@ public class SetDeliverer {
if (getRecordListItems.getAggregations() != null) {
// ...for TG
if (this.textgrid) {
String projectName = "";
for (Entry<String, Aggregation> entry : getRecordListItems.getAggregations().asMap()
.entrySet()) {
String name = entry.getKey();
if (name.equals("projectsPublic")) {
Filter trytry = getRecordListItems.getAggregations().get("projectsPublic");
Terms trytry2 = trytry.getAggregations().get("projects");
Terms trytry2 = trytry.getAggregations().get("projects");
for (Bucket bentry : trytry2.getBuckets()) {
projectName = bentry.getKey().toString();
String projectName = bentry.getKey().toString();
String[] projectInfos = projectName.split("&");
SetType setsForTextGrid = new SetType();
setsForTextGrid.setSetSpec("project:" + projectInfos[0]);
......@@ -205,62 +194,80 @@ public class SetDeliverer {
// ...for DH
if (this.dariah) {
// for (Entry<String, Aggregation> entry : getRecordListItems.getAggregations().asMap()
// .entrySet()) {
//
// System.out.println(" ## SetDeliverer() ## key " + entry.getKey());
// System.out.println(" ## valname " + entry.getValue().getName());
// System.out.println(" ## valtype " + entry.getValue().getType());
// System.out.println(" ## value " + entry.getValue());
//
// }
for (Entry<String, Aggregation> entry : getRecordListItems.getAggregations().asMap()
.entrySet()) {
System.out.println(" ## SetDeliverer() ## key " + entry.getKey());
System.out.println(" ## valname " + entry.getValue().getName());
System.out.println(" ## valtype " + entry.getValue().getType());
System.out.println(" ## value " + entry.getValue());
}
for (String identifierSetSpec : this.identifier) {
System.out.println(" ## SetDeliverer() ## id " + identifierSetSpec);
String id = identifierSetSpec;
try {
id = URLDecoder.decode(id, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
id = identifierSetSpec.substring(this.repositoryObjectURIPrefix.length());
String[] includes2 = new String[] {this.specField};
String[] excludes2 = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext2 =
new FetchSourceContext(true, includes2, excludes2);
GetRequest getRequest =
new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id)
.fetchSourceContext(fetchSourceContext2);
GetResponse setSpec = null;
String name = entry.getKey();
if (name.equals("collection")) {
Terms filterCollection = getRecordListItems.getAggregations().get("collection");
for (Bucket b : filterCollection.getBuckets()) {
try {
setSpec = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(" ## ID " + b.getKeyAsString());
String setName = "";
if (setSpec != null && setSpec.isExists()) {
if (setSpec.getField(this.specField) != null) {
setName = setSpec.getSourceAsMap().get(this.specField).toString();
SetType newSet = new SetType();
newSet.setSetSpec(b.getKeyAsString());
// newSet.setSetName(projectInfos[1]);
// setList.getSet().add(newSet);
}
}
SetType set = new SetType();
set.setSetName(setName);
set.setSetSpec(this.specFieldPrefix + id);
setList.getSet().add(set);
}
// for (String identifierSetSpec : this.identifier) {
//
// System.out.println(" ## SetDeliverer() ## id " + identifierSetSpec);
//
// String id = identifierSetSpec;
// try {
// id = URLDecoder.decode(id, "UTF-8");
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
//
// id = identifierSetSpec.substring(this.repositoryObjectURIPrefix.length());
//
// String[] includes2 = new String[] {this.specField};
// String[] excludes2 = Strings.EMPTY_ARRAY;
// FetchSourceContext fetchSourceContext2 =
// new FetchSourceContext(true, includes2, excludes2);
//
// GetRequest getRequest =
// new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id)
// .fetchSourceContext(fetchSourceContext2);
// GetResponse setSpec = null;
//
// try {
// setSpec = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT);
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// String setName = "";
// if (setSpec != null && setSpec.isExists()) {
// if (setSpec.getField(this.specField) != null) {
// setName = setSpec.getSourceAsMap().get(this.specField).toString();
// }
// }
//
// SetType set = new SetType();
// set.setSetName(setName);
// set.setSetSpec(this.specFieldPrefix + id);
// setList.getSet().add(set);
// }
}
}
this.identifier.clear();
// this.identifier.clear();
return setList;
}
......
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