| Nils Diewald | 86dad5b | 2015-01-28 15:09:07 +0000 | [diff] [blame] | 1 | /** | 
|  | 2 | * Create virtual collections with a visual user interface. | 
| Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 3 | * This resembles the collection type objects of a KoralQuery | 
|  | 4 | * "collection" object. | 
|  | 5 | * | 
|  | 6 | * KoralQuery v0.3 is expected. | 
| Nils Diewald | 86dad5b | 2015-01-28 15:09:07 +0000 | [diff] [blame] | 7 | * | 
|  | 8 | * @author Nils Diewald | 
|  | 9 | */ | 
| Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame] | 10 | /* | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 11 | * This replaces a previous version written by Mengfei Zhou | 
| Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame] | 12 | */ | 
| Nils Diewald | 2fe12e1 | 2015-03-06 16:47:06 +0000 | [diff] [blame] | 13 |  | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 14 | /* | 
| Nils Diewald | 86dad5b | 2015-01-28 15:09:07 +0000 | [diff] [blame] | 15 | TODO: Disable "and" or "or" in case it's followed | 
|  | 16 | by an unspecified document | 
| Akron | 0a6768f | 2016-07-13 18:00:43 +0200 | [diff] [blame] | 17 | TODO: Add "and"-method to root to add further constraints based on match- | 
|  | 18 | input (like clicking on a pubDate timestamp in a match) | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 19 | TODO: Implement "persistence"-Option, | 
| Nils Diewald | 6e43ffd | 2015-03-25 18:55:39 +0000 | [diff] [blame] | 20 | injecting the current creation date stamp | 
| Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame] | 21 | TODO: Implement vec-Type for document-id vectors | 
|  | 22 | like docID in [1,2,3,4 ...] | 
| Nils Diewald | 86dad5b | 2015-01-28 15:09:07 +0000 | [diff] [blame] | 23 |  | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 24 | Error codes: | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 25 | 701: "JSON-LD group has no @type attribute" | 
|  | 26 | 704: "Operation needs operand list" | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 27 | 802: "Match type is not supported by value type" | 
|  | 28 | 804: "Unknown value type" | 
|  | 29 | 805: "Value is invalid" | 
|  | 30 | 806: "Value is not a valid date string" | 
|  | 31 | 807: "Value is not a valid regular expression" | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 32 | 810: "Unknown document group operation" (like 711) | 
|  | 33 | 811: "Document group expects operation" (like 703) | 
|  | 34 | 812: "Operand not supported in document group" (like 744) | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 35 | 813: "Collection type is not supported" (like 713) | 
| Nils Diewald | 86dad5b | 2015-01-28 15:09:07 +0000 | [diff] [blame] | 36 | 814: "Unknown rewrite operation" | 
|  | 37 | 815: "Rewrite expects source" | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 38 |  | 
|  | 39 | Localization strings: | 
|  | 40 | KorAP.Locale = { | 
|  | 41 | EMPTY : '...', | 
|  | 42 | AND : 'and', | 
|  | 43 | OR : 'or', | 
|  | 44 | DELETE : 'x' | 
|  | 45 | } | 
| Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 46 | and various field names with the prefix 'VC_' | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 47 | */ | 
|  | 48 |  | 
| Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 49 | define([ | 
|  | 50 | 'vc/unspecified', | 
|  | 51 | 'vc/doc', | 
|  | 52 | 'vc/docgroup', | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 53 | 'vc/menu', | 
| hebasta | ccb8fa3 | 2018-06-05 17:02:16 +0200 | [diff] [blame] | 54 | 'vc/statistic', | 
| Nils Diewald | 8750783 | 2015-05-01 23:36:41 +0000 | [diff] [blame] | 55 | 'datepicker', | 
| hebasta | ccb8fa3 | 2018-06-05 17:02:16 +0200 | [diff] [blame] | 56 | 'util', | 
|  | 57 | ], function (unspecDocClass, docClass, docGroupClass, menuClass, statClass, dpClass) { | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 58 | "use strict"; | 
|  | 59 |  | 
| Akron | 31d8994 | 2018-04-06 16:44:51 +0200 | [diff] [blame] | 60 | KorAP._validUnspecMatchRE = new RegExp("^(?:eq|ne|contains(?:not)?|excludes)$"); | 
|  | 61 | KorAP._validStringMatchRE = new RegExp("^(?:eq|ne)$"); | 
|  | 62 | KorAP._validTextMatchRE = KorAP._validUnspecMatchRE; | 
|  | 63 | KorAP._validTextOnlyMatchRE = new RegExp("^(?:contains(?:not)?|excludes)$"); | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 64 | KorAP._overrideStyles     = false; | 
| Akron | 31d8994 | 2018-04-06 16:44:51 +0200 | [diff] [blame] | 65 | // KorAP._validDateMatchRE is defined in datepicker.js! | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 66 |  | 
| Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 67 | const loc = KorAP.Locale; | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 68 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 69 | KorAP._vcKeyMenu = undefined; | 
| Nils Diewald | 8750783 | 2015-05-01 23:36:41 +0000 | [diff] [blame] | 70 | KorAP._vcDatePicker = dpClass.create(); | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 71 |  | 
| Akron | 712733a | 2018-04-05 18:17:47 +0200 | [diff] [blame] | 72 | // Create match menus .... | 
|  | 73 | KorAP._vcMatchopMenu = { | 
|  | 74 | 'string' : menuClass.create([ | 
|  | 75 | ['eq', null], | 
|  | 76 | ['ne', null] | 
|  | 77 | ]), | 
|  | 78 | 'text' : menuClass.create([ | 
|  | 79 | ['eq', null],         // Requires exact match | 
|  | 80 | ['ne', null], | 
|  | 81 | ['contains', null],   // Requires token sequence match | 
|  | 82 | ['containsnot', null] | 
|  | 83 | ]), | 
|  | 84 | 'date' : menuClass.create([ | 
|  | 85 | ['eq', null], | 
| Akron | 31d8994 | 2018-04-06 16:44:51 +0200 | [diff] [blame] | 86 | ['ne', null], | 
| Akron | 712733a | 2018-04-05 18:17:47 +0200 | [diff] [blame] | 87 | ['geq', null], | 
|  | 88 | ['leq', null] | 
|  | 89 | ]), | 
|  | 90 | 'regex' : menuClass.create([ | 
|  | 91 | ['eq', null], | 
|  | 92 | ['ne', null] | 
|  | 93 | ]) | 
|  | 94 | }; | 
|  | 95 |  | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 96 | /** | 
|  | 97 | * Virtual Collection | 
|  | 98 | */ | 
| Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 99 | return { | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 100 |  | 
|  | 101 | /** | 
|  | 102 | * The JSON-LD type of the virtual collection | 
|  | 103 | */ | 
| Nils Diewald | f219eb8 | 2015-01-07 20:15:42 +0000 | [diff] [blame] | 104 | ldType : function () { | 
|  | 105 | return null; | 
|  | 106 | }, | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 107 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 108 | // Initialize virtual collection | 
|  | 109 | _init : function (keyList) { | 
|  | 110 |  | 
|  | 111 | // Inject localized css styles | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 112 | if (!KorAP._overrideStyles) { | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 113 | var sheet = KorAP.newStyleSheet(); | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 114 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 115 | // Add css rule for OR operations | 
|  | 116 | sheet.insertRule( | 
|  | 117 | '.vc .docGroup[data-operation=or] > .doc::before,' + | 
|  | 118 | '.vc .docGroup[data-operation=or] > .docGroup::before ' + | 
|  | 119 | '{ content: "' + loc.OR + '" }', | 
|  | 120 | 0 | 
|  | 121 | ); | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 122 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 123 | // Add css rule for AND operations | 
|  | 124 | sheet.insertRule( | 
|  | 125 | '.vc .docGroup[data-operation=and] > .doc::before,' + | 
|  | 126 | '.vc .docGroup[data-operation=and] > .docGroup::before ' + | 
|  | 127 | '{ content: "' + loc.AND + '" }', | 
|  | 128 | 1 | 
|  | 129 | ); | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 130 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 131 | KorAP._overrideStyles = true; | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 132 | }; | 
|  | 133 |  | 
| Akron | 712733a | 2018-04-05 18:17:47 +0200 | [diff] [blame] | 134 | // Create key menu | 
|  | 135 | KorAP._vcKeyMenu = menuClass.create(keyList); | 
|  | 136 | KorAP._vcKeyMenu.limit(6); | 
|  | 137 |  | 
| Nils Diewald | 359a72c | 2015-04-20 17:40:29 +0000 | [diff] [blame] | 138 | return this; | 
|  | 139 | }, | 
|  | 140 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 141 | /** | 
|  | 142 | * Create a new virtual collection. | 
|  | 143 | */ | 
|  | 144 | create : function (keyList) { | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 145 | var obj = Object.create(this)._init(keyList); | 
|  | 146 | obj._root = unspecDocClass.create(obj); | 
|  | 147 | return obj; | 
| Nils Diewald | 4019bd2 | 2015-01-08 19:57:50 +0000 | [diff] [blame] | 148 | }, | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 149 |  | 
| Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 150 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 151 | /** | 
|  | 152 | * Create and render a new virtual collection | 
|  | 153 | * based on a KoralQuery collection document | 
|  | 154 | */ | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 155 | fromJson : function (json) { | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 156 | if (json !== undefined) { | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 157 | // Parse root document | 
|  | 158 | if (json['@type'] == 'koral:doc') { | 
|  | 159 | this._root = docClass.create(this, json); | 
|  | 160 | } | 
|  | 161 | // parse root group | 
|  | 162 | else if (json['@type'] == 'koral:docGroup') { | 
|  | 163 | this._root = docGroupClass.create(this, json); | 
|  | 164 | } | 
|  | 165 | // Unknown collection type | 
|  | 166 | else { | 
|  | 167 | KorAP.log(813, "Collection type is not supported"); | 
|  | 168 | return; | 
|  | 169 | }; | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 170 | } | 
|  | 171 |  | 
|  | 172 | else { | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 173 | // Add unspecified object | 
|  | 174 | this._root = unspecDocClass.create(this); | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 175 | }; | 
|  | 176 |  | 
| Nils Diewald | 8e7182e | 2015-01-08 15:02:07 +0000 | [diff] [blame] | 177 | // Init element and update | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 178 | this.update(); | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 179 |  | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 180 | return this; | 
|  | 181 | }, | 
|  | 182 |  | 
| Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 183 |  | 
| Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 184 | // Check if the virtual corpus contains a rewrite | 
|  | 185 | // This is a class method | 
|  | 186 | checkRewrite : function (json) { | 
|  | 187 |  | 
|  | 188 | // There is a rewrite attribute | 
|  | 189 | if (json['rewrites'] !== undefined) { | 
|  | 190 | return true; | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | // There is a group to check for rewrites | 
|  | 194 | else if (json['@type'] === 'koral:docGroup') { | 
|  | 195 | var ops = json['operands']; | 
|  | 196 | if (ops === undefined) | 
|  | 197 | return false; | 
|  | 198 |  | 
|  | 199 | for (var i in ops) { | 
|  | 200 |  | 
|  | 201 | // "this" is the class | 
|  | 202 | if (this.checkRewrite(ops[i])) { | 
|  | 203 | return true; | 
|  | 204 | }; | 
|  | 205 | }; | 
|  | 206 | }; | 
|  | 207 | return false; | 
|  | 208 | }, | 
|  | 209 |  | 
| Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 210 | /** | 
|  | 211 | * Clean the virtual document to uspecified doc. | 
|  | 212 | */ | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 213 | clean : function () { | 
|  | 214 | if (this._root.ldType() !== "non") { | 
| Akron | 04671e7 | 2017-05-11 20:47:32 +0200 | [diff] [blame] | 215 | this._root.destroy(); | 
|  | 216 | this.root(unspecDocClass.create(this)); | 
| Nils Diewald | 6283d69 | 2015-04-23 20:32:53 +0000 | [diff] [blame] | 217 | }; | 
|  | 218 | return this; | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 219 | }, | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 220 |  | 
| Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 221 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 222 | /** | 
|  | 223 | * Get or set the root object of the | 
|  | 224 | * virtual collection. | 
|  | 225 | */ | 
| Nils Diewald | f219eb8 | 2015-01-07 20:15:42 +0000 | [diff] [blame] | 226 | root : function (obj) { | 
| Nils Diewald | 8e7182e | 2015-01-08 15:02:07 +0000 | [diff] [blame] | 227 | if (arguments.length === 1) { | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 228 | var e = this.element(); | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 229 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 230 | if (e.firstChild !== null) { | 
|  | 231 | if (e.firstChild !== obj.element()) { | 
|  | 232 | e.replaceChild(obj.element(), e.firstChild); | 
|  | 233 | }; | 
|  | 234 | } | 
| Nils Diewald | 8f6b610 | 2015-01-08 18:25:33 +0000 | [diff] [blame] | 235 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 236 | // Append root element | 
|  | 237 | else { | 
|  | 238 | e.appendChild(obj.element()); | 
|  | 239 | }; | 
| Nils Diewald | 8f6b610 | 2015-01-08 18:25:33 +0000 | [diff] [blame] | 240 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 241 | // Update parent child relations | 
|  | 242 | this._root = obj; | 
|  | 243 | obj.parent(this); | 
| Nils Diewald | 8f6b610 | 2015-01-08 18:25:33 +0000 | [diff] [blame] | 244 |  | 
| Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 245 | this.update(); | 
| Nils Diewald | 8e7182e | 2015-01-08 15:02:07 +0000 | [diff] [blame] | 246 | }; | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 247 | return this._root; | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 248 | }, | 
| Nils Diewald | 8f6b610 | 2015-01-08 18:25:33 +0000 | [diff] [blame] | 249 |  | 
| Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 250 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 251 | /** | 
|  | 252 | * Get the element associated with the virtual collection | 
|  | 253 | */ | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 254 | element : function () { | 
| Akron | 12971a0 | 2018-01-03 16:38:10 +0100 | [diff] [blame] | 255 | if (this._element !== undefined) { | 
|  | 256 | return this._element; | 
|  | 257 | }; | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 258 |  | 
|  | 259 | this._element = document.createElement('div'); | 
|  | 260 | this._element.setAttribute('class', 'vc'); | 
| Nils Diewald | 8e7182e | 2015-01-08 15:02:07 +0000 | [diff] [blame] | 261 |  | 
| Nils Diewald | 8f6b610 | 2015-01-08 18:25:33 +0000 | [diff] [blame] | 262 | // Initialize root | 
|  | 263 | this._element.appendChild(this._root.element()); | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 264 |  | 
| Nils Diewald | d077049 | 2014-12-19 03:55:00 +0000 | [diff] [blame] | 265 | return this._element; | 
| Nils Diewald | f219eb8 | 2015-01-07 20:15:42 +0000 | [diff] [blame] | 266 | }, | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 267 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 268 |  | 
|  | 269 | /** | 
|  | 270 | * Update the whole object based on the underlying | 
|  | 271 | * data structure | 
|  | 272 | */ | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 273 | update : function () { | 
|  | 274 | this._root.update(); | 
|  | 275 | return this; | 
|  | 276 | }, | 
|  | 277 |  | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 278 | /** | 
|  | 279 | * Make the vc persistant by injecting the current timestamp | 
|  | 280 | * as a creation date limit criterion. | 
|  | 281 | */ | 
|  | 282 | makePersistant : function () { | 
| Akron | 12971a0 | 2018-01-03 16:38:10 +0100 | [diff] [blame] | 283 | // this.root().wrapOnRoot('and'); | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 284 | var todayStr = KorAP._vcDatePicker.today(); | 
|  | 285 | var doc = docClass.create(); | 
|  | 286 | var root = this.root(); | 
|  | 287 |  | 
|  | 288 | if (root.ldType() === 'docGroup' && | 
| Akron | 12971a0 | 2018-01-03 16:38:10 +0100 | [diff] [blame] | 289 | root.operation === 'and') { | 
|  | 290 | root.append(cond); | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 291 | } | 
|  | 292 | else { | 
| Akron | 12971a0 | 2018-01-03 16:38:10 +0100 | [diff] [blame] | 293 | root.wrapOnRoot('and'); | 
|  | 294 | root.append(doc); | 
| Nils Diewald | 845282c | 2015-05-14 07:53:03 +0000 | [diff] [blame] | 295 | }; | 
|  | 296 |  | 
|  | 297 | doc.key("creationDate"); | 
|  | 298 | doc.type("date"); | 
|  | 299 | doc.matchop("leq"); | 
|  | 300 | doc.value(todayStr); | 
|  | 301 |  | 
|  | 302 | /* | 
|  | 303 | { | 
|  | 304 | "@type" : "koral:doc", | 
|  | 305 | "key" : "creationDate", | 
|  | 306 | "type" : "type:date", | 
|  | 307 | "match" : "match:leq", | 
|  | 308 | "value" : todayStr | 
|  | 309 | } | 
|  | 310 | this.root().append(cond); | 
|  | 311 | */ | 
|  | 312 | this.update(); | 
|  | 313 | }, | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 314 |  | 
|  | 315 | /** | 
|  | 316 | * Get the generated json string | 
|  | 317 | */ | 
| Nils Diewald | f219eb8 | 2015-01-07 20:15:42 +0000 | [diff] [blame] | 318 | toJson : function () { | 
|  | 319 | return this._root.toJson(); | 
|  | 320 | }, | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 321 |  | 
| Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 322 |  | 
|  | 323 | /** | 
|  | 324 | * Get the generated query string | 
|  | 325 | */ | 
| Nils Diewald | d599d54 | 2015-01-08 20:41:34 +0000 | [diff] [blame] | 326 | toQuery : function () { | 
|  | 327 | return this._root.toQuery(); | 
| hebasta | ccb8fa3 | 2018-06-05 17:02:16 +0200 | [diff] [blame] | 328 | }, | 
|  | 329 |  | 
|  | 330 |  | 
|  | 331 | /** | 
|  | 332 | * Get associated corpus statistic, | 
|  | 333 | * create corpus statistic if it is unassigned | 
|  | 334 | */ | 
|  | 335 | statistic : function(){ | 
|  | 336 | if(this.corpStat == undefined){ | 
|  | 337 | this.corpStat = statClass.create(); | 
|  | 338 | } | 
|  | 339 | return this.corpStat; | 
|  | 340 | } | 
|  | 341 |  | 
| Nils Diewald | 3a2d802 | 2014-12-16 02:45:41 +0000 | [diff] [blame] | 342 | }; | 
| Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 343 | }); |