Fixed foundry rewrite for constituency (koral:span).

Change-Id: Ia6e7c03e4d78466484cc872a5280eaca851bc558
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 7b75f37..3f8d950 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -136,11 +136,11 @@
         issuer = new URL(is);
 
         default_const = properties
-                .getProperty("kustvakt.default.const", "mate");
-        default_dep = properties.getProperty("kustvakt.default.dep", "mate");
-        default_lemma = properties.getProperty("kustvakt.default.lemma", "tt");
-        default_pos = properties.getProperty("kustvakt.default.pos", "tt");
-        default_token = properties.getProperty("kustvakt.default.token",
+                .getProperty("default.layer.c", "mate");
+        default_dep = properties.getProperty("default.layer.d", "mate");
+        default_lemma = properties.getProperty("default.layer.l", "tt");
+        default_pos = properties.getProperty("default.layer.p", "tt");
+        default_token = properties.getProperty("default.layer.o",
                 "opennlp");
 
         // security configuration
@@ -179,9 +179,9 @@
         ldapConfig = properties.getProperty("ldap.config");
         
         // EM: regex used for storing vc
-        freeOnlyRegex = properties.getProperty("kustvakt.regex.free","");
-        publicOnlyRegex = properties.getProperty("kustvakt.regex.public","");
-        allOnlyRegex = properties.getProperty("kustvakt.regex.all","");
+        freeOnlyRegex = properties.getProperty("availability.regex.free","");
+        publicOnlyRegex = properties.getProperty("availability.regex.public","");
+        allOnlyRegex = properties.getProperty("availability.regex.all","");
         
         // EM: pattern for matching availability in Krill matches
         freeLicensePattern = compilePattern(freeOnlyRegex);
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
index abbacf0..23d2838 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
+++ b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
@@ -1,19 +1,18 @@
 package de.ids_mannheim.korap.resource.rewrite;
 
+import java.util.Collection;
+
 import com.fasterxml.jackson.databind.JsonNode;
+
 import de.ids_mannheim.korap.config.BeanInjectable;
-import de.ids_mannheim.korap.config.BeansFactory;
 import de.ids_mannheim.korap.config.ContextHolder;
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
 import de.ids_mannheim.korap.resource.LayerMapper;
+import de.ids_mannheim.korap.resource.rewrite.KoralNode.RewriteIdentifier;
 import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettings;
 import edu.emory.mathcs.backport.java.util.Collections;
 
-import java.util.Collection;
-
 /**
  * @author hanl
  * @date 30/06/2015
@@ -41,8 +40,12 @@
 //        }
 //        else
             mapper = new LayerMapper(config);
-
-        if (node.get("@type").equals("koral:term") && !node.has("foundry")) {
+            
+        if (node.get("@type").equals("koral:span")) {
+            JsonNode term = rewriteQuery(node.at("/wrap"), config, user);
+            node.replaceAt("/wrap", term, new RewriteIdentifier("koral:term", "replace"));
+        }
+        else if (node.get("@type").equals("koral:term") && !node.has("foundry")) {
             String layer;
             if (node.has("layer"))
                 layer = node.get("layer");
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index 3c63dcd..8f465e3 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -6,25 +6,21 @@
 krill.index.commit.auto = 500
 krill.index.relations.max = 100
 
-kustvakt.default.pos = tt
-kustvakt.default.lemma = tt
-kustvakt.default.token = opennlp
-kustvakt.default.dep = mate
-kustvakt.default.const = mate
+# default layers
+default.layer.p = tt
+default.layer.l = tt
+default.layer.o = opennlp
+default.layer.d = mate
+default.layer.c = corenlp
+
+# availability regex
+availability.regex.free = CC-BY.*
+availability.regex.public = ACA.*
+availability.regex.all = QAO.*
 
 kustvakt.management.registration=enable
 
-kustvakt.regex.free = CC-BY.*
-kustvakt.regex.public = ACA.*
-kustvakt.regex.all = QAO.*
-
-# server
-server.port=8089
-server.host=localhost
-
-# user configuration
-# user.config = user.conf
-
+#LDAP
 ldap.config = file-path-to-ldap-config
 
 ## options referring to the security module!
diff --git a/full/src/main/resources/log4j.properties b/full/src/main/resources/log4j.properties
index 7f9c1ca..b975c78 100644
--- a/full/src/main/resources/log4j.properties
+++ b/full/src/main/resources/log4j.properties
@@ -6,7 +6,7 @@
 
 #log4j.logger.de.ids_mannheim.korap.service.VirtualCorpusService = error, debugLog
 #log4j.logger.de.ids_mannheim.korap.web.controller.AuthenticationController = debug, debugLog, stdout
-log4j.logger.de.ids_mannheim.korap.resource.rewrite.CollectionRewrite= stdout, debugLog
+#log4j.logger.de.ids_mannheim.korap.resource.rewrite.CollectionRewrite= stdout, debugLog
 
 # Direct log messages to stdout
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index 847788e..c87ecba 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -6,25 +6,25 @@
 krill.index.commit.auto = 500
 krill.index.relations.max = 100
 
-kustvakt.default.pos = tt
-kustvakt.default.lemma = tt
-kustvakt.default.token = opennlp
-kustvakt.default.dep = mate
-kustvakt.default.const = mate
+# default layers
+default.layer.p = tt
+default.layer.l = tt
+default.layer.o = opennlp
+default.layer.d = mate
+default.layer.c = corenlp
 
-kustvakt.management.registration=enable
-
-kustvakt.regex.free = CC-BY.*
-kustvakt.regex.public = ACA.*
-kustvakt.regex.all = QAO.*
+# availability regex
+availability.regex.free = CC-BY.*
+availability.regex.public = ACA.*
+availability.regex.all = QAO.*
 
 # port&host added 06.02.17/FB
 server.port=8089
 server.host=localhost
 
-# user configuration
-# user.config = user.conf
+kustvakt.management.registration=enable
 
+#LDAP
 ldap.config = /home/elma/.config/ldap.conf
 
 ## options referring to the security module!