Get pageSize from configuration file
Change-Id: I6863a4c5f8dff879b0ba476b0a7f96a667b9c4a1
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
index c00663b..11413ae 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
@@ -20,14 +20,6 @@
* See also: https://www.ids-mannheim.de/cosmas2/script-app/hilfe/sitzung.html
*/
public static final int MAX_EXP_LIMIT = 10000;
- /*
- * TODO:
- * Analog zur Variable aus Search.pm
- * Kommentar eventuell JSON um aus Perl und Java einzulesen
- */
- // Eigentlich 25 zu Testzwecken kleiner
- // public static final int PAGE_SIZE = 25;
- public static final int PAGE_SIZE = 5;
// Version of Export Plugin
public static final int VERSION_MAJOR = 0;
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
index 680f6a7..a8d691e 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
@@ -154,9 +154,10 @@
Client client = ClientBuilder.newClient();
String scheme = properties.getProperty("api.scheme", "https");
- String port = properties.getProperty("api.port", "8089");
- String host = properties.getProperty("api.host", "localhost");
- String path = properties.getProperty("api.path", "");
+ String port = properties.getProperty("api.port", "8089");
+ String host = properties.getProperty("api.host", "localhost");
+ String path = properties.getProperty("api.path", "");
+ int pageSize = Integer.parseInt(properties.getProperty("conf.page_size", "5"));
UriBuilder uri = UriBuilder.fromPath("/api/v1.0/search")
.host(host)
@@ -181,7 +182,8 @@
uri = uri.queryParam("count", ExWSConf.MAX_EXP_LIMIT);
};
*/
- uri = uri.queryParam("count", ExWSConf.PAGE_SIZE);
+
+ uri = uri.queryParam("count", pageSize);
// Get client IP, in case service is behind a proxy
String xff = "";
@@ -285,12 +287,12 @@
* which should be exported at the last page
*/
int pg = 1;
- int dr = totalhits % ExWSConf.PAGE_SIZE;
+ int dr = totalhits % pageSize;
if (dr > 0) {
- pg = totalhits / ExWSConf.PAGE_SIZE + 1;
+ pg = totalhits / pageSize + 1;
}
else {
- pg = totalhits / ExWSConf.PAGE_SIZE;
+ pg = totalhits / pageSize;
}
/*
@@ -310,7 +312,7 @@
// url = urlorg + "&page=" + i;
// resource = client.target(url);
resource = client.target(
- uri.build((i * ExWSConf.PAGE_SIZE) - ExWSConf.PAGE_SIZE)
+ uri.build((i * pageSize) - pageSize)
);
resp = resource.request(MediaType.APPLICATION_JSON)
.get(String.class);
diff --git a/plugin/src/main/resources/exportPlugin.conf b/plugin/src/main/resources/exportPlugin.conf
index 3dd58d9..dfd029d 100644
--- a/plugin/src/main/resources/exportPlugin.conf
+++ b/plugin/src/main/resources/exportPlugin.conf
@@ -10,4 +10,7 @@
# Asset Configuration
asset.host=korap.ids-mannheim.de
-asset.scheme=https
\ No newline at end of file
+asset.scheme=https
+
+# Default configuration
+conf.page_size=5
\ No newline at end of file