blob: fe702a7e63eb32f0edaf26cad2b1f87f21e474fd [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!
4// TODO: Support 'update' method to update elements on change
Nils Diewald966abf12014-12-20 02:27:45 +00005// TODO: Implement "toQuery"
Nils Diewaldd0770492014-12-19 03:55:00 +00006
7/*
8 * Error codes:
9 701: "JSON-LD group has no @type attribute"
10 704: "Operation needs operand list"
Nils Diewald3a2d8022014-12-16 02:45:41 +000011 802: "Match type is not supported by value type"
12 804: "Unknown value type"
13 805: "Value is invalid"
14 806: "Value is not a valid date string"
15 807: "Value is not a valid regular expression"
Nils Diewald3a2d8022014-12-16 02:45:41 +000016 810: "Unknown document group operation" (like 711)
17 811: "Document group expects operation" (like 703)
18 812: "Operand not supported in document group" (like 744)
Nils Diewaldd0770492014-12-19 03:55:00 +000019 813: "Collection type is not supported" (like 713)
20*/
21
Nils Diewald3a2d8022014-12-16 02:45:41 +000022(function (KorAP) {
23 "use strict";
24
25 // Default log message
26 KorAP.log = KorAP.log || function (type, msg) {
27 console.log(type + ": " + msg);
28 };
29
30 KorAP._validStringMatchRE = new RegExp("^(?:eq|ne|contains)$");
31 KorAP._validRegexMatchRE = new RegExp("^(?:eq|ne)$");
Nils Diewaldd0770492014-12-19 03:55:00 +000032 KorAP._validDateMatchRE = new RegExp("^[lg]?eq$");
Nils Diewald3a2d8022014-12-16 02:45:41 +000033 KorAP._validDateRE = new RegExp("^(?:\\d{4})(?:-\\d\\d(?:-\\d\\d)?)?$");
34 KorAP._validGroupOpRE = new RegExp("^(?:and|or)$");
35
Nils Diewaldd0770492014-12-19 03:55:00 +000036 var loc = (KorAP.Locale = KorAP.Locale || {} );
37 loc.AND = loc.AND || 'and';
38 loc.OR = loc.OR || 'or';
39 loc.DEL = loc.DEL || '×';
40
Nils Diewald966abf12014-12-20 02:27:45 +000041 function _bool (bool) {
42 return (bool === undefined || bool === false) ? false : true;
43 };
44
45 function _removeChildren (node) {
46 // Remove everything underneath
47 while (node.firstChild) {
48 node.removeChild(node.firstChild);
49 };
50 };
51
Nils Diewald3a2d8022014-12-16 02:45:41 +000052 KorAP.VirtualCollection = {
Nils Diewaldd0770492014-12-19 03:55:00 +000053 _root : undefined,
Nils Diewald3a2d8022014-12-16 02:45:41 +000054 create : function () {
55 return Object.create(KorAP.VirtualCollection);
56 },
Nils Diewaldd0770492014-12-19 03:55:00 +000057 render : function (json) {
58 var obj = Object.create(KorAP.VirtualCollection);
59
60 if (json !== undefined) {
61 // Root object
62 if (json['@type'] == 'korap:doc') {
Nils Diewald8f4e2542014-12-19 04:42:09 +000063 obj._root = KorAP.Doc.create(undefined, json);
Nils Diewaldd0770492014-12-19 03:55:00 +000064 }
65 else if (json['@type'] == 'korap:docGroup') {
Nils Diewald8f4e2542014-12-19 04:42:09 +000066 obj._root = KorAP.DocGroup.create(undefined, json);
Nils Diewaldd0770492014-12-19 03:55:00 +000067 }
68 else {
69 KorAP.log(813, "Collection type is not supported");
70 return;
71 };
72 }
73
74 else {
75 // Add unspecified object
Nils Diewald8f4e2542014-12-19 04:42:09 +000076 obj._root = KorAP.UnspecifiedDoc.create();
Nils Diewaldd0770492014-12-19 03:55:00 +000077 };
78
79 // Add root element to root node
80 obj.element().appendChild(
81 obj._root.element()
82 );
83
84 return obj;
Nils Diewald3a2d8022014-12-16 02:45:41 +000085 },
Nils Diewaldd0770492014-12-19 03:55:00 +000086 root : function () {
87 return this._root;
Nils Diewald3a2d8022014-12-16 02:45:41 +000088 },
Nils Diewaldd0770492014-12-19 03:55:00 +000089 element : function () {
90 if (this._element !== undefined)
91 return this._element;
92
93 this._element = document.createElement('div');
94 this._element.setAttribute('class', 'vc');
95 return this._element;
Nils Diewald3a2d8022014-12-16 02:45:41 +000096 }
97 };
98
Nils Diewald8f4e2542014-12-19 04:42:09 +000099 /**
100 * Operators for criteria
101 */
Nils Diewaldd0770492014-12-19 03:55:00 +0000102 KorAP.Operators = {
103 create : function (and, or, del) {
104 var op = Object.create(KorAP.Operators);
105 op.and(and);
106 op.or(or);
107 op.del(del);
108 return op;
109 },
110 update : function () {
111
112 // Init the element
113 if (this._element === undefined)
114 return this.element();
115
116 var op = this._element;
117
118 // Remove everything underneath
Nils Diewald966abf12014-12-20 02:27:45 +0000119 _removeChildren(op);
Nils Diewaldd0770492014-12-19 03:55:00 +0000120
121 // Add and button
122 if (this._and === true) {
123 var andE = document.createElement('span');
124 andE.setAttribute('class', 'and');
125 andE.appendChild(document.createTextNode(KorAP.Locale.AND));
126 op.appendChild(andE);
127 };
128
129 // Add or button
130 if (this._or === true) {
131 var orE = document.createElement('span');
132 orE.setAttribute('class', 'or');
133 orE.appendChild(document.createTextNode(KorAP.Locale.OR));
134 op.appendChild(orE);
135 };
136
137 // Add delete button
138 if (this._del === true) {
139 var delE = document.createElement('span');
140 delE.setAttribute('class', 'delete');
141 delE.appendChild(document.createTextNode(KorAP.Locale.DEL));
142 op.appendChild(delE);
143 };
Nils Diewald966abf12014-12-20 02:27:45 +0000144
145 return op;
Nils Diewaldd0770492014-12-19 03:55:00 +0000146 },
147 element : function () {
148
149 // Return existing element
150 if (this._element !== undefined)
151 return this._element;
152
153 this._element = document.createElement('div');
154 this._element.setAttribute('class', 'operators');
155
156 // Init elements
157 this.update();
158 return this._element;
159 },
160 and : function (bool) {
161 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000162 this._and = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000163 return this._and;
164 },
165 or : function (bool) {
166 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000167 this._or = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000168 return this._or;
169 },
170 del : function (bool) {
171 if (arguments.length === 1)
Nils Diewald966abf12014-12-20 02:27:45 +0000172 this._del = _bool(bool);
Nils Diewaldd0770492014-12-19 03:55:00 +0000173 return this._del;
174 }
175 };
176
177
178 /**
179 * Unspecified criterion
180 */
Nils Diewald8f4e2542014-12-19 04:42:09 +0000181 KorAP.UnspecifiedDoc = {
Nils Diewald966abf12014-12-20 02:27:45 +0000182 _ldType : "doc",
Nils Diewaldd0770492014-12-19 03:55:00 +0000183 create : function (parent) {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000184 var obj = Object.create(KorAP.JsonLD).upgradeTo(KorAP.UnspecifiedDoc);
Nils Diewaldd0770492014-12-19 03:55:00 +0000185 if (parent !== undefined)
186 obj._parent = parent;
187 return obj;
188 },
Nils Diewald966abf12014-12-20 02:27:45 +0000189 update : function () {
190 if (this._element === undefined)
191 return this.element();
192
193 _removeChildren(this._element);
194
195 var ellipsis = document.createElement('span');
196 ellipsis.appendChild(document.createTextNode('⋯'));
197 this._element.appendChild(ellipsis);
198
199 // Set operators
200 var op = this.operators(
201 false,
202 false,
203 // No delete object, if this is the root
204 this._parent !== undefined ? true : false
205 );
206
207 this._element.appendChild(
208 op.element()
209 );
210
211
212 return this.element();
213 },
Nils Diewaldd0770492014-12-19 03:55:00 +0000214 element : function () {
215 if (this._element !== undefined)
216 return this._element;
Nils Diewald966abf12014-12-20 02:27:45 +0000217
Nils Diewaldd0770492014-12-19 03:55:00 +0000218 this._element = document.createElement('div');
Nils Diewald966abf12014-12-20 02:27:45 +0000219 this._element.setAttribute('class', 'unspecified');
220
221 this.update();
Nils Diewaldd0770492014-12-19 03:55:00 +0000222 return this._element;
223 }
224 };
225
226
Nils Diewald8f4e2542014-12-19 04:42:09 +0000227 /**
228 * Virtual collection doc criterion.
229 */
230 KorAP.Doc = {
231 _ldType : "doc",
232 _obj : function () { return KorAP.Doc; },
Nils Diewaldd0770492014-12-19 03:55:00 +0000233
234 create : function (parent, json) {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000235 var obj = Object(KorAP.JsonLD).create().upgradeTo(KorAP.Doc).fromJson(json);
Nils Diewaldd0770492014-12-19 03:55:00 +0000236 if (parent !== undefined)
237 obj._parent = parent;
238 return obj;
239 },
Nils Diewald966abf12014-12-20 02:27:45 +0000240 update : function () {
241 if (this._element === undefined)
242 return this.element();
Nils Diewaldd0770492014-12-19 03:55:00 +0000243
244 // Added key
245 var key = document.createElement('span');
246 key.setAttribute('class', 'key');
247 if (this.key())
248 key.appendChild(document.createTextNode(this.key()));
249
250 // Added match operator
251 var matchop = document.createElement('span');
252 matchop.setAttribute('data-type', this.type());
253 matchop.setAttribute('class', 'match');
254 matchop.appendChild(document.createTextNode(this.matchop()));
255
256 // Added match operator
257 var value = document.createElement('span');
258 value.setAttribute('data-type', this.type());
259 value.setAttribute('class', 'value');
260 if (this.value())
261 value.appendChild(document.createTextNode(this.value()));
262
Nils Diewald966abf12014-12-20 02:27:45 +0000263 var e = this._element;
264
Nils Diewaldd0770492014-12-19 03:55:00 +0000265 // Add spans
266 e.appendChild(key);
267 e.appendChild(matchop);
268 e.appendChild(value);
Nils Diewald966abf12014-12-20 02:27:45 +0000269
270 // Set operators
271 var op = this.operators(true, true, true);
272
273 e.appendChild(op.element());
274
Nils Diewaldd0770492014-12-19 03:55:00 +0000275 return e;
276 },
277
Nils Diewald966abf12014-12-20 02:27:45 +0000278 element : function () {
279 if (this._element !== undefined)
280 return this._element;
281
282 this._element = document.createElement('div');
283 this._element.setAttribute('class', 'doc');
284
285 this.update();
286 return this._element;
287 },
288
Nils Diewaldd0770492014-12-19 03:55:00 +0000289 // Wrap a new operation around the doc element
290 wrap : function (op) {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000291 var group = KorAP.DocGroup.create(undefined);
Nils Diewald966abf12014-12-20 02:27:45 +0000292 group.append(this);
293 group.append(null);
Nils Diewaldd0770492014-12-19 03:55:00 +0000294 this.parent(group);
295/*
296 var div = document.createElement('div');
297 div.setAttribute('data-operation', op);
298 var parent = this.element.parent;
299 parent.removeChild(this.element);
300 parent.appendChild(div);
301 div.appendChild(this.element);
302 return div;
303*/
Nils Diewaldd0770492014-12-19 03:55:00 +0000304 },
Nils Diewald3a2d8022014-12-16 02:45:41 +0000305 // Deserialize from json
306 fromJson : function (json) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000307 if (json === undefined)
Nils Diewaldd0770492014-12-19 03:55:00 +0000308 return this;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000309
Nils Diewald3a2d8022014-12-16 02:45:41 +0000310 if (json["@type"] !== "korap:doc") {
311 KorAP.log(701, "JSON-LD group has no @type attribute");
312 return;
313 };
314
Nils Diewald3a2d8022014-12-16 02:45:41 +0000315 if (json["value"] === undefined ||
316 typeof json["value"] != 'string') {
317 KorAP.log(805, "Value is invalid");
318 return;
319 };
320
321 // There is a defined key
322 if (json["key"] !== undefined &&
323 typeof json["key"] === 'string') {
324
325 // Set key
Nils Diewaldd0770492014-12-19 03:55:00 +0000326 this.key(json["key"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000327
328 // Set match operation
329 if (json["match"] !== undefined) {
Nils Diewaldd0770492014-12-19 03:55:00 +0000330 if (typeof json["match"] === 'string') {
331 this.matchop(json["match"]);
332 }
Nils Diewald3a2d8022014-12-16 02:45:41 +0000333 else {
334 KorAP.log(802, "Match type is not supported by value type");
335 return;
336 };
337 };
338
339 // Key is a string
340 if (json["type"] === undefined ||
341 json["type"] == "type:string") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000342 this.type("string");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000343
344 // Check match type
Nils Diewaldd0770492014-12-19 03:55:00 +0000345 if (!KorAP._validStringMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000346 KorAP.log(802, "Match type is not supported by value type");
347 return;
348 };
349
350 // Set string value
Nils Diewaldd0770492014-12-19 03:55:00 +0000351 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000352 }
353
354 // Key is a date
355 else if (json["type"] === "type:date") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000356 this.type("date");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000357
358 if (json["value"] !== undefined &&
359 KorAP._validDateRE.test(json["value"])) {
360
Nils Diewaldd0770492014-12-19 03:55:00 +0000361 if (!KorAP._validDateMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000362 KorAP.log(802, "Match type is not supported by value type");
363 return;
364 };
365
366 // Set value
Nils Diewaldd0770492014-12-19 03:55:00 +0000367 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000368 }
369 else {
370 KorAP.log(806, "Value is not a valid date string");
371 return;
372 };
373 }
374
375 // Key is a regular expression
376 else if (json["type"] === "type:regex") {
Nils Diewaldd0770492014-12-19 03:55:00 +0000377 this.type("regex");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000378
379 try {
380
381 // Try to create a regular expression
382 var check = new RegExp(json["value"]);
383
Nils Diewaldd0770492014-12-19 03:55:00 +0000384 if (!KorAP._validRegexMatchRE.test(this.matchop())) {
Nils Diewald3a2d8022014-12-16 02:45:41 +0000385 KorAP.log(802, "Match type is not supported by value type");
386 return;
387 };
388
Nils Diewaldd0770492014-12-19 03:55:00 +0000389 this.value(json["value"]);
Nils Diewald3a2d8022014-12-16 02:45:41 +0000390 }
Nils Diewaldd0770492014-12-19 03:55:00 +0000391
Nils Diewald3a2d8022014-12-16 02:45:41 +0000392 catch (e) {
393 KorAP.log(807, "Value is not a valid regular expression");
394 return;
395 };
Nils Diewaldd0770492014-12-19 03:55:00 +0000396 this.type("regex");
Nils Diewald3a2d8022014-12-16 02:45:41 +0000397 }
398
399 else {
400 KorAP.log(804, "Unknown value type");
401 return;
402 };
403 };
404
405 return this;
406 },
Nils Diewaldd0770492014-12-19 03:55:00 +0000407 key : function (value) {
408 if (arguments.length === 1)
409 this._key = value;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000410 return this._key;
411 },
Nils Diewaldd0770492014-12-19 03:55:00 +0000412 matchop : function (match) {
413 if (arguments.length === 1)
414 this._matchop = match.replace(/^match:/, '');
Nils Diewald3a2d8022014-12-16 02:45:41 +0000415 return this._matchop || "eq";
416 },
Nils Diewaldd0770492014-12-19 03:55:00 +0000417 type : function (type) {
418 if (arguments.length === 1)
419 this._type = type;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000420 return this._type || "string";
421 },
Nils Diewaldd0770492014-12-19 03:55:00 +0000422 value : function (value) {
423 if (arguments.length === 1)
424 this._value = value;
Nils Diewald3a2d8022014-12-16 02:45:41 +0000425 return this._value;
426 },
Nils Diewald3a2d8022014-12-16 02:45:41 +0000427 toJson : function () {
Nils Diewaldd0770492014-12-19 03:55:00 +0000428 if (!this.matchop() || !this.key())
Nils Diewald3a2d8022014-12-16 02:45:41 +0000429 return {};
430
431 return {
Nils Diewaldd0770492014-12-19 03:55:00 +0000432 "@type" : "korap:" + this.ldType(),
433 "key" : this.key(),
434 "match" : "match:" + this.matchop(),
435 "value" : this.value() || '',
436 "type" : "type:" + this.type()
Nils Diewald3a2d8022014-12-16 02:45:41 +0000437 };
438 }
439 };
Nils Diewald8f4e2542014-12-19 04:42:09 +0000440
441 /**
442 * Virtual collection group criterion.
443 */
444 KorAP.DocGroup = {
445 _ldType : "docGroup",
446
447 create : function (parent, json) {
448 var obj = Object.create(KorAP.JsonLD).upgradeTo(KorAP.DocGroup);
449 obj._operands = [];
450 obj.fromJson(json);
451 if (parent !== undefined)
452 obj._parent = parent;
453 return obj;
454 },
Nils Diewald966abf12014-12-20 02:27:45 +0000455 append : function (operand) {
456
457 // Append unspecified object
458 if (operand === undefined) {
459
460 // Be aware of cyclic structures!
461 operand = KorAP.UnspecifiedDoc.create(this);
462 this._operands.push(operand);
463 this.update();
464 return operand;
465 };
466
Nils Diewald8f4e2542014-12-19 04:42:09 +0000467 switch (operand["@type"]) {
468 case undefined:
469 if (operand["ldType"] !== undefined) {
470 if (operand.ldType() !== 'doc' &&
Nils Diewald966abf12014-12-20 02:27:45 +0000471 operand.ldType() !== 'docGroup') {
Nils Diewald8f4e2542014-12-19 04:42:09 +0000472 KorAP.log(812, "Operand not supported in document group");
473 return;
474 };
Nils Diewald966abf12014-12-20 02:27:45 +0000475 // Be aware of cyclic structures!
476 operand.parent(this);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000477 this._operands.push(operand);
Nils Diewald966abf12014-12-20 02:27:45 +0000478 this.update();
Nils Diewald8f4e2542014-12-19 04:42:09 +0000479 return operand;
480 };
481
482 KorAP.log(701, "JSON-LD group has no @type attribute");
483 return;
484
485 case "korap:doc":
Nils Diewald966abf12014-12-20 02:27:45 +0000486 // Be aware of cyclic structures!
487 var doc = KorAP.Doc.create(this, operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000488 if (doc === undefined)
489 return;
490 this._operands.push(doc);
Nils Diewald966abf12014-12-20 02:27:45 +0000491 this.update();
Nils Diewald8f4e2542014-12-19 04:42:09 +0000492 return doc;
493
494 case "korap:docGroup":
Nils Diewald966abf12014-12-20 02:27:45 +0000495 // Be aware of cyclic structures!
496 var docGroup = KorAP.DocGroup.create(this, operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000497 if (docGroup === undefined)
498 return;
499 this._operands.push(docGroup);
Nils Diewald966abf12014-12-20 02:27:45 +0000500 this.update();
Nils Diewald8f4e2542014-12-19 04:42:09 +0000501 return docGroup;
502
503 default:
504 KorAP.log(812, "Operand not supported in document group");
505 return;
506 };
507 },
Nils Diewald966abf12014-12-20 02:27:45 +0000508 update : function () {
509 if (this._element === undefined)
510 return this.element();
511
512 var op = this._element;
513 op.setAttribute('data-operation', this.operation());
514
515 _removeChildren(op);
516
517 // Append operands
518 for (var i in this.operands()) {
519 op.appendChild(
520 this.getOperand(i).element()
521 );
522 };
523
524 // Set operators
525 var op = this.operators(
526 this.operation() == 'and' ? false : true,
527 this.operation() == 'or' ? false : true,
528 true
529 );
530
531 this._element.appendChild(
532 op.element()
533 );
534
535 return op;
536 },
Nils Diewald8f4e2542014-12-19 04:42:09 +0000537 element : function () {
538 if (this._element !== undefined)
539 return this._element;
540
541 this._element = document.createElement('div');
542 this._element.setAttribute('class', 'docGroup');
Nils Diewald8f4e2542014-12-19 04:42:09 +0000543
Nils Diewald966abf12014-12-20 02:27:45 +0000544 this.update();
Nils Diewald8f4e2542014-12-19 04:42:09 +0000545
546 return this._element;
547 },
548 operation : function (op) {
549 if (arguments.length === 1) {
550 if (KorAP._validGroupOpRE.test(op)) {
551 this._op = op;
552 }
553 else {
554 KorAP.log(810, "Unknown operation type");
555 return;
556 };
557 };
558 return this._op || 'and';
559 },
560 operands : function () {
561 return this._operands;
562 },
563 getOperand : function (index) {
564 return this._operands[index];
565 },
566
567 // Deserialize from json
568 fromJson : function (json) {
569 if (json === undefined)
570 return this;
571
572 if (json["@type"] !== "korap:docGroup") {
573 KorAP.log(701, "JSON-LD group has no @type attribute");
574 return;
575 };
576
577 if (json["operation"] === undefined ||
578 typeof json["operation"] !== 'string') {
579 KorAP.log(811, "Document group expects operation");
580 return;
581 };
582
583 var operation = json["operation"];
584
585 this.operation(operation.replace(/^operation:/,''));
586
587 if (json["operands"] === undefined ||
588 !(json["operands"] instanceof Array)) {
589 KorAP.log(704, "Operation needs operand list")
590 return;
591 };
592
593 // Add all documents
594 for (var i in json["operands"]) {
595 var operand = json["operands"][i];
Nils Diewald966abf12014-12-20 02:27:45 +0000596 this.append(operand);
Nils Diewald8f4e2542014-12-19 04:42:09 +0000597 };
598
599 return this;
600 },
601 toJson : function () {
602 var opArray = new Array();
603 for (var i in this._operands) {
604 opArray.push(this._operands[i].toJson());
605 };
606 return {
607 "@type" : "korap:" + this.ldType(),
608 "operation" : "operation:" + this.operation(),
609 "operands" : opArray
610 };
611 }
612 };
613
614
615 // Abstract JsonLD object
616 KorAP.JsonLD = {
617 create : function () {
618 return Object.create(KorAP.JsonLD);
619 },
620
621 /**
622 * Upgrade this object to another object
623 * while private data stays intact
624 */
625 upgradeTo : function (props) {
626 for (var prop in props) {
627 this[prop] = props[prop];
628 };
629 return this;
630 },
631 ldType : function (type) {
632 if (arguments.length === 1)
633 this._ldType = type;
634 return this._ldType;
635 },
636 parent : function (obj) {
637 if (arguments.length === 1)
638 this._parent = obj;
639 return this._parent;
Nils Diewald966abf12014-12-20 02:27:45 +0000640 },
641 operators : function (and, or, del) {
642 if (arguments === 0)
643 return this._ops;
644 this._ops = KorAP.Operators.create(
645 and, or, del
646 );
647 return this._ops;
648 },
649 toJson : function () {
650 return {
651 // Unspecified object
652 "@type" : "korap:" + this.ldType()
653 };
Nils Diewald8f4e2542014-12-19 04:42:09 +0000654 }
655 };
656
Nils Diewald3a2d8022014-12-16 02:45:41 +0000657}(this.KorAP));