Skip to content
Snippets Groups Projects
Commit 36c85b33 authored by mbrodhu's avatar mbrodhu
Browse files

better set handling for textgrid

parent d42e1a19
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>oaipmh</artifactId> <artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId> <groupId>info.textgrid.middleware</groupId>
<version>2.5.11-SNAPSHOT</version> <version>2.5.12-SNAPSHOT</version>
</parent> </parent>
<groupId>info.textgrid.middleware</groupId> <groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-core</artifactId> <artifactId>oaipmh-core</artifactId>
......
...@@ -258,15 +258,6 @@ public class IdentifierListDeliverer { ...@@ -258,15 +258,6 @@ public class IdentifierListDeliverer {
return query; return query;
} }
/*public ResumptionTokenType setResToken(BigInteger bi2, BigInteger bi1, String scrollID){
value.setCompleteListSize(bi2);
value.setCursor(bi1);
resumptionToken = scrollID;
value.setValue(resumptionToken);
return value;
}*/
public ListIdentifiersType getLit(ListIdentifiersType lit) { public ListIdentifiersType getLit(ListIdentifiersType lit) {
return lit; return lit;
......
...@@ -2,11 +2,15 @@ package info.textgrid.middleware; ...@@ -2,11 +2,15 @@ package info.textgrid.middleware;
import info.textgrid.middleware.oaipmh.ListSetsType; import info.textgrid.middleware.oaipmh.ListSetsType;
import info.textgrid.middleware.oaipmh.SetType; import info.textgrid.middleware.oaipmh.SetType;
import info.textgrid.utils.sesameclient.SesameClient;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetRequestBuilder;
...@@ -20,6 +24,7 @@ import org.elasticsearch.search.SearchHit; ...@@ -20,6 +24,7 @@ import org.elasticsearch.search.SearchHit;
public class SetDeliverer { public class SetDeliverer {
private OAI_ESClient oaiEsClient; private OAI_ESClient oaiEsClient;
private SesameClient sparqlClient;
public SetDeliverer(OAI_ESClient oaiEsClient, boolean textgrid, boolean dariah) { public SetDeliverer(OAI_ESClient oaiEsClient, boolean textgrid, boolean dariah) {
this.oaiEsClient = oaiEsClient; this.oaiEsClient = oaiEsClient;
...@@ -36,6 +41,7 @@ public class SetDeliverer { ...@@ -36,6 +41,7 @@ public class SetDeliverer {
private String specField; private String specField;
private String specFieldPrefix; private String specFieldPrefix;
private Set<String> project = new LinkedHashSet<String>(); private Set<String> project = new LinkedHashSet<String>();
private static Map<String, String> setSet = new Hashtable<String, String >();
private boolean textgrid; private boolean textgrid;
private boolean dariah; private boolean dariah;
...@@ -68,11 +74,11 @@ public class SetDeliverer { ...@@ -68,11 +74,11 @@ public class SetDeliverer {
//System.out.println("QUERY: " + request); //System.out.println("QUERY: " + request);
SearchResponse getRecordListItems = request.execute().actionGet(); SearchResponse getRecordListItems = request.execute().actionGet();
System.out.println(getRecordListItems); //System.out.println(getRecordListItems);
for (SearchHit hit : getRecordListItems.getHits().getHits()) { for (SearchHit hit : getRecordListItems.getHits().getHits()) {
//System.out.println("HALLO HALLO"); //System.out.println("HALLO HALLO");
//if(hit.getFields().get(formatField) != null && hit.getFields().get(formatField).value().equals(formatToFilter)) { //if(hit.getFields().get(formatField) != null && hit.getFields().get(formatField).value().equals(formatToFilter)) {
System.out.println("IDENTIFIER FIELD: " + identifierField); //System.out.println("IDENTIFIER FIELD: " + identifierField);
if(dariah == true && hit.getFields().get(identifierField).values().get(0).toString().startsWith("hdl:")){ if(dariah == true && hit.getFields().get(identifierField).values().get(0).toString().startsWith("hdl:")){
System.out.println("JUHU"); System.out.println("JUHU");
...@@ -83,9 +89,19 @@ public class SetDeliverer { ...@@ -83,9 +89,19 @@ public class SetDeliverer {
if(textgrid==true){ if(textgrid==true){
//System.out.println("HALLO TEXTGRIT"); //System.out.println("HALLO TEXTGRIT");
String projectName = hit.getFields().get("project.value").values().get(0).toString(); String projectName = hit.getFields().get("project.value").values().get(0).toString();
String projectID = hit.getFields().get("project.id").values().get(0).toString(); String projectID = hit.getFields().get("project.id").values().get(0).toString();
String projectSetSpec = projectName.concat(":").concat(projectID); String projectSetSpec = projectName.concat(":").concat(projectID);
this.project.add(projectSetSpec); this.project.add(projectSetSpec);
//this.setSet.put(projectID, projectName);
/*if(projectID.contains("Enzyklopädien")){
System.out.println("URI: " + hit.getFields().get("textgridUri").values().get(0).toString());
System.out.println("PROJECT ID: " + projectID);
System.out.println("PRJECTNAME: " + projectName);
}*/
/*SetType set = new SetType();
set.setSetName(projectName);
set.setSetSpec("project:" + projectID);
setList.getSet().add(set);*/
} }
} }
...@@ -94,19 +110,43 @@ public class SetDeliverer { ...@@ -94,19 +110,43 @@ public class SetDeliverer {
if(textgrid==true){ if(textgrid==true){
//System.out.println("HALLO GRIT"); //System.out.println("HALLO GRIT");
for(String projectSetSpec : this.project){
Iterator it = setSet.entrySet().iterator();
while(it.hasNext()){
Map.Entry pair = (Map.Entry)it.next();
SetType set = new SetType();
set.setSetName(pair.getKey().toString());
set.setSetSpec(pair.getValue().toString());
setList.getSet().add(set);
}
/*for(String projectSetSpec : this.project){
SetType set = new SetType(); SetType set = new SetType();
String[] projectValues = projectSetSpec.split(":"); String[] projectValues = projectSetSpec.split(":");
String projectName = projectValues[0]; String projectName = projectValues[0];
String projectID = projectValues[1]; String projectID = projectValues[1];
if(!projectID.startsWith("TGPR")){
projectID = projectValues[2];
}
if(projectName.contains("PUBLISH")){
System.out.println("PROJECTD: " + projectID);
System.out.println("PROJECTVALUE: " + projectName);
System.out.println("SETSPEC: " + projectSetSpec);
}
set.setSetName(projectName); set.setSetName(projectName);
set.setSetSpec("project:" + projectID); set.setSetSpec("project:" + projectID);
setList.getSet().add(set); setList.getSet().add(set);
} }*/
} }
else{
if(dariah == true){
for (String identifierSetSpec : this.identifier) { for (String identifierSetSpec : this.identifier) {
String id = identifierSetSpec; String id = identifierSetSpec;
try { try {
...@@ -214,4 +254,12 @@ public class SetDeliverer { ...@@ -214,4 +254,12 @@ public class SetDeliverer {
public void setDariah(boolean dariah) { public void setDariah(boolean dariah) {
this.dariah = dariah; this.dariah = dariah;
} }
public SesameClient getSparqlClient() {
return sparqlClient;
}
public void setSparqlClient(SesameClient sparqlClient) {
this.sparqlClient = sparqlClient;
}
} }
...@@ -6,6 +6,7 @@ import info.textgrid.middleware.oaipmh.DeletedRecordType; ...@@ -6,6 +6,7 @@ import info.textgrid.middleware.oaipmh.DeletedRecordType;
import info.textgrid.middleware.oaipmh.GranularityType; import info.textgrid.middleware.oaipmh.GranularityType;
import info.textgrid.middleware.oaipmh.OAIPMHType; import info.textgrid.middleware.oaipmh.OAIPMHType;
import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes;
import info.textgrid.utils.sesameclient.SesameClient;
import javax.xml.bind.JAXB; import javax.xml.bind.JAXB;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
...@@ -23,6 +24,7 @@ import org.junit.Test; ...@@ -23,6 +24,7 @@ import org.junit.Test;
public class OaiPmhTest { public class OaiPmhTest {
public static OAI_ESClient oaiEsClient; public static OAI_ESClient oaiEsClient;
private static SesameClient sc;
DeletedRecordType bla = DeletedRecordType.NO; DeletedRecordType bla = DeletedRecordType.NO;
GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z;
private RepIdentification rep = new RepIdentification( private RepIdentification rep = new RepIdentification(
...@@ -48,7 +50,7 @@ public class OaiPmhTest { ...@@ -48,7 +50,7 @@ public class OaiPmhTest {
private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false); private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false);
private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, false, true); private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, false, true);
//private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(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.setListDARIAH, this.identifierList); private OAIPMHImpl request = new OAIPMHImpl(oaiEsClient, this.rep, this.record, this.recordList, this.metadataFormatList, this.setListTextGrid, this.identifierList);
/** /**
* @throws Exception * @throws Exception
...@@ -56,8 +58,9 @@ public class OaiPmhTest { ...@@ -56,8 +58,9 @@ public class OaiPmhTest {
@BeforeClass @BeforeClass
public static void setUp() throws Exception { public static void setUp() throws Exception {
//oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); sc = new SesameClient("http://localhost:9091/openrdf-workbench/repositories/textgrid-public");
oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx1-dev-instance");
//oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype");
oaiEsClient.setEsIndex("textgrid-public"); oaiEsClient.setEsIndex("textgrid-public");
oaiEsClient.setEsType("metadata"); oaiEsClient.setEsType("metadata");
//oaiEsClient.setEsIndex("dariahreptest"); //oaiEsClient.setEsIndex("dariahreptest");
...@@ -435,8 +438,9 @@ public class OaiPmhTest { ...@@ -435,8 +438,9 @@ public class OaiPmhTest {
* @throws ParseException * @throws ParseException
*/ */
@Test @Test
@Ignore //@Ignore
public void testListSets() throws ParseException { public void testListSets() throws ParseException {
System.out.println("bla");
this.setListTextGrid.setFormatField("format"); this.setListTextGrid.setFormatField("format");
this.setListTextGrid.setFormatToFilter("text/tg.edition+tg.aggregation+xml"); this.setListTextGrid.setFormatToFilter("text/tg.edition+tg.aggregation+xml");
this.setListTextGrid.setIdentifierField("textgridUri"); this.setListTextGrid.setIdentifierField("textgridUri");
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>oaipmh</artifactId> <artifactId>oaipmh</artifactId>
<groupId>info.textgrid.middleware</groupId> <groupId>info.textgrid.middleware</groupId>
<version>2.5.11-SNAPSHOT</version> <version>2.5.12-SNAPSHOT</version>
</parent> </parent>
<groupId>info.textgrid.middleware</groupId> <groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh-webapp</artifactId> <artifactId>oaipmh-webapp</artifactId>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>info.textgrid.middleware</groupId> <groupId>info.textgrid.middleware</groupId>
<artifactId>oaipmh</artifactId> <artifactId>oaipmh</artifactId>
<version>2.5.11-SNAPSHOT</version> <version>2.5.12-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>DARIAHDE :: OAI-PMH DataProvider</name> <name>DARIAHDE :: OAI-PMH DataProvider</name>
<properties> <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