graying corpus statistic(plus tests+vc test fixed) and fix vc serialization

Change-Id: I3f934c2cc0ebbb0a91b5fa8f529bf3f5c3ebd391
(cherry picked from commit 172d6a4bbc7d29a0fe7c23b114fbbf485e2f4aeb)
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index 996c347..2a0e872 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -149,6 +149,10 @@
         e.appendChild(op.element());
       };
       
+      if(KorAP.vc){
+        KorAP.vc.checkGrayingStat();
+      }
+      
       return e;
     },
 
@@ -616,9 +620,12 @@
       };
     },
 
+    incomplete : function () {
+      return !(this.matchop() && this.key() && this.value());
+    },
 
     toQuery : function () {
-      if (!this.matchop() || !this.key())
+      if (this.incomplete())
         return "";
 
       // Build doc string based on key
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 7ce2fed..10a6495 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -356,7 +356,7 @@
     toQuery : function (brackets) {
       var list = this._operands
 	        .filter(function (op) {
-	          return op.ldType() !== 'non';
+            return !op.incomplete();
 	        })
 	        .map(function (op) {
 	          return (op.ldType() === 'docGroup') ?
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
index 7d3ecea..fa82a4b 100644
--- a/dev/js/src/vc/docgroupref.js
+++ b/dev/js/src/vc/docgroupref.js
@@ -109,7 +109,7 @@
         // Append new operators
         e.appendChild(op.element());
       };  
-
+      KorAP.vc.checkGrayingStat();
       return this.element();
     },
 
@@ -207,7 +207,6 @@
       return this;
     },
 
-
     /**
      * Click on the unspecified object
      */
@@ -261,9 +260,13 @@
       };
     },
 
+
+    incomplete : function () {
+      return this.ref() ? false : true
+    },
     
     toQuery : function () {
-      if (!this.ref())
+      if (this.incomplete())
         return "";
 
       // Build doc string based on key
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index 600a5bb..21260d4 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -99,6 +99,10 @@
       return null;
     },
 
+    incomplete : function () {
+      return false;
+    },
+
     toQuery : function () {
       return '';
     }
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 6ffa0e3..416ad85 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -121,6 +121,11 @@
       return this._element;
     },
 
+
+    incomplete : function () {
+      return true;
+    },
+    
     /**
      * Click on the unspecified object
      */