Fix serialization of text values in VC
Change-Id: Idcabb4d6c69020c6a9911669853bdafb8c934f21
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index b9822fd..f7a136c 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -359,9 +359,15 @@
// Render Virtual collection
function _getCurrentVC (vcClass, vcArray) {
var vc = vcClass.create(vcArray);
- if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
- vc.fromJson(KorAP.koralQuery["collection"]);
- };
+ try {
+ if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
+ vc.fromJson(KorAP.koralQuery["collection"]);
+ };
+ }
+ catch (e) {
+ KorAP.log(0, e);
+ return;
+ }
return vc;
};
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 527e116..8a5c6b8 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -316,18 +316,9 @@
var that = this;
var actions = panel.actions;
var statView;
-
- //delete log after solving the cq= -Problem.
- console.log("vc._root.element() = " + that._root.element().innerHTML);
- console.log("vc._root.toQuery = " + that._root.toQuery());
-
+
actions.add(loc.SHOW_STAT, [ 'statistic' ], function() {
if (statView === undefined || !statView.shown()) {
-
- //delete log after solving the cq= -Problem
- console.log("statView created mit vc.toQuery()= "
- + that.toQuery());
-
statView = corpStatVClass.create(that);
panel.add(statView);
}
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index d2a413e..15c7287 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -9,8 +9,14 @@
'util'
], function (jsonldClass, rewriteListClass, stringValClass) {
+ /*
+ * TODO:
+ * Improve error handling by using window.onerror() to
+ * capture thrown errors and log them.
+ */
const errstr802 = "Match type is not supported by value type";
+ const errstr804 = "Unknown value type";
const loc = KorAP.Locale;
loc.EMPTY = loc.EMPTY || '⋯';
@@ -319,8 +325,8 @@
}
else {
- KorAP.log(804, "Unknown value type");
- return;
+ KorAP.log(804, errstr804 + ": " + this.type());
+ throw new Error(errstr804 + ": " + this.type());
};
};
@@ -622,13 +628,11 @@
switch (this.type()) {
case "date":
return string + this.value();
- break;
case "regex":
return string + '/' + this.value().escapeRegex() + '/';
- break;
case "string":
+ case "text":
return string + '"' + this.value().quote() + '"';
- break;
};
return "";