blob: 42e51c3159cc00afc9e7f4b2b952858aabe05c72 [file] [log] [blame]
Nils Diewald3a2d8022014-12-16 02:45:41 +00001var KorAP = KorAP || {};
Nils Diewald3a2d8022014-12-16 02:45:41 +00002
Nils Diewald8f4e2542014-12-19 04:42:09 +00003// TODO: Implement a working localization solution!
Nils Diewald52f7eb12015-01-12 17:30:04 +00004// TODO: Remove "and" or "or" in case it's followed
5// by an unspecified document
6// TODO: Add 'or' or 'and' on root
Nils Diewaldd0770492014-12-19 03:55:00 +00007
8/*
Nils Diewaldd599d542015-01-08 20:41:34 +00009 Error codes:
Nils Diewaldd0770492014-12-19 03:55:00 +000010 701: "JSON-LD group has no @type attribute"
11 704: "Operation needs operand list"
Nils Diewald3a2d8022014-12-16 02:45:41 +000012 802: "Match type is not supported by value type"
13 804: "Unknown value type"
14 805: "Value is invalid"
15 806: "Value is not a valid date string"
16 807: "Value is not a valid regular expression"
Nils Diewald3a2d8022014-12-16 02:45:41 +000017 810: "Unknown document group operation" (like 711)
18 811: "Document group expects operation" (like 703)
19 812: "Operand not supported in document group" (like 744)
Nils Diewaldd0770492014-12-19 03:55:00 +000020 813: "Collection type is not supported" (like 713)
21*/
22
Nils Diewald3a2d8022014-12-16 02:45:41 +000023(function (KorAP) {
24 "use strict";
25
26 // Default log message
27 KorAP.log = KorAP.log || function (type, msg) {
28 console.log(type + ": " + msg);
29 };
30
31 KorAP._validStringMatchRE = new RegExp("^(?:eq|ne|contains)$");
32 KorAP._validRegexMatchRE = new RegExp("^(?:eq|ne)$");
Nils Diewaldd0770492014-12-19 03:55:00 +000033 KorAP._validDateMatchRE = new RegExp("^[lg]?eq$");
Nils Diewald3a2d8022014-12-16 02:45:41 +000034 KorAP._validDateRE = new RegExp("^(?:\\d{4})(?:-\\d\\d(?:-\\d\\d)?)?$");
35 KorAP._validGroupOpRE = new RegExp("^(?:and|or)$");
Nils Diewaldf219eb82015-01-07 20:15:42 +000036 KorAP._quote = new RegExp("([\"\\\\])", 'g');
Nils Diewald3a2d8022014-12-16 02:45:41 +000037
Nils Diewalde15b7a22015-01-09 21:50:21 +000038 // Localization values
Nils Diewaldf219eb82015-01-07 20:15:42 +000039 var loc = (KorAP.Locale = KorAP.Locale || {} );
40 loc.AND = loc.AND || 'and';
41 loc.OR = loc.OR || 'or';
42 loc.DEL = loc.DEL || '×';
43 loc.EMPTY = loc.EMPTY || '⋯'
Nils Diewaldd0770492014-12-19 03:55:00 +000044
Nils Diewaldd599d542015-01-08 20:41:34 +000045
Nils Diewalde15b7a22015-01-09 21:50:21 +000046 // Utility for analysing boolean values
Nils Diewald966abf12014-12-20 02:27:45 +000047 function _bool (bool) {
Nils Diewalde15b7a22015-01-09 21:50:21 +000048 return (bool === undefined || bool === null || bool === false) ? false : true;
Nils Diewald966abf12014-12-20 02:27:45 +000049 };
50
Nils Diewaldd599d542015-01-08 20:41:34 +000051
Nils Diewalde15b7a22015-01-09 21:50:21 +000052 // Utility for removing all children of a node
Nils Diewald966abf12014-12-20 02:27:45 +000053 function _removeChildren (node) {
54 // Remove everything underneath
Nils Diewald8f6b6102015-01-08 18:25:33 +000055 while (node.firstChild)
Nils Diewald966abf12014-12-20 02:27:45 +000056 node.removeChild(node.firstChild);
Nils Diewald966abf12014-12-20 02:27:45 +000057 };
58
Nils Diewald4019bd22015-01-08 19:57:50 +000059
Nils Diewald52f7eb12015-01-12 17:30:04 +000060 // Add new unspecified document
Nils Diewald9fcc1712015-01-09 14:24:32 +000061 KorAP._add = function (obj, type) {
62 var ref = obj.parentNode.refTo;
Nils Diewaldd5070b02015-01-11 01:44:47 +000063 var parent = ref.parent();
Nils Diewald52f7eb12015-01-12 17:30:04 +000064
Nils Diewald9fcc1712015-01-09 14:24:32 +000065 if (ref.ldType() === 'docGroup') {
Nils Diewaldd5070b02015-01-11 01:44:47 +000066
67 // Check that the action differs from the type
68 if (ref.operation() === type)
69 return;
70
71 if (parent.ldType() !== null) {
72 return parent.newAfter(ref);
Nils Diewald9fcc1712015-01-09 14:24:32 +000073 }
74 else {
Nils Diewaldd5070b02015-01-11 01:44:47 +000075 // The group is on root - wrap
76 return ref.wrapOnRoot();
77 };
78 }
79 else if (ref.ldType() === 'doc') {
Nils Diewald52f7eb12015-01-12 17:30:04 +000080
81 if (parent.ldType() === null) {
82 return ref.wrapOnRoot(type);
83 }
84 else if (parent.operation() === type) {
Nils Diewaldd5070b02015-01-11 01:44:47 +000085 return parent.newAfter(ref);
86 }
87 else {
88 return ref.wrap(type);
Nils Diewald9fcc1712015-01-09 14:24:32 +000089 };
Nils Diewaldd599d542015-01-08 20:41:34 +000090 };
Nils Diewald4019bd22015-01-08 19:57:50 +000091 };
92
Nils Diewaldd599d542015-01-08 20:41:34 +000093
Nils Diewalde15b7a22015-01-09 21:50:21 +000094 // Add doc with 'and' relation
95 KorAP._and = function () {
96 return KorAP._add(this, 'and');
97 };
98
99
100 // Add doc with 'or' relation
101 KorAP._or = function () {
102 return KorAP._add(this, 'or');
103 };
104
Nils Diewald52f7eb12015-01-12 17:30:04 +0000105
Nils Diewald4019bd22015-01-08 19:57:50 +0000106 // Remove doc or docGroup
Nils Diewalde15b7a22015-01-09 21:50:21 +0000107 KorAP._delete = function () {
Nils Diewald9fcc1712015-01-09 14:24:32 +0000108 var ref = this.parentNode.refTo;
Nils Diewald52f7eb12015-01-12 17:30:04 +0000109 if (ref.parent().ldType() !== null) {
110 return ref.parent().delOperand(ref).update();
111 }
112 else {
Nils Diewald9fcc1712015-01-09 14:24:32 +0000113 ref.parent().clean();
Nils Diewald52f7eb12015-01-12 17:30:04 +0000114 };
Nils Diewald4019bd22015-01-08 19:57:50 +0000115 };
116
Nils Diewaldd599d542015-01-08 20:41:34 +0000117
118 /**
119 * Virtual Collection
120 */
Nils Diewald3a2d8022014-12-16 02:45:41 +0000121 KorAP.VirtualCollection = {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000122 ldType : function () {
123 return null;
124 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000125
Nils Diewald3a2d8022014-12-16 02:45:41 +0000126 create : function () {
127 return Object.create(KorAP.VirtualCollection);
128 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000129
Nils Diewald4019bd22015-01-08 19:57:50 +0000130 clean : function () {
131 if (this._root.ldType() !== "non") {
132 this._root.destroy();
133 this.root(KorAP.UnspecifiedDoc.create(this));
134 };
135 return this;
136 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000137
Nils Diewaldd0770492014-12-19 03:55:00 +0000138 render : function (json) {
139 var obj = Object.create(KorAP.VirtualCollection);
140
141 if (json !== undefined) {
142 // Root object
143 if (json['@type'] == 'korap:doc') {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000144 obj._root = KorAP.Doc.create(obj, json);
Nils Diewaldd0770492014-12-19 03:55:00 +0000145 }
146 else if (json['@type'] == 'korap:docGroup') {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000147 obj._root = KorAP.DocGroup.create(obj, json);
Nils Diewaldd0770492014-12-19 03:55:00 +0000148 }
149 else {
150 KorAP.log(813, "Collection type is not supported");
151 return;
152 };
153 }
154
155 else {
156 // Add unspecified object
Nils Diewaldf219eb82015-01-07 20:15:42 +0000157 obj._root = KorAP.UnspecifiedDoc.create(obj);
Nils Diewaldd0770492014-12-19 03:55:00 +0000158 };
159
Nils Diewald8e7182e2015-01-08 15:02:07 +0000160 // Init element and update
161 obj.update();
Nils Diewaldd0770492014-12-19 03:55:00 +0000162
163 return obj;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000164 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000165
Nils Diewaldf219eb82015-01-07 20:15:42 +0000166 root : function (obj) {
Nils Diewald8e7182e2015-01-08 15:02:07 +0000167 if (arguments.length === 1) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000168 var e = this.element();
169 if (e.firstChild !== null) {
Nils Diewaldd5070b02015-01-11 01:44:47 +0000170 if (e.firstChild !== obj.element()) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000171 e.replaceChild(obj.element(), e.firstChild);
Nils Diewaldd5070b02015-01-11 01:44:47 +0000172 };
Nils Diewald8f6b6102015-01-08 18:25:33 +0000173 }
174
175 // Append root element
176 else {
177 e.appendChild(obj.element());
178 };
179
180 // Update parent child relations
Nils Diewaldf219eb82015-01-07 20:15:42 +0000181 this._root = obj;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000182 obj.parent(this);
183
Nils Diewald8e7182e2015-01-08 15:02:07 +0000184 this.update();
185 };
Nils Diewaldd0770492014-12-19 03:55:00 +0000186 return this._root;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000187 },
Nils Diewald8f6b6102015-01-08 18:25:33 +0000188
Nils Diewaldd0770492014-12-19 03:55:00 +0000189 element : function () {
190 if (this._element !== undefined)
191 return this._element;
192
193 this._element = document.createElement('div');
194 this._element.setAttribute('class', 'vc');
Nils Diewald8e7182e2015-01-08 15:02:07 +0000195
Nils Diewald8f6b6102015-01-08 18:25:33 +0000196 // Initialize root
197 this._element.appendChild(this._root.element());
198
Nils Diewaldd0770492014-12-19 03:55:00 +0000199 return this._element;
Nils Diewaldf219eb82015-01-07 20:15:42 +0000200 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000201
202 update : function () {
203 this._root.update();
204 return this;
205 },
206
Nils Diewaldf219eb82015-01-07 20:15:42 +0000207 toJson : function () {
208 return this._root.toJson();
209 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000210
211 toQuery : function () {
212 return this._root.toQuery();
Nils Diewald3a2d8022014-12-16 02:45:41 +0000213 }
214 };
215
Nils Diewaldd599d542015-01-08 20:41:34 +0000216
Nils Diewald8f4e2542014-12-19 04:42:09 +0000217 /**
218 * Operators for criteria
219 */
Nils Diewaldd0770492014-12-19 03:55:00 +0000220 KorAP.Operators = {
221 create : function (and, or, del) {
222 var op = Object.create(KorAP.Operators);
223 op.and(and);
224 op.or(or);
225 op.del(del);
226 return op;
227 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000228
Nils Diewaldd0770492014-12-19 03:55:00 +0000229 update : function () {
Nils Diewaldd0770492014-12-19 03:55:00 +0000230 // Init the element
231 if (this._element === undefined)
232 return this.element();
233
234 var op = this._element;
235
Nils Diewald0297ba12015-01-05 21:56:12 +0000236 op.refTo = this.parent();
237
Nils Diewaldd0770492014-12-19 03:55:00 +0000238 // Remove everything underneath
Nils Diewald966abf12014-12-20 02:27:45 +0000239 _removeChildren(op);
Nils Diewaldd0770492014-12-19 03:55:00 +0000240
241 // Add and button
242 if (this._and === true) {
243 var andE = document.createElement('span');
244 andE.setAttribute('class', 'and');
Nils Diewalde15b7a22015-01-09 21:50:21 +0000245 andE.addEventListener('click', KorAP._and, false);
Nils Diewald8f6b6102015-01-08 18:25:33 +0000246 andE.appendChild(
247 document.createTextNode(KorAP.Locale.AND)
248 );
Nils Diewaldd0770492014-12-19 03:55:00 +0000249 op.appendChild(andE);
250 };
251
252 // Add or button
253 if (this._or === true) {
254 var orE = document.createElement('span');
255 orE.setAttribute('class', 'or');
Nils Diewalde15b7a22015-01-09 21:50:21 +0000256 orE.addEventListener('click', KorAP._or, false);
Nils Diewaldd0770492014-12-19 03:55:00 +0000257 orE.appendChild(document.createTextNode(KorAP.Locale.OR));
258 op.appendChild(orE);
259 };
260
261 // Add delete button
262 if (this._del === true) {
263 var delE = document.createElement('span');
264 delE.setAttribute('class', 'delete');
265 delE.appendChild(document.createTextNode(KorAP.Locale.DEL));
Nils Diewald0297ba12015-01-05 21:56:12 +0000266 delE.addEventListener('click', KorAP._delete, false);
Nils Diewaldd0770492014-12-19 03:55:00 +0000267 op.appendChild(delE);
268 };
Nils Diewald966abf12014-12-20 02:27:45 +0000269
270 return op;
Nils Diewaldd0770492014-12-19 03:55:00 +0000271 },
Nils Diewald0297ba12015-01-05 21:56:12 +0000272
273 // Be aware! This may be cyclic
274 parent : function (obj) {
275 if (arguments.length === 1)
276 this._parent = obj;
277 return this._parent;
278 },
Nils Diewald5c817a42015-01-06 01:08:56 +0000279
Nils Diewaldd0770492014-12-19 03:55:00 +0000280 element : function () {
281
282 // Return existing element
283 if (this._element !== undefined)
284 return this._element;
285
286 this._element = document.createElement('div');
287 this._element.setAttribute('class', 'operators');
288
289 // Init elements
290 this.update();
291 return this._element;
292 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000293
Nils Diewaldd0770492014-12-19 03:55:00 +0000294 and : function (bool) {
295 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000296 this._and = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000297 return this._and;
298 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000299
Nils Diewaldd0770492014-12-19 03:55:00 +0000300 or : function (bool) {
301 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000302 this._or = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000303 return this._or;
304 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000305
Nils Diewaldd0770492014-12-19 03:55:00 +0000306 del : function (bool) {
307 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000308 this._del = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000309 return this._del;
310 }
311 };
312
313
314 /**
315 * Unspecified criterion
316 */
Nils Diewald8f4e2542014-12-19 04:42:09 +0000317 KorAP.UnspecifiedDoc = {
Nils Diewald4019bd22015-01-08 19:57:50 +0000318 _ldType : "non",
Nils Diewaldd0770492014-12-19 03:55:00 +0000319 create : function (parent) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000320 var obj = Object.create(KorAP.JsonLD).
321 upgradeTo(KorAP.UnspecifiedDoc);
322
Nils Diewaldd0770492014-12-19 03:55:00 +0000323 if (parent !== undefined)
324 obj._parent = parent;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000325
Nils Diewaldd0770492014-12-19 03:55:00 +0000326 return obj;
327 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000328
Nils Diewald966abf12014-12-20 02:27:45 +0000329 update : function () {
Nils Diewald4019bd22015-01-08 19:57:50 +0000330
Nils Diewald966abf12014-12-20 02:27:45 +0000331 if (this._element === undefined)
332 return this.element();
333
Nils Diewald8f6b6102015-01-08 18:25:33 +0000334 // Remove element content
Nils Diewald966abf12014-12-20 02:27:45 +0000335 _removeChildren(this._element);
336
337 var ellipsis = document.createElement('span');
Nils Diewaldf219eb82015-01-07 20:15:42 +0000338 ellipsis.appendChild(document.createTextNode(loc.EMPTY));
Nils Diewald966abf12014-12-20 02:27:45 +0000339 this._element.appendChild(ellipsis);
340
341 // Set operators
Nils Diewalde15b7a22015-01-09 21:50:21 +0000342 if (this._parent !== undefined && this.parent().ldType() !== null) {
343 var op = this.operators(
344 false,
345 false,
346 true
347 );
Nils Diewald966abf12014-12-20 02:27:45 +0000348
Nils Diewalde15b7a22015-01-09 21:50:21 +0000349 this._element.appendChild(
350 op.element()
351 );
352 };
Nils Diewald966abf12014-12-20 02:27:45 +0000353
Nils Diewald966abf12014-12-20 02:27:45 +0000354 return this.element();
355 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000356
Nils Diewaldd0770492014-12-19 03:55:00 +0000357 element : function () {
358 if (this._element !== undefined)
359 return this._element;
360 this._element = document.createElement('div');
Nils Diewaldd599d542015-01-08 20:41:34 +0000361 this._element.setAttribute('class', 'doc unspecified');
Nils Diewald966abf12014-12-20 02:27:45 +0000362 this.update();
Nils Diewaldd0770492014-12-19 03:55:00 +0000363 return this._element;
364 }
365 };
366
367
Nils Diewald8f4e2542014-12-19 04:42:09 +0000368 /**
Nils Diewaldd599d542015-01-08 20:41:34 +0000369 * Document criterion
Nils Diewald8f4e2542014-12-19 04:42:09 +0000370 */
371 KorAP.Doc = {
372 _ldType : "doc",
373 _obj : function () { return KorAP.Doc; },
Nils Diewaldd0770492014-12-19 03:55:00 +0000374
375 create : function (parent, json) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000376 var obj = Object(KorAP.JsonLD).
377 create().
378 upgradeTo(KorAP.Doc).
379 fromJson(json);
380
Nils Diewaldd0770492014-12-19 03:55:00 +0000381 if (parent !== undefined)
382 obj._parent = parent;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000383
384 obj._changed = true;
Nils Diewaldd0770492014-12-19 03:55:00 +0000385 return obj;
386 },
Nils Diewald5c817a42015-01-06 01:08:56 +0000387
Nils Diewald966abf12014-12-20 02:27:45 +0000388 update : function () {
389 if (this._element === undefined)
390 return this.element();
Nils Diewaldd0770492014-12-19 03:55:00 +0000391
Nils Diewald8f6b6102015-01-08 18:25:33 +0000392 // Get element
Nils Diewald966abf12014-12-20 02:27:45 +0000393 var e = this._element;
394
Nils Diewald8f6b6102015-01-08 18:25:33 +0000395 // Check if there is a change
396 if (this._changed) {
Nils Diewald966abf12014-12-20 02:27:45 +0000397
Nils Diewald8f6b6102015-01-08 18:25:33 +0000398 // Added key
399 var key = document.createElement('span');
400 key.setAttribute('class', 'key');
401 if (this.key())
402 key.appendChild(document.createTextNode(this.key()));
Nils Diewald966abf12014-12-20 02:27:45 +0000403
Nils Diewald8f6b6102015-01-08 18:25:33 +0000404 // Added match operator
405 var matchop = document.createElement('span');
406 matchop.setAttribute('data-type', this.type());
407 matchop.setAttribute('class', 'match');
408 matchop.appendChild(
409 document.createTextNode(this.matchop())
410 );
411
412 // Added match operator
413 var value = document.createElement('span');
414 value.setAttribute('data-type', this.type());
415 value.setAttribute('class', 'value');
416 if (this.value())
417 value.appendChild(
418 document.createTextNode(this.value())
419 );
420
421 // Remove all element children
422 _removeChildren(e);
423
424 // Add spans
425 e.appendChild(key);
426 e.appendChild(matchop);
427 e.appendChild(value);
428
429 this._changed = false;
430 };
431
432 if (this._parent !== undefined) {
433 // Set operators
434 var op = this.operators(
435 true,
436 true,
Nils Diewald4019bd22015-01-08 19:57:50 +0000437 true
Nils Diewald8f6b6102015-01-08 18:25:33 +0000438 );
439
440 // Append new operators
441 e.appendChild(op.element());
442 };
Nils Diewald966abf12014-12-20 02:27:45 +0000443
Nils Diewaldd0770492014-12-19 03:55:00 +0000444 return e;
445 },
446
Nils Diewald966abf12014-12-20 02:27:45 +0000447 element : function () {
448 if (this._element !== undefined)
449 return this._element;
450
451 this._element = document.createElement('div');
452 this._element.setAttribute('class', 'doc');
453
454 this.update();
455 return this._element;
456 },
457
Nils Diewaldd0770492014-12-19 03:55:00 +0000458 // Wrap a new operation around the doc element
459 wrap : function (op) {
Nils Diewald9fcc1712015-01-09 14:24:32 +0000460 var parent = this.parent();
461 var group = KorAP.DocGroup.create(parent);
462 group.operation(op);
Nils Diewald966abf12014-12-20 02:27:45 +0000463 group.append(this);
Nils Diewald9fcc1712015-01-09 14:24:32 +0000464 group.append();
465 return parent.replaceOperand(this, group).update();
Nils Diewaldd0770492014-12-19 03:55:00 +0000466 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000467
Nils Diewald3a2d8022014-12-16 02:45:41 +0000468 // Deserialize from json
469 fromJson : function (json) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000470 if (json === undefined)
Nils Diewaldd0770492014-12-19 03:55:00 +0000471 return this;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000472
Nils Diewald3a2d8022014-12-16 02:45:41 +0000473 if (json["@type"] !== "korap:doc") {
474 KorAP.log(701, "JSON-LD group has no @type attribute");
475 return;
476 };
477
Nils Diewald3a2d8022014-12-16 02:45:41 +0000478 if (json["value"] === undefined ||
479 typeof json["value"] != 'string') {
480 KorAP.log(805, "Value is invalid");
481 return;
482 };
483
484 // There is a defined key
485 if (json["key"] !== undefined &&
486 typeof json["key"] === 'string') {
487
488 // Set key
Nils Diewaldd0770492014-12-19 03:55:00 +0000489 this.key(json["key"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000490
491 // Set match operation
492 if (json["match"] !== undefined) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000493 if (typeof json["match"] === 'string') {
494 this.matchop(json["match"]);
495 }
Nils Diewald3a2d8022014-12-16 02:45:41 +0000496 else {
497 KorAP.log(802, "Match type is not supported by value type");
498 return;
499 };
500 };
501
502 // Key is a string
503 if (json["type"] === undefined ||
504 json["type"] == "type:string") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000505 this.type("string");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000506
507 // Check match type
Nils Diewaldd0770492014-12-19 03:55:00 +0000508 if (!KorAP._validStringMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000509 KorAP.log(802, "Match type is not supported by value type");
510 return;
511 };
512
513 // Set string value
Nils Diewaldd0770492014-12-19 03:55:00 +0000514 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000515 }
516
517 // Key is a date
518 else if (json["type"] === "type:date") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000519 this.type("date");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000520
521 if (json["value"] !== undefined &&
522 KorAP._validDateRE.test(json["value"])) {
523
Nils Diewaldd0770492014-12-19 03:55:00 +0000524 if (!KorAP._validDateMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000525 KorAP.log(802, "Match type is not supported by value type");
526 return;
527 };
528
529 // Set value
Nils Diewaldd0770492014-12-19 03:55:00 +0000530 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000531 }
532 else {
533 KorAP.log(806, "Value is not a valid date string");
534 return;
535 };
536 }
537
538 // Key is a regular expression
539 else if (json["type"] === "type:regex") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000540 this.type("regex");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000541
542 try {
543
544 // Try to create a regular expression
545 var check = new RegExp(json["value"]);
546
Nils Diewaldd0770492014-12-19 03:55:00 +0000547 if (!KorAP._validRegexMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000548 KorAP.log(802, "Match type is not supported by value type");
549 return;
550 };
551
Nils Diewaldd0770492014-12-19 03:55:00 +0000552 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000553 }
Nils Diewaldd0770492014-12-19 03:55:00 +0000554
Nils Diewald3a2d8022014-12-16 02:45:41 +0000555 catch (e) {
556 KorAP.log(807, "Value is not a valid regular expression");
557 return;
558 };
Nils Diewaldd0770492014-12-19 03:55:00 +0000559 this.type("regex");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000560 }
561
562 else {
563 KorAP.log(804, "Unknown value type");
564 return;
565 };
566 };
567
568 return this;
569 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000570
Nils Diewaldd0770492014-12-19 03:55:00 +0000571 key : function (value) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000572 if (arguments.length === 1) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000573 this._key = value;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000574 this._changed = true;
575 };
Nils Diewald3a2d8022014-12-16 02:45:41 +0000576 return this._key;
577 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000578
Nils Diewaldd0770492014-12-19 03:55:00 +0000579 matchop : function (match) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000580 if (arguments.length === 1) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000581 this._matchop = match.replace(/^match:/, '');
Nils Diewald8f6b6102015-01-08 18:25:33 +0000582 this._changed = true;
583 };
Nils Diewald3a2d8022014-12-16 02:45:41 +0000584 return this._matchop || "eq";
585 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000586
Nils Diewaldd0770492014-12-19 03:55:00 +0000587 type : function (type) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000588 if (arguments.length === 1) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000589 this._type = type;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000590 this._changed = true;
591 };
Nils Diewald3a2d8022014-12-16 02:45:41 +0000592 return this._type || "string";
593 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000594
Nils Diewaldd0770492014-12-19 03:55:00 +0000595 value : function (value) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000596 if (arguments.length === 1) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000597 this._value = value;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000598 this._changed = true;
599 };
Nils Diewald3a2d8022014-12-16 02:45:41 +0000600 return this._value;
601 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000602
Nils Diewald3a2d8022014-12-16 02:45:41 +0000603 toJson : function () {
Nils Diewaldd0770492014-12-19 03:55:00 +0000604 if (!this.matchop() || !this.key())
Nils Diewald3a2d8022014-12-16 02:45:41 +0000605 return {};
606
607 return {
Nils Diewaldd0770492014-12-19 03:55:00 +0000608 "@type" : "korap:" + this.ldType(),
609 "key" : this.key(),
610 "match" : "match:" + this.matchop(),
611 "value" : this.value() || '',
612 "type" : "type:" + this.type()
Nils Diewald3a2d8022014-12-16 02:45:41 +0000613 };
Nils Diewaldf219eb82015-01-07 20:15:42 +0000614 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000615
616 toQuery : function () {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000617 if (!this.matchop() || !this.key())
618 return "";
619
620 // Build doc string based on key
621 var string = this.key() + ' ';
622
623 // Add match operator
624 switch (this.matchop()) {
625 case "ne":
626 string += '!=';
627 break;
628 case "contains":
629 string += '~';
630 break;
631 case "geq":
632 string += 'since';
633 break;
634 case "leq":
635 string += 'until';
636 break;
637 default:
638 string += (this.type() == 'date') ? 'in' : '=';
639 break;
640 };
641
642 string += ' ';
643
644 // Add value
645 switch (this.type()) {
646 case "date":
647 return string + this.value();
648 break;
649 case "regex":
650 return string + '/' + this.value() + '/';
651 break;
652 case "string":
653 return string + '"' + this.value().replace(KorAP._quote, '\\$1') + '"';
654 break;
655 };
656
Nils Diewaldd599d542015-01-08 20:41:34 +0000657 return "";
Nils Diewald3a2d8022014-12-16 02:45:41 +0000658 }
659 };
Nils Diewald8f4e2542014-12-19 04:42:09 +0000660
Nils Diewaldd599d542015-01-08 20:41:34 +0000661
Nils Diewald8f4e2542014-12-19 04:42:09 +0000662 /**
Nils Diewaldd599d542015-01-08 20:41:34 +0000663 * Document group criterion
Nils Diewald8f4e2542014-12-19 04:42:09 +0000664 */
665 KorAP.DocGroup = {
666 _ldType : "docGroup",
667
668 create : function (parent, json) {
669 var obj = Object.create(KorAP.JsonLD).upgradeTo(KorAP.DocGroup);
670 obj._operands = [];
671 obj.fromJson(json);
672 if (parent !== undefined)
673 obj._parent = parent;
674 return obj;
675 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000676
677 newAfter : function (obj) {
Nils Diewald52f7eb12015-01-12 17:30:04 +0000678 for (var i = 0; i < this._operands.length; i++) {
Nils Diewaldd599d542015-01-08 20:41:34 +0000679 if (this._operands[i] === obj) {
680 var operand = KorAP.UnspecifiedDoc.create(this);
681 this._operands.splice(i + 1, 0, operand);
682 return this.update();
683 };
684 };
685 },
686
Nils Diewald966abf12014-12-20 02:27:45 +0000687 append : function (operand) {
688
689 // Append unspecified object
690 if (operand === undefined) {
691
692 // Be aware of cyclic structures!
693 operand = KorAP.UnspecifiedDoc.create(this);
694 this._operands.push(operand);
Nils Diewald966abf12014-12-20 02:27:45 +0000695 return operand;
696 };
697
Nils Diewald8f4e2542014-12-19 04:42:09 +0000698 switch (operand["@type"]) {
699 case undefined:
700 if (operand["ldType"] !== undefined) {
701 if (operand.ldType() !== 'doc' &&
Nils Diewald966abf12014-12-20 02:27:45 +0000702 operand.ldType() !== 'docGroup') {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000703 KorAP.log(812, "Operand not supported in document group");
704 return;
705 };
Nils Diewald966abf12014-12-20 02:27:45 +0000706 // Be aware of cyclic structures!
707 operand.parent(this);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000708 this._operands.push(operand);
709 return operand;
710 };
711
712 KorAP.log(701, "JSON-LD group has no @type attribute");
713 return;
714
715 case "korap:doc":
Nils Diewald966abf12014-12-20 02:27:45 +0000716 // Be aware of cyclic structures!
717 var doc = KorAP.Doc.create(this, operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000718 if (doc === undefined)
719 return;
720 this._operands.push(doc);
721 return doc;
722
723 case "korap:docGroup":
Nils Diewald966abf12014-12-20 02:27:45 +0000724 // Be aware of cyclic structures!
725 var docGroup = KorAP.DocGroup.create(this, operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000726 if (docGroup === undefined)
727 return;
728 this._operands.push(docGroup);
729 return docGroup;
730
731 default:
732 KorAP.log(812, "Operand not supported in document group");
733 return;
734 };
735 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000736
Nils Diewald966abf12014-12-20 02:27:45 +0000737 update : function () {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000738 // There is only one operand in group
Nils Diewald52f7eb12015-01-12 17:30:04 +0000739
Nils Diewaldf219eb82015-01-07 20:15:42 +0000740 if (this._operands.length === 1) {
Nils Diewald52f7eb12015-01-12 17:30:04 +0000741
Nils Diewaldf219eb82015-01-07 20:15:42 +0000742 var parent = this.parent();
Nils Diewald8e7182e2015-01-08 15:02:07 +0000743 var op = this.getOperand(0);
744
Nils Diewald8f6b6102015-01-08 18:25:33 +0000745 // This will prevent destruction of
746 // the operand
747 this._operands = [];
Nils Diewaldf219eb82015-01-07 20:15:42 +0000748
749 // Parent is a group
Nils Diewald52f7eb12015-01-12 17:30:04 +0000750 if (parent.ldType() !== null)
Nils Diewald8e7182e2015-01-08 15:02:07 +0000751 return parent.replaceOperand(this, op).update();
Nils Diewaldf219eb82015-01-07 20:15:42 +0000752
Nils Diewald8f6b6102015-01-08 18:25:33 +0000753 // Parent is vc
Nils Diewaldf219eb82015-01-07 20:15:42 +0000754 else {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000755 this.destroy();
Nils Diewald8f6b6102015-01-08 18:25:33 +0000756 // Cyclic madness
757 parent.root(op);
758 op.parent(parent);
Nils Diewaldf219eb82015-01-07 20:15:42 +0000759 return parent.root();
Nils Diewald5c817a42015-01-06 01:08:56 +0000760 };
761 };
762
Nils Diewald966abf12014-12-20 02:27:45 +0000763 if (this._element === undefined)
Nils Diewald5c817a42015-01-06 01:08:56 +0000764 return this;
Nils Diewald966abf12014-12-20 02:27:45 +0000765
Nils Diewald5c817a42015-01-06 01:08:56 +0000766 var group = this._element;
767 group.setAttribute('data-operation', this.operation());
Nils Diewald966abf12014-12-20 02:27:45 +0000768
Nils Diewald5c817a42015-01-06 01:08:56 +0000769 _removeChildren(group);
Nils Diewald966abf12014-12-20 02:27:45 +0000770
771 // Append operands
Nils Diewald52f7eb12015-01-12 17:30:04 +0000772 for (var i = 0; i < this._operands.length; i++) {
Nils Diewald5c817a42015-01-06 01:08:56 +0000773 group.appendChild(
Nils Diewald966abf12014-12-20 02:27:45 +0000774 this.getOperand(i).element()
775 );
776 };
777
778 // Set operators
779 var op = this.operators(
780 this.operation() == 'and' ? false : true,
781 this.operation() == 'or' ? false : true,
782 true
783 );
784
Nils Diewald5c817a42015-01-06 01:08:56 +0000785 group.appendChild(
Nils Diewald966abf12014-12-20 02:27:45 +0000786 op.element()
787 );
788
Nils Diewald5c817a42015-01-06 01:08:56 +0000789 return this;
Nils Diewald966abf12014-12-20 02:27:45 +0000790 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000791
Nils Diewald8f4e2542014-12-19 04:42:09 +0000792 element : function () {
793 if (this._element !== undefined)
794 return this._element;
795
796 this._element = document.createElement('div');
797 this._element.setAttribute('class', 'docGroup');
Nils Diewald8f4e2542014-12-19 04:42:09 +0000798
Nils Diewaldf219eb82015-01-07 20:15:42 +0000799 // Update the object - including optimization
Nils Diewald966abf12014-12-20 02:27:45 +0000800 this.update();
Nils Diewald8f4e2542014-12-19 04:42:09 +0000801
802 return this._element;
803 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000804
Nils Diewald8f4e2542014-12-19 04:42:09 +0000805 operation : function (op) {
806 if (arguments.length === 1) {
807 if (KorAP._validGroupOpRE.test(op)) {
808 this._op = op;
809 }
810 else {
811 KorAP.log(810, "Unknown operation type");
812 return;
813 };
814 };
815 return this._op || 'and';
816 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000817
Nils Diewald8f4e2542014-12-19 04:42:09 +0000818 operands : function () {
819 return this._operands;
820 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000821
Nils Diewald8f4e2542014-12-19 04:42:09 +0000822 getOperand : function (index) {
823 return this._operands[index];
824 },
825
Nils Diewald5c817a42015-01-06 01:08:56 +0000826 // Replace operand
Nils Diewaldf219eb82015-01-07 20:15:42 +0000827 replaceOperand : function (oldOp, newOp) {
Nils Diewald52f7eb12015-01-12 17:30:04 +0000828
829 for (var i = 0; i < this._operands.length; i++) {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000830 if (this._operands[i] === oldOp) {
831
Nils Diewalde15b7a22015-01-09 21:50:21 +0000832 // Just insert a doc or ...
833 if (newOp.ldType() === "doc" ||
Nils Diewald52f7eb12015-01-12 17:30:04 +0000834 newOp.ldType() === "non" ||
Nils Diewalde15b7a22015-01-09 21:50:21 +0000835 // ... insert a group of a different operation
836 // (i.e. "and" in "or"/"or" in "and")
837 newOp.operation() != this.operation()) {
Nils Diewaldf219eb82015-01-07 20:15:42 +0000838 this._operands[i] = newOp;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000839 newOp.parent(this);
Nils Diewaldf219eb82015-01-07 20:15:42 +0000840 }
841
842 // Flatten the group
843 else {
Nils Diewald8e7182e2015-01-08 15:02:07 +0000844 // Remove old group
845 this._operands.splice(i, 1);
846
847 // Inject new operands
Nils Diewald8f6b6102015-01-08 18:25:33 +0000848 for (var op in newOp.operands().reverse()) {
849 this._operands.splice(i, 0, newOp.getOperand(op));
850 newOp.getOperand(0).parent(this);
851 };
852 // Prevent destruction of operands
853 newOp._operands = [];
854 newOp.destroy();
Nils Diewaldf219eb82015-01-07 20:15:42 +0000855 };
856 oldOp.destroy();
857 return this;
Nils Diewald5c817a42015-01-06 01:08:56 +0000858 }
859 };
860 return false;
861 },
862
Nils Diewald0297ba12015-01-05 21:56:12 +0000863 // Delete operand from group
864 delOperand : function (obj) {
Nils Diewald52f7eb12015-01-12 17:30:04 +0000865 for (var i = 0; i < this._operands.length; i++) {
Nils Diewald0297ba12015-01-05 21:56:12 +0000866 if (this._operands[i] === obj) {
Nils Diewald8e7182e2015-01-08 15:02:07 +0000867
Nils Diewald8f6b6102015-01-08 18:25:33 +0000868 // Delete identified operand
Nils Diewald0297ba12015-01-05 21:56:12 +0000869 this._operands.splice(i,1);
870
Nils Diewald5c817a42015-01-06 01:08:56 +0000871 // Destroy object for cyclic references
872 obj.destroy();
873
Nils Diewaldf219eb82015-01-07 20:15:42 +0000874 return this;
Nils Diewald0297ba12015-01-05 21:56:12 +0000875 };
876 };
Nils Diewald5c817a42015-01-06 01:08:56 +0000877
878 // Operand not found
879 return undefined;
Nils Diewald0297ba12015-01-05 21:56:12 +0000880 },
881
Nils Diewald8f4e2542014-12-19 04:42:09 +0000882 // Deserialize from json
883 fromJson : function (json) {
884 if (json === undefined)
885 return this;
886
887 if (json["@type"] !== "korap:docGroup") {
888 KorAP.log(701, "JSON-LD group has no @type attribute");
889 return;
890 };
891
892 if (json["operation"] === undefined ||
893 typeof json["operation"] !== 'string') {
894 KorAP.log(811, "Document group expects operation");
895 return;
896 };
897
898 var operation = json["operation"];
899
900 this.operation(operation.replace(/^operation:/,''));
901
902 if (json["operands"] === undefined ||
903 !(json["operands"] instanceof Array)) {
904 KorAP.log(704, "Operation needs operand list")
905 return;
906 };
907
908 // Add all documents
909 for (var i in json["operands"]) {
910 var operand = json["operands"][i];
Nils Diewald966abf12014-12-20 02:27:45 +0000911 this.append(operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000912 };
913
914 return this;
915 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000916
Nils Diewald8f4e2542014-12-19 04:42:09 +0000917 toJson : function () {
918 var opArray = new Array();
Nils Diewald52f7eb12015-01-12 17:30:04 +0000919 for (var i = 0; i < this._operands.length; i++) {
Nils Diewalde15b7a22015-01-09 21:50:21 +0000920 if (this._operands[i].ldType() !== 'non')
921 opArray.push(this._operands[i].toJson());
Nils Diewald8f4e2542014-12-19 04:42:09 +0000922 };
923 return {
924 "@type" : "korap:" + this.ldType(),
925 "operation" : "operation:" + this.operation(),
926 "operands" : opArray
927 };
Nils Diewaldf219eb82015-01-07 20:15:42 +0000928 },
Nils Diewaldd599d542015-01-08 20:41:34 +0000929
Nils Diewalde15b7a22015-01-09 21:50:21 +0000930 toQuery : function (brackets) {
931 var list = this._operands
932 .filter(function (op) {
933 return op.ldType() !== 'non';
934 })
935 .map(function (op) {
Nils Diewaldd599d542015-01-08 20:41:34 +0000936 return (op.ldType() === 'docGroup') ?
Nils Diewalde15b7a22015-01-09 21:50:21 +0000937 op.toQuery(true) :
Nils Diewaldd599d542015-01-08 20:41:34 +0000938 op.toQuery();
Nils Diewalde15b7a22015-01-09 21:50:21 +0000939 });
940
941 if (list.length === 1)
942 return list.join('');
943 else {
944 var str = list.join(this.operation() === 'or' ? ' | ' : ' & ');
945 return brackets ? '(' + str + ')' : str;
946 };
Nils Diewald8f4e2542014-12-19 04:42:09 +0000947 }
948 };
949
950
Nils Diewaldd599d542015-01-08 20:41:34 +0000951 /**
952 * Abstract JsonLD criterion object
953 */
Nils Diewald8f4e2542014-12-19 04:42:09 +0000954 KorAP.JsonLD = {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000955 _changed : false,
956
Nils Diewald8f4e2542014-12-19 04:42:09 +0000957 create : function () {
958 return Object.create(KorAP.JsonLD);
959 },
960
961 /**
962 * Upgrade this object to another object
963 * while private data stays intact
964 */
965 upgradeTo : function (props) {
966 for (var prop in props) {
967 this[prop] = props[prop];
968 };
969 return this;
970 },
Nils Diewald8f6b6102015-01-08 18:25:33 +0000971
Nils Diewald8f4e2542014-12-19 04:42:09 +0000972 ldType : function (type) {
973 if (arguments.length === 1)
974 this._ldType = type;
975 return this._ldType;
976 },
Nils Diewald8f6b6102015-01-08 18:25:33 +0000977
Nils Diewald8f4e2542014-12-19 04:42:09 +0000978 parent : function (obj) {
Nils Diewald8f6b6102015-01-08 18:25:33 +0000979 if (arguments.length === 1) {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000980 this._parent = obj;
Nils Diewald8f6b6102015-01-08 18:25:33 +0000981 this._changed = true;
982 };
Nils Diewald8f4e2542014-12-19 04:42:09 +0000983 return this._parent;
Nils Diewald966abf12014-12-20 02:27:45 +0000984 },
Nils Diewald0297ba12015-01-05 21:56:12 +0000985
Nils Diewald5c817a42015-01-06 01:08:56 +0000986 // Destroy object - especially for
987 // acyclic structures!
988 // I'm a paranoid chicken!
989 destroy : function () {
990 if (this._ops != undefined) {
991 this._ops._parent = undefined;
992 if (this._ops._element !== undefined)
993 this._ops._element.refTo = undefined;
994 this._ops = undefined;
995 };
996 if (this._element !== undefined)
997 this._element = undefined;
998
999 // In case of a group, destroy all operands
1000 if (this._operands !== undefined) {
Nils Diewald52f7eb12015-01-12 17:30:04 +00001001 for (var i = 0; i < this._operands.length; i++)
Nils Diewald5c817a42015-01-06 01:08:56 +00001002 this.getOperand(i).destroy();
Nils Diewaldf219eb82015-01-07 20:15:42 +00001003 this._operands = [];
Nils Diewald5c817a42015-01-06 01:08:56 +00001004 };
1005 },
1006
Nils Diewald52f7eb12015-01-12 17:30:04 +00001007 // Wrap a new operation around the root group element
1008 wrapOnRoot : function (op) {
1009 var parent = this.parent();
1010
1011 var group = KorAP.DocGroup.create(parent);
1012 if (arguments.length === 1)
1013 group.operation(op);
1014 else
1015 group.operation(
1016 this.operation() === 'and' ? 'or' : 'and'
1017 );
1018 group.append(this);
1019 this.parent(group);
1020 group.append();
1021 group.element(); // Init (seems to be necessary)
1022 parent.root(group);
1023 return this.parent();
1024 },
1025
Nils Diewald0297ba12015-01-05 21:56:12 +00001026 // Be aware! This may be cyclic
Nils Diewald966abf12014-12-20 02:27:45 +00001027 operators : function (and, or, del) {
1028 if (arguments === 0)
1029 return this._ops;
1030 this._ops = KorAP.Operators.create(
1031 and, or, del
1032 );
Nils Diewald0297ba12015-01-05 21:56:12 +00001033 this._ops.parent(this);
Nils Diewald966abf12014-12-20 02:27:45 +00001034 return this._ops;
1035 },
Nils Diewald8f6b6102015-01-08 18:25:33 +00001036
Nils Diewald966abf12014-12-20 02:27:45 +00001037 toJson : function () {
1038 return {
1039 // Unspecified object
1040 "@type" : "korap:" + this.ldType()
1041 };
Nils Diewald8f6b6102015-01-08 18:25:33 +00001042 },
Nils Diewaldd599d542015-01-08 20:41:34 +00001043
1044 toQuery : function () {
Nils Diewald8f6b6102015-01-08 18:25:33 +00001045 return loc.EMPTY;
Nils Diewald8f4e2542014-12-19 04:42:09 +00001046 }
1047 };
1048
Nils Diewald3a2d8022014-12-16 02:45:41 +00001049}(this.KorAP));