Implemented VirtualCorpusRewrite.

Change-Id: I937cfa78db9be0602b17222f37de72cf3b63027c
diff --git a/core/Changes b/core/Changes
index ec10f8e..1b78700 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,7 +1,9 @@
 version 0.61.2
 12/09/2018
    - Removed log4j loader and old OAuth2 implementation codes(margaretha)
-
+13/09/2018
+   - Updated KoralNode and enforced order of RewriteTask (margaretha)
+    
 version 0.61.1
 28/08/2018
     - Added API URL versioning (margaretha)
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
index 70f23bc..46bb538 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
+++ b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
@@ -133,6 +133,13 @@
         }
     }
 
+    public void setAll (ObjectNode other) {
+        if (this.node.isObject()) {
+            ObjectNode n = (ObjectNode) this.node;
+            n.setAll(other);
+        }
+        this.rewrites.add("insertion",null);
+    }
 
     public String get (String name) {
         if (this.node.isObject())
@@ -204,7 +211,9 @@
         public KoralRewriteBuilder add (String op, Object scope) {
             KoralRewrite rewrite = new KoralRewrite();
             rewrite.setOperation(op);
-            rewrite.setScope(scope.toString());
+            if (scope !=null){
+                rewrite.setScope(scope.toString());
+            }
             this.rewrites.add(rewrite);
             return this;
         }
@@ -270,4 +279,15 @@
     public boolean isMissingNode (String string) {
         return this.node.at(string).isMissingNode();
     }
+
+
+    public int size () {
+        return this.node.size();
+    }
+
+
+    public KoralNode get (int i) {
+//        this.node = this.node.get(i);
+        return this.wrapNode(this.node.get(i));
+    }
 }
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
index 592a144..a932fa9 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
+++ b/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
@@ -5,6 +5,7 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -50,7 +51,7 @@
     public RewriteHandler () {
         this.node_processors = new HashSet<>();
         this.token_node_processors = new HashSet<>();
-        this.query_processors = new HashSet<>();
+        this.query_processors = new LinkedHashSet<>();
         this.failed_task_registration = new HashSet<>();
         this.beans = null;
         this.add(FoundryInject.class);
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
index 4317308..f52bbdb 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
@@ -36,7 +36,7 @@
     String indexDir = "/data/prep_corpus/index/";
     String i = "/Users/hanl/Projects/prep_corpus";
     String klinux10 = "/vol/work/hanl/indices";
-    private KrillIndex index;
+    public static KrillIndex index;
     
     /**
      * Constructor