diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index d057e5fe5e9e4588c117b55f92c4135de0d3e629..7bbedd62ab57396dd33873476e4375e1bae1810a 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -4,7 +4,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>2.5.11-SNAPSHOT</version> + <version>2.5.12-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java index f7b7533115fd69658be0c65af7ebfb40a6d03216..c38703c978432336f2d44f68cd895bef107a8485 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDeliverer.java @@ -258,15 +258,6 @@ public class IdentifierListDeliverer { 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) { return lit; diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java index f11602f820a995a786a3b2d0a48d8ce32eb565ef..b5bc7ccc3bae5d4c19689a80c41be1ec567d05d3 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java @@ -2,11 +2,15 @@ package info.textgrid.middleware; import info.textgrid.middleware.oaipmh.ListSetsType; import info.textgrid.middleware.oaipmh.SetType; +import info.textgrid.utils.sesameclient.SesameClient; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.util.Hashtable; +import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import org.elasticsearch.action.get.GetRequestBuilder; @@ -20,6 +24,7 @@ import org.elasticsearch.search.SearchHit; public class SetDeliverer { private OAI_ESClient oaiEsClient; + private SesameClient sparqlClient; public SetDeliverer(OAI_ESClient oaiEsClient, boolean textgrid, boolean dariah) { this.oaiEsClient = oaiEsClient; @@ -36,6 +41,7 @@ public class SetDeliverer { private String specField; private String specFieldPrefix; private Set<String> project = new LinkedHashSet<String>(); + private static Map<String, String> setSet = new Hashtable<String, String >(); private boolean textgrid; private boolean dariah; @@ -68,11 +74,11 @@ public class SetDeliverer { //System.out.println("QUERY: " + request); SearchResponse getRecordListItems = request.execute().actionGet(); - System.out.println(getRecordListItems); + //System.out.println(getRecordListItems); for (SearchHit hit : getRecordListItems.getHits().getHits()) { //System.out.println("HALLO HALLO"); //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:")){ System.out.println("JUHU"); @@ -83,9 +89,19 @@ public class SetDeliverer { if(textgrid==true){ //System.out.println("HALLO TEXTGRIT"); 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); - 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 { if(textgrid==true){ //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(); String[] projectValues = projectSetSpec.split(":"); String projectName = projectValues[0]; 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.setSetSpec("project:" + projectID); setList.getSet().add(set); - } + }*/ } - else{ - + + if(dariah == true){ for (String identifierSetSpec : this.identifier) { String id = identifierSetSpec; try { @@ -214,4 +254,12 @@ public class SetDeliverer { public void setDariah(boolean dariah) { this.dariah = dariah; } + + public SesameClient getSparqlClient() { + return sparqlClient; + } + + public void setSparqlClient(SesameClient sparqlClient) { + this.sparqlClient = sparqlClient; + } } diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java index 577d5b084075ede255b919e167d6088a8af30c13..208c30f4e8765061fefe385f9ffb2bf5eb029602 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -6,6 +6,7 @@ import info.textgrid.middleware.oaipmh.DeletedRecordType; import info.textgrid.middleware.oaipmh.GranularityType; import info.textgrid.middleware.oaipmh.OAIPMHType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; +import info.textgrid.utils.sesameclient.SesameClient; import javax.xml.bind.JAXB; import javax.xml.bind.JAXBElement; @@ -23,6 +24,7 @@ import org.junit.Test; public class OaiPmhTest { public static OAI_ESClient oaiEsClient; + private static SesameClient sc; DeletedRecordType bla = DeletedRecordType.NO; GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; private RepIdentification rep = new RepIdentification( @@ -48,7 +50,7 @@ public class OaiPmhTest { private SetDeliverer setListTextGrid = new SetDeliverer(oaiEsClient, true, false); private IdentifierListDeliverer identifierList = new IdentifierListDeliverer(oaiEsClient, false, true); //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 @@ -56,8 +58,9 @@ public class OaiPmhTest { @BeforeClass public static void setUp() throws Exception { - //oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx2-instance"); - oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); + sc = new SesameClient("http://localhost:9091/openrdf-workbench/repositories/textgrid-public"); + oaiEsClient = new OAI_ESClient("localhost", "9302", "tg-esx1-dev-instance"); + //oaiEsClient = new OAI_ESClient("localhost", "9302", "dariah-repository-prototype"); oaiEsClient.setEsIndex("textgrid-public"); oaiEsClient.setEsType("metadata"); //oaiEsClient.setEsIndex("dariahreptest"); @@ -435,8 +438,9 @@ public class OaiPmhTest { * @throws ParseException */ @Test - @Ignore + //@Ignore public void testListSets() throws ParseException { + System.out.println("bla"); this.setListTextGrid.setFormatField("format"); this.setListTextGrid.setFormatToFilter("text/tg.edition+tg.aggregation+xml"); this.setListTextGrid.setIdentifierField("textgridUri"); diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index a79a6a320b79065e8e38d2f3ea76788a22506a67..86cff4f27f65607b565a27a23e1595542305e35e 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -4,7 +4,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>2.5.11-SNAPSHOT</version> + <version>2.5.12-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> diff --git a/pom.xml b/pom.xml index cf94ca253603f3c5a0dd00281fac8333d61470da..8af28314f0ba0f28efde56442f3264898792b66c 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>2.5.11-SNAPSHOT</version> + <version>2.5.12-SNAPSHOT</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties>