Set the default value for named-vc path (fixes #146)
Change-Id: I77d0ac01bddba2c1649e88385ed475e46d56ea47
diff --git a/Changes b/Changes
index 98f331d..37d2ffc 100644
--- a/Changes
+++ b/Changes
@@ -1,9 +1,10 @@
-0.62.5 2024-05-31
+0.62.5 2024-06-11
- [bugfix] cut primary data according to max values (margaretha, #143)
- [enhancement] restrict match expansion by max token and context
size (margaretha, #144)
+ - [bugfix] Set the default value for named-vc path (margaretha,
+ fixes #146)
-
0.62.4 2024-05-27
- [feature] Make match and context size configurable (address #128,
diewald & margaretha)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillCollection.java b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
index fbd2f4f..ffa99cd 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
@@ -167,20 +167,8 @@
public KrillCollection fromStore (String ref) throws QueryException {
- Properties prop = KrillProperties.loadDefaultProperties();
this.prefiltered = null;
-
- if (prop == null) {
- this.addError(StatusCodes.MISSING_KRILL_PROPERTIES,
- "krill.properties is not found.");
- return null;
- }
-
- String p = prop.getProperty("krill.test", "false");
- boolean isTest = Boolean.parseBoolean(p);
-
- String namedVCPath = prop.getProperty("krill.namedVC");
-
+ String namedVCPath = KrillProperties.namedVCPath;
if (!namedVCPath.endsWith("/")) {
namedVCPath += "/";
};
@@ -215,7 +203,7 @@
}
}
// for testing
- else if (isTest
+ else if (KrillProperties.isTest
&& (is = retrieveInputStreamFromClasspath(fileName)) != null) {
try {
json = IOUtils.toString(is, "utf-8");
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillProperties.java b/src/main/java/de/ids_mannheim/korap/util/KrillProperties.java
index db73e36..1ebc449 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillProperties.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillProperties.java
@@ -23,6 +23,9 @@
public static int maxTokenContextSize = 60;
public static int maxCharContextSize = 500;
+ public static String namedVCPath = "";
+ public static boolean isTest = false;
+
// Logger
private final static Logger log = LoggerFactory
.getLogger(KrillProperties.class);
@@ -74,7 +77,7 @@
return prop;
};
- private static void updateConfigurations (Properties prop) {
+ public static void updateConfigurations (Properties prop) {
String maxTokenMatchSize = prop.getProperty("krill.match.max.token");
String maxTokenContextSize = prop.getProperty("krill.context.max.token");
@@ -92,6 +95,11 @@
log.error("A Krill property expects numerical values: "
+ e.getMessage());
};
+
+ String p = prop.getProperty("krill.test", "false");
+ isTest = Boolean.parseBoolean(p);
+
+ namedVCPath = prop.getProperty("krill.namedVC", "");
}
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollection.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollection.java
new file mode 100644
index 0000000..ff8e755
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollection.java
@@ -0,0 +1,25 @@
+package de.ids_mannheim.korap.collection;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.util.KrillProperties;
+import de.ids_mannheim.korap.util.QueryException;
+
+public class TestKrillCollection {
+
+ @Test
+ public void testLoadVCFromStore () throws QueryException, IOException {
+ KrillProperties.loadProperties("krill.properties.info");
+ KrillCollection kc = new KrillCollection();
+ kc = kc.fromStore("unknown-vc");
+ assertEquals(-1, kc.numberOf("tokens"));
+ assertEquals(-1, kc.numberOf("documents"));
+ assertEquals(-1, kc.numberOf("sentences"));
+ KrillProperties.loadDefaultProperties();
+ }
+}