Added default foundry for structure layer.

Change-Id: I808745f3e4ae83157204a13061bd3f6b2d6e799c
diff --git a/core/Changes b/core/Changes
index 5d8758f..3f2d0b7 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,3 +1,8 @@
+# version 0.61.6
+
+06/02/2018
+   - Added default foundry for structure layer (margaretha)
+
 # version 0.61.5
 17/12/2018
    - Added search timeout in meta query (margaretha)
diff --git a/core/pom.xml b/core/pom.xml
index aff703d..109ef97 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-core</artifactId>
-	<version>0.61.5</version>
+	<version>0.61.6</version>
 
 	<properties>
 		<java.version>1.8</java.version>
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/Attributes.java b/core/src/main/java/de/ids_mannheim/korap/config/Attributes.java
index 2ad58cc..a3e2433 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/Attributes.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/Attributes.java
@@ -149,7 +149,8 @@
     public static final String DEFAULT_FOUNDRY_CONSTITUENT = "constituent-foundry";
     public static final String DEFAULT_FOUNDRY_RELATION = "relation-foundry";
     public static final String DEFAULT_FOUNDRY_MORPHOLOGY = "morphology-foundry";
-
+    public static final String DEFAULT_FOUNDRY_STRUCTURE = "structure-foundry";
+    
     /**
      * db column keys
      */
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 f4f107f..87f0838 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
@@ -73,9 +73,10 @@
     private String default_pos;
     private String default_morphology;
     private String default_lemma;
-    private String default_token;
+    private String default_orthography;
     private String default_dep;
     private String default_const;
+    private String defaultStructureFoundry;
     private ArrayList<String> foundries;
     private ArrayList<String> layers;
 
@@ -140,8 +141,10 @@
         default_morphology = properties.getProperty("default.foundry.morphology", "marmot");
         default_pos =
                 properties.getProperty("default.foundry.partOfSpeech", "tt");
-        default_token =
+        default_orthography =
                 properties.getProperty("default.foundry.orthography", "opennlp");
+        defaultStructureFoundry =
+                properties.getProperty("default.foundry.structure", "base");
 
         // security configuration
         inactiveTime = TimeUtils.convertTimeToSeconds(
diff --git a/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
index a8a81bd..29360d9 100644
--- a/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
@@ -53,6 +53,9 @@
                 case "surface":
                     return "opennlp";
                 // EM: added
+                case "s":
+                    return (String) settings
+                            .get(Attributes.DEFAULT_FOUNDRY_STRUCTURE);    
                 case "morphology":
                     return (String) settings
                             .get(Attributes.DEFAULT_FOUNDRY_MORPHOLOGY);    
@@ -72,13 +75,14 @@
                     return config.getDefault_pos();
                 case "lemma":
                     return config.getDefault_lemma();
-                case "morphology":
-                    return config.getDefault_morphology();
                 case "surface":
-                    return config.getDefault_token();
+                    return config.getDefault_orthography();
                     // refers to "structure" and is used for paragraphs or sentence boundaries
                 case "s":
-                    return "base";
+                    return config.getDefaultStructureFoundry();
+                //EM: added
+                case "morphology":
+                    return config.getDefault_morphology();
                 default:
                     // if the layer is not in this specific listing, assume a default layer
                     // like orth or other tokenization layers
@@ -101,8 +105,10 @@
                 //todo the orth layer does not need a foundry entry
             case "orth":
                 return "surface";
-            case "t":
-                return "surface";
+            // EM: layer t does not exist at all   
+//            case "t":
+//                return "surface";
+            // EM: this islegacy support    
             case "const":
                 return "c";
             case "p":
diff --git a/full/Changes b/full/Changes
index e8ba17d..adb6bf6 100644
--- a/full/Changes
+++ b/full/Changes
@@ -5,6 +5,8 @@
 05/02/2019
    - Added delete-group-by-name controller (margaretha)
    - Added unique index to group name (margaretha)
+06/02/2019
+   - Updated a user setting test using array for multiple values (margaretha)
 
 # version 0.61.5
 17/12/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/dao/DefaultSettingDao.java b/full/src/main/java/de/ids_mannheim/korap/dao/DefaultSettingDao.java
index 813fb72..bc7afdd 100644
--- a/full/src/main/java/de/ids_mannheim/korap/dao/DefaultSettingDao.java
+++ b/full/src/main/java/de/ids_mannheim/korap/dao/DefaultSettingDao.java
@@ -58,13 +58,13 @@
     public void deleteDefaultSetting (String username)
             throws KustvaktException {
         ParameterChecker.checkObjectValue(username, "defaultSetting");
-        DefaultSetting defaultSetting = retrieveDefautlSetting(username);
+        DefaultSetting defaultSetting = retrieveDefaultSetting(username);
         if (defaultSetting != null){
             entityManager.remove(defaultSetting);
         }
     }
 
-    public DefaultSetting retrieveDefautlSetting (String username)
+    public DefaultSetting retrieveDefaultSetting (String username)
             throws KustvaktException {
         ParameterChecker.checkStringValue(username, "username");
 
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java b/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
index fc924db..96ebeb8 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/DefaultSettingService.java
@@ -61,7 +61,7 @@
         processor.readQuietly(map, false);
 
         DefaultSetting defaultSetting =
-                settingDao.retrieveDefautlSetting(username);
+                settingDao.retrieveDefaultSetting(username);
         if (defaultSetting == null) {
             createDefaultSetting(username, processor);
             return HttpStatus.SC_CREATED;
@@ -99,7 +99,7 @@
     public String retrieveDefaultSettings (String username)
             throws KustvaktException {
         DefaultSetting defaultSetting =
-                settingDao.retrieveDefautlSetting(username);
+                settingDao.retrieveDefaultSetting(username);
         if (defaultSetting == null) {
             return null;
         }
@@ -110,7 +110,7 @@
             throws KustvaktException {
         username = verifiyUsername(username, contextUsername);
         DefaultSetting defaultSetting =
-                settingDao.retrieveDefautlSetting(username);
+                settingDao.retrieveDefaultSetting(username);
 
         String jsonSettings = defaultSetting.getSettings();
         UserSettingProcessor processor = new UserSettingProcessor(jsonSettings);
diff --git a/full/src/main/resources/kustvakt.conf b/full/src/main/resources/kustvakt.conf
index ec540f9..24dcb47 100644
--- a/full/src/main/resources/kustvakt.conf
+++ b/full/src/main/resources/kustvakt.conf
@@ -36,6 +36,7 @@
 default.foundry.dependency = malt
 default.foundry.constituent = corenlp
 default.foundry.morphology = marmot
+default.foundry.surface = base
 
 ## delete configuration (default hard)
 # delete.auto.group = hard
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
index bd56477..ffe1c51 100644
--- a/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/misc/ConfigTest.java
@@ -50,7 +50,7 @@
 
     @Test
     public void testProperties () {
-        assertEquals("token layer does not match", "opennlp", config.getDefault_token());
+        assertEquals("token layer does not match", "opennlp", config.getDefault_orthography());
         assertEquals("token expiration does not match",
                 TimeUtils.convertTimeToSeconds("1D"), config.getLongTokenTTL());
     }
diff --git a/full/src/test/java/de/ids_mannheim/korap/rewrite/FoundryRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/rewrite/FoundryRewriteTest.java
index ee86fc2..ce2f6ad 100644
--- a/full/src/test/java/de/ids_mannheim/korap/rewrite/FoundryRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/rewrite/FoundryRewriteTest.java
@@ -114,7 +114,7 @@
     public void testDefaultLayerMapperThrowsNoException () {
         assertEquals(config.getDefault_lemma(), m.findFoundry("lemma"));
         assertEquals(config.getDefault_pos(), m.findFoundry("pos"));
-        assertEquals(config.getDefault_token(), m.findFoundry("surface"));
+        assertEquals(config.getDefault_orthography(), m.findFoundry("surface"));
         assertEquals(config.getDefault_dep(), m.findFoundry("d"));
         assertEquals(config.getDefault_const(), m.findFoundry("c"));
     }
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserSettingControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserSettingControllerTest.java
index 29c5890..c04aee1 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserSettingControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserSettingControllerTest.java
@@ -46,8 +46,8 @@
     @Test
     public void testCreateSettingWithJson () throws KustvaktException {
         String json =
-                "{\"pos-foundry\":\"opennlp\",\"metadata\":\"author title "
-                        + "textSigle availability\",\"resultPerPage\":25}";
+                "{\"pos-foundry\":\"opennlp\",\"metadata\":[\"author\", \"title\","
+                        + "\"textSigle\", \"availability\"],\"resultPerPage\":25}";
 
         ClientResponse response = resource().path(API_VERSION)
                 .path("~" + username).path("setting")
@@ -59,7 +59,8 @@
         assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
 
         int numOfResult = 25;
-        String metadata = "author title textSigle availability";
+        String metadata = "[\"author\",\"title\",\"textSigle\","
+                + "\"availability\"]";
 
         testRetrieveSettings(username, "opennlp", numOfResult, metadata);
 
@@ -254,6 +255,7 @@
                 .get(ClientResponse.class);
 
         String entity = response.getEntity(String.class);
+        System.out.println(entity);
         JsonNode node = JsonUtils.readTree(entity);
         if (posFoundry == null) {
             assertTrue(node.at("/pos-foundry").isMissingNode());
@@ -262,7 +264,7 @@
             assertEquals(posFoundry, node.at("/pos-foundry").asText());
         }
         assertEquals(numOfResult, node.at("/resultPerPage").asInt());
-        assertEquals(metadata, node.at("/metadata").asText());
+        assertEquals(metadata, node.at("/metadata").toString());
     }
 
 }
diff --git a/full/src/test/resources/kustvakt-test.conf b/full/src/test/resources/kustvakt-test.conf
index b3d2985..7587bc9 100644
--- a/full/src/test/resources/kustvakt-test.conf
+++ b/full/src/test/resources/kustvakt-test.conf
@@ -36,6 +36,7 @@
 default.foundry.dependency = malt
 default.foundry.constituent = corenlp
 default.foundry.morphology = marmot
+default.foundry.surface = base 
 
 ## delete configuration (default hard)
 # delete.auto.group = hard
diff --git a/lite/Changes b/lite/Changes
index 74d334c..3c045ae 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,16 +1,14 @@
-version 0.61.4
+version 0.61.3
 05/02/2019
   - Updated kustvakt-lite.conf
 
-version 0.61.3
-19/12/2018
-  - Fixed getUser in DummyAuthenticationManager (margaretha)
-  - Fixed search test with fields parameter (margaretha)
-
 version 0.61.2
 14/11/2018
    - Integrated lite and full services and controllers in core (margaretha)
    - Added annotation services (margaretha)
+19/12/2018
+  - Fixed getUser in DummyAuthenticationManager (margaretha)
+  - Fixed search test with fields parameter (margaretha)
 
 version 0.61.1
 22/10/2018
diff --git a/lite/pom.xml b/lite/pom.xml
index e531c37..cacf4a6 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-lite</artifactId>
-	<version>0.61.2</version>
+	<version>0.61.3</version>
 	<properties>
 		<java.version>1.8</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/lite/src/main/resources/kustvakt-lite.conf b/lite/src/main/resources/kustvakt-lite.conf
index 5636857..e78f993 100644
--- a/lite/src/main/resources/kustvakt-lite.conf
+++ b/lite/src/main/resources/kustvakt-lite.conf
@@ -27,6 +27,7 @@
 default.foundry.dependency = malt
 default.foundry.constituent = corenlp
 default.foundry.morphology = marmot
+default.foundry.surface = base
 
 # server
 server.port=8089