Skip to content
Snippets Groups Projects
Commit 0cdfce0c authored by mbrodhu's avatar mbrodhu
Browse files

list sets changes for dariah

parent b9aa1f19
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,11 @@
<parent>
<artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-core</artifactId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DARIAHDE :: OAI-PMH :: Core</name>
<url>http://maven.apache.org</url>
......
......@@ -4,9 +4,9 @@ import info.textgrid.middleware.oaipmh.ListSetsType;
import info.textgrid.middleware.oaipmh.SetType;
import java.util.ArrayList;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.elasticsearch.action.get.GetRequestBuilder;
......@@ -21,8 +21,11 @@ public class SetDeliverer {
private OAI_ESClient oaiEsClient;
public SetDeliverer(OAI_ESClient oaiEsClient) {
public SetDeliverer(OAI_ESClient oaiEsClient, boolean textgrid, boolean dariah) {
this.oaiEsClient = oaiEsClient;
this.textgrid = textgrid;
this.dariah = dariah;
System.out.println(dariah);
}
private Set<String> identifier = new LinkedHashSet<String>();
......@@ -33,8 +36,9 @@ public class SetDeliverer {
private String specField;
private String specFieldPrefix;
private Set<String> project = new LinkedHashSet<String>();
private Set<String> projectID = new LinkedHashSet<String>();
private boolean textgrid= true;
private boolean textgrid;
private boolean dariah;
public ListSetsType setListBuilder() {
......@@ -51,13 +55,18 @@ public class SetDeliverer {
.addField("project.id")
.setSize(100000);
System.out.println("QUERY: " + request);
SearchResponse getRecordListItems = request.execute().actionGet();
for (SearchHit hit : getRecordListItems.getHits().getHits()) {
System.out.println("testitest: " + textgrid);
if(hit.getFields().get(formatField) != null && hit.getFields().get(formatField).value().equals(formatToFilter)) {
System.out.println("testitest1");
this.identifier.add(hit.getFields().get(identifierField).values().get(0).toString());
if(hit.getFields().get(identifierField).values().get(0).toString().startsWith("hdl:")){
System.out.println(hit.getFields().get(identifierField).values().get(0).toString());
this.identifier.add(hit.getFields().get(identifierField).values().get(0).toString());
System.out.println("woohoo");
}
if(textgrid==true){
System.out.println("testitest2");
......@@ -87,23 +96,30 @@ public class SetDeliverer {
}
}
else{
System.out.println("woho");
for (String identifierSetSpec : this.identifier) {
String id = identifierSetSpec;
System.out.println("The id is: " + id);
try {
id = URLDecoder.decode(id, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//System.out.println("The id is: " + id);
if (identifierSetSpec.startsWith(repositoryObjectURIPrefix)) {
System.out.println("1");
id = identifierSetSpec.substring(repositoryObjectURIPrefix.length());
System.out.println("the new id is: " + id);
}
GetRequestBuilder collectionNameById = this.oaiEsClient
.getOaiESClient().prepareGet()
.setIndex(this.oaiEsClient.getEsIndex())
.setType(this.oaiEsClient.getEsType())
.setFields(specField).setId(id);
GetResponse setSpec = collectionNameById.execute().actionGet();
.setFields(specField)
.setId(id);
GetResponse setSpec = collectionNameById.execute().actionGet();
String setName = "";
if(setSpec.isExists()){
if (setSpec != null && setSpec.getField(specField) != null) {
......@@ -115,7 +131,7 @@ public class SetDeliverer {
SetType set = new SetType();
set.setSetName(setName);
set.setSetSpec(specFieldPrefix + ":" + id);
set.setSetSpec(specFieldPrefix + id);
setList.getSet().add(set);
......@@ -172,4 +188,20 @@ public class SetDeliverer {
public void setSpecFieldPrefix(String specFieldPrefix) {
this.specFieldPrefix = specFieldPrefix;
}
public boolean isTextgrid() {
return textgrid;
}
public void setTextgrid(boolean textgrid) {
this.textgrid = textgrid;
}
public boolean isDariah() {
return dariah;
}
public void setDariah(boolean dariah) {
this.dariah = dariah;
}
}
......@@ -40,21 +40,22 @@ public class OaiPmhTest {
oaiEsClient,DARIAHConstants.DARIAHFields,
DARIAHConstants.DARIAHFields, false, true);
private boolean textgrid;
private boolean dariah;
// private RecordListDeliverer recordList = new
// RecordListDeliverer(oaiEsClient, TGConstants.TGFields,
// TGConstants.TGWorkFields, true, false);
private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(
oaiEsClient);
private SetDeliverer setList = new SetDeliverer(oaiEsClient);
private SetDeliverer setListDARIAH = new SetDeliverer(oaiEsClient, false, true);
//private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false);
private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(
oaiEsClient, true, false);
private OAIPMHImpl request = new OAIPMHImpl(oaiEsClient, this.rep,
this.record, this.recordList, this.metadataFormatList,
this.setList, this.identifierList);
this.setListDARIAH, this.identifierList);
/**
* @throws Exception
......@@ -410,7 +411,7 @@ public class OaiPmhTest {
// cregId:hdl:6607/0000-0000-26A5-B
// dariah:collection:6607/0000-0000-26A5-B
JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "",
"oai_dc", "11022/0000-0000-8F60-3", "", "", "");
"oai_dc", "11022/0000-0000-8FA0-A", "", "", "");
JAXB.marshal(r, System.out);
System.out.println("-----------------------------------\n");
}
......@@ -445,16 +446,35 @@ public class OaiPmhTest {
@Test
@Ignore
public void testListSets() throws ParseException {
this.setList.setFormatField("format");
this.setList.setFormatToFilter("text/tg.edition+tg.aggregation+xml");
this.setList.setIdentifierField("textgridUri");
this.setList.setRepositoryObjectURIPrefix("textgrid:");
this.setListDARIAH.setFormatField("format");
this.setListDARIAH.setFormatToFilter("text/tg.edition+tg.aggregation+xml");
this.setListDARIAH.setIdentifierField("textgridUri");
this.setListDARIAH.setRepositoryObjectURIPrefix("textgrid:");
JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "",
"", "", "", "");
JAXB.marshal(r, System.out);
System.out.println("-----------------------------------\n");
}
/**
* @throws ParseException
*/
@Test
//@Ignore
public void testListSetsDARIAH() throws ParseException {
System.out.println("TEST DARIAH");
this.setListDARIAH.setFormatField(DARIAHConstants.FORMAT);
this.setListDARIAH.setFormatToFilter(DARIAHConstants.COLLECTION_MIMETYPE);
this.setListDARIAH.setIdentifierField(DARIAHConstants.IDENTIFIER);
this.setListDARIAH.setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX);
this.setListDARIAH.setSpecField("descriptiveMetadata.dc:title");
this.setListDARIAH.setSpecFieldPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX);
JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "",
"", "", "", "");
JAXB.marshal(r, System.out);
System.out.println("-----------------------------------\n");
}
/**
* @throws ParseException
*/
......
......@@ -4,12 +4,12 @@
<parent>
<artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-webapp</artifactId>
<packaging>war</packaging>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
<name>DARIAHDE :: OAI-PMH :: Webapp</name>
<url>http://maven.apache.org</url>
<profiles>
......
......@@ -165,6 +165,12 @@
<bean id="SetDeliverer" class="info.textgrid.middleware.SetDeliverer">
<constructor-arg ref="ElasticSearchClient" />
<constructor-arg index="2">
<value>${textgrid}</value>
</constructor-arg>
<constructor-arg index="3">
<value>${dariah}</value>
</constructor-arg>
<property name="formatField" value="${formatField}" />
<property name="formatToFilter" value="${formatToFilter}" />
<property name="identifierField" value="${identifierField}" />
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh</artifactId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>DARIAHDE :: OAI-PMH</name>
<properties>
......
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