igniteui-webcomponents-datasources 7.1.1-beta.1 → 7.1.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/esm2022/lib/ODataSchemaProvider.js +120 -0
  2. package/esm2022/lib/ODataVirtualDataSourceDataProvider.js +450 -0
  3. package/esm2022/lib/ODataVirtualDataSourceDataProviderWorker.js +710 -0
  4. package/esm2022/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +83 -0
  5. package/esm2022/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +6 -0
  6. package/esm2022/lib/RestVirtualDataSourceDataProvider.js +535 -0
  7. package/esm2022/lib/RestVirtualDataSourceDataProviderWorker.js +762 -0
  8. package/esm2022/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +159 -0
  9. package/esm2022/lib/RestVirtualDataSourceProviderTaskDataHolder.js +6 -0
  10. package/package.json +14 -10
  11. package/bundles/igniteui-webcomponents-datasources.umd.js +0 -4725
  12. package/bundles/igniteui-webcomponents-datasources.umd.min.js +0 -7
  13. package/esm2015/igniteui-webcomponents-datasources.js +0 -1
  14. package/esm2015/lib/ODataSchemaProvider.js +0 -123
  15. package/esm2015/lib/ODataVirtualDataSourceDataProvider.js +0 -453
  16. package/esm2015/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -713
  17. package/esm2015/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -86
  18. package/esm2015/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -9
  19. package/esm2015/lib/RestVirtualDataSourceDataProvider.js +0 -538
  20. package/esm2015/lib/RestVirtualDataSourceDataProviderWorker.js +0 -765
  21. package/esm2015/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -162
  22. package/esm2015/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -9
  23. package/esm5/igniteui-webcomponents-datasources.js +0 -1
  24. package/esm5/lib/Entity.js +0 -79
  25. package/esm5/lib/EntityProperty.js +0 -41
  26. package/esm5/lib/EntitySet.js +0 -68
  27. package/esm5/lib/ODataDataSourcePage.js +0 -73
  28. package/esm5/lib/ODataSchemaProvider.js +0 -158
  29. package/esm5/lib/ODataVirtualDataSource.js +0 -169
  30. package/esm5/lib/ODataVirtualDataSourceDataProvider.js +0 -558
  31. package/esm5/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -920
  32. package/esm5/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -130
  33. package/esm5/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -11
  34. package/esm5/lib/RestVirtualDataSource.js +0 -357
  35. package/esm5/lib/RestVirtualDataSourceDataProvider.js +0 -687
  36. package/esm5/lib/RestVirtualDataSourceDataProviderWorker.js +0 -967
  37. package/esm5/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -250
  38. package/esm5/lib/RestVirtualDataSourcePage.js +0 -73
  39. package/esm5/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -11
  40. package/esm5/lib/Schema.js +0 -68
  41. package/esm5/lib/util.js +0 -160
  42. package/esm5/public_api.js +0 -18
  43. package/fesm2015/igniteui-webcomponents-datasources.js +0 -3638
  44. package/fesm5/igniteui-webcomponents-datasources.js +0 -4698
  45. package/igniteui-webcomponents-datasources.d.ts +0 -1
  46. /package/{lib → esm2022/lib}/Entity.d.ts +0 -0
  47. /package/{esm2015 → esm2022}/lib/Entity.js +0 -0
  48. /package/{lib → esm2022/lib}/EntityProperty.d.ts +0 -0
  49. /package/{esm2015 → esm2022}/lib/EntityProperty.js +0 -0
  50. /package/{lib → esm2022/lib}/EntitySet.d.ts +0 -0
  51. /package/{esm2015 → esm2022}/lib/EntitySet.js +0 -0
  52. /package/{lib → esm2022/lib}/ODataDataSourcePage.d.ts +0 -0
  53. /package/{esm2015 → esm2022}/lib/ODataDataSourcePage.js +0 -0
  54. /package/{lib → esm2022/lib}/ODataSchemaProvider.d.ts +0 -0
  55. /package/{lib → esm2022/lib}/ODataVirtualDataSource.d.ts +0 -0
  56. /package/{esm2015 → esm2022}/lib/ODataVirtualDataSource.js +0 -0
  57. /package/{lib → esm2022/lib}/ODataVirtualDataSourceDataProvider.d.ts +0 -0
  58. /package/{lib → esm2022/lib}/ODataVirtualDataSourceDataProviderWorker.d.ts +0 -0
  59. /package/{lib → esm2022/lib}/ODataVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -0
  60. /package/{lib → esm2022/lib}/ODataVirtualDataSourceProviderTaskDataHolder.d.ts +0 -0
  61. /package/{lib → esm2022/lib}/RestVirtualDataSource.d.ts +0 -0
  62. /package/{esm2015 → esm2022}/lib/RestVirtualDataSource.js +0 -0
  63. /package/{lib → esm2022/lib}/RestVirtualDataSourceDataProvider.d.ts +0 -0
  64. /package/{lib → esm2022/lib}/RestVirtualDataSourceDataProviderWorker.d.ts +0 -0
  65. /package/{lib → esm2022/lib}/RestVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -0
  66. /package/{lib → esm2022/lib}/RestVirtualDataSourcePage.d.ts +0 -0
  67. /package/{esm2015 → esm2022}/lib/RestVirtualDataSourcePage.js +0 -0
  68. /package/{lib → esm2022/lib}/RestVirtualDataSourceProviderTaskDataHolder.d.ts +0 -0
  69. /package/{lib → esm2022/lib}/Schema.d.ts +0 -0
  70. /package/{esm2015 → esm2022}/lib/Schema.js +0 -0
  71. /package/{lib → esm2022/lib}/util.d.ts +0 -0
  72. /package/{esm2015 → esm2022}/lib/util.js +0 -0
  73. /package/{public_api.d.ts → esm2022/public_api.d.ts} +0 -0
  74. /package/{esm2015 → esm2022}/public_api.js +0 -0
@@ -1,4698 +0,0 @@
1
- /*!
2
- THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
3
- https://www.infragistics.com/legal/license/igultimate-la
4
- https://www.infragistics.com/legal/license/igultimate-eula
5
- GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
6
- */
7
-
8
- import { fromEnum, XName, DataSourceSchemaPropertyType, XDocument, XmlNodeType, typeCast, XElement, ODataDataSourceSchema, XNamespace, markType, AsyncVirtualDataSourceProviderTaskDataHolder, SortDescriptionCollection, ListSortDirection, DataSourceSummaryScope, stringIsNullOrEmpty, Convert, DefaultSectionInformation, DataSourceSummaryOperand, DefaultSummaryResult, AsyncVirtualDataTask, AsyncDataSourcePageTaskHolder, ODataDataSourceFilterExpressionVisitor, TransactionType, AsyncVirtualDataSourceProviderWorker, AsyncVirtualDataSourceDataProviderWorkerSettings, FilterExpressionCollection, SummaryDescriptionCollection, DataSourcePageRequestPriority, runOn, DataSourceDataProviderSchemaChangedEventArgs, stringContains, Base, IDataSourceVirtualDataProvider_$type, VirtualDataSource, LocalDataSource, DefaultDataSourceSchema } from 'igniteui-webcomponents-core';
9
- import { __values, __extends, __generator } from 'tslib';
10
-
11
- var EntityProperty = /** @class */ /*@__PURE__*/ (function () {
12
- function EntityProperty(name, schemaType) {
13
- this._name = null;
14
- this._isNullable = false;
15
- this._type = null;
16
- this.name = name;
17
- this.type = schemaType;
18
- }
19
- Object.defineProperty(EntityProperty.prototype, "name", {
20
- get: function () {
21
- return this._name;
22
- },
23
- set: function (value) {
24
- this._name = value;
25
- },
26
- enumerable: false,
27
- configurable: true
28
- });
29
- Object.defineProperty(EntityProperty.prototype, "isNullable", {
30
- get: function () {
31
- return this._isNullable;
32
- },
33
- set: function (value) {
34
- this._isNullable = value;
35
- },
36
- enumerable: false,
37
- configurable: true
38
- });
39
- Object.defineProperty(EntityProperty.prototype, "type", {
40
- get: function () {
41
- return this._type;
42
- },
43
- set: function (value) {
44
- this._type = value;
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- return EntityProperty;
50
- }());
51
-
52
- function toArray(en) {
53
- return Array.from(fromEnum(en));
54
- }
55
- function first(iter) {
56
- var e_1, _a;
57
- try {
58
- for (var iter_1 = __values(iter), iter_1_1 = iter_1.next(); !iter_1_1.done; iter_1_1 = iter_1.next()) {
59
- var v = iter_1_1.value;
60
- return v;
61
- }
62
- }
63
- catch (e_1_1) {
64
- e_1 = { error: e_1_1 };
65
- }
66
- finally {
67
- try {
68
- if (iter_1_1 && !iter_1_1.done && (_a = iter_1.return))
69
- _a.call(iter_1);
70
- }
71
- finally {
72
- if (e_1)
73
- throw e_1.error;
74
- }
75
- }
76
- throw new Error("Iterable contained no elements, expected at least one");
77
- }
78
- var LinkedList = /** @class */ /*@__PURE__*/ (function () {
79
- function LinkedList() {
80
- }
81
- Object.defineProperty(LinkedList.prototype, "first", {
82
- get: function () {
83
- return this._first;
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(LinkedList.prototype, "last", {
89
- get: function () {
90
- return this._last;
91
- },
92
- enumerable: false,
93
- configurable: true
94
- });
95
- LinkedList.prototype.addFirst = function (item) {
96
- if (this._first == null) {
97
- this._first = new LinkedListNode(item);
98
- this._last = this._first;
99
- }
100
- else {
101
- var oldFirst = this._first;
102
- this._first = new LinkedListNode(item);
103
- this._first.next = oldFirst;
104
- oldFirst.prev = this._first;
105
- }
106
- };
107
- LinkedList.prototype.addLast = function (item) {
108
- if (this._last == null) {
109
- this._first = new LinkedListNode(item);
110
- this._last = this._first;
111
- }
112
- else {
113
- var oldLast = this._last;
114
- this._last = new LinkedListNode(item);
115
- this._last.prev = oldLast;
116
- oldLast.next = this._last;
117
- }
118
- };
119
- LinkedList.prototype.removeFirst = function () {
120
- this.remove(this.first);
121
- };
122
- LinkedList.prototype.clear = function () {
123
- this._first = null;
124
- this._last = null;
125
- };
126
- LinkedList.prototype.contains = function (value) {
127
- var curr = this.first;
128
- while (curr != null) {
129
- if (curr.value === value) {
130
- return true;
131
- }
132
- curr = curr.next;
133
- }
134
- return false;
135
- };
136
- LinkedList.prototype.removeValue = function (value) {
137
- var curr = this.first;
138
- while (curr != null) {
139
- if (curr.value === value) {
140
- this.remove(curr);
141
- return;
142
- }
143
- curr = curr.next;
144
- }
145
- };
146
- LinkedList.prototype.remove = function (node) {
147
- if (this._first == node) {
148
- this._first = node.next;
149
- if (node.next != null) {
150
- node.next.prev = null;
151
- }
152
- }
153
- if (this._last == node) {
154
- this._last = node.prev;
155
- if (node.prev != null) {
156
- node.prev.next = null;
157
- }
158
- }
159
- if (node.prev != null) {
160
- node.prev.next = node.next;
161
- }
162
- if (node.next != null) {
163
- node.next.prev = node.prev;
164
- }
165
- node.next = null;
166
- node.prev = null;
167
- };
168
- return LinkedList;
169
- }());
170
- var LinkedListNode = /** @class */ /*@__PURE__*/ (function () {
171
- function LinkedListNode(item) {
172
- if (item !== undefined) {
173
- this.value = item;
174
- }
175
- }
176
- Object.defineProperty(LinkedListNode.prototype, "value", {
177
- get: function () {
178
- return this._value;
179
- },
180
- set: function (value) {
181
- this._value = value;
182
- },
183
- enumerable: false,
184
- configurable: true
185
- });
186
- Object.defineProperty(LinkedListNode.prototype, "prev", {
187
- get: function () {
188
- return this._prev;
189
- },
190
- set: function (value) {
191
- this._prev = value;
192
- },
193
- enumerable: false,
194
- configurable: true
195
- });
196
- Object.defineProperty(LinkedListNode.prototype, "next", {
197
- get: function () {
198
- return this._next;
199
- },
200
- set: function (value) {
201
- this._next = value;
202
- },
203
- enumerable: false,
204
- configurable: true
205
- });
206
- return LinkedListNode;
207
- }());
208
-
209
- var Entity = /** @class */ /*@__PURE__*/ (function () {
210
- function Entity(name, entityNode) {
211
- this._properties = null;
212
- this._primaryKey = null;
213
- this._name = null;
214
- this.name = name;
215
- this.loadProperties(entityNode);
216
- this.loadPrimaryKey(entityNode);
217
- }
218
- Object.defineProperty(Entity.prototype, "name", {
219
- get: function () {
220
- return this._name;
221
- },
222
- set: function (value) {
223
- this._name = value;
224
- },
225
- enumerable: false,
226
- configurable: true
227
- });
228
- Object.defineProperty(Entity.prototype, "properties", {
229
- get: function () {
230
- if (null == this._properties) {
231
- this._properties = new Map();
232
- }
233
- return this._properties;
234
- },
235
- enumerable: false,
236
- configurable: true
237
- });
238
- Object.defineProperty(Entity.prototype, "primaryKey", {
239
- get: function () {
240
- if (null == this._primaryKey) {
241
- this._primaryKey = [];
242
- }
243
- return this._primaryKey;
244
- },
245
- enumerable: false,
246
- configurable: true
247
- });
248
- Entity.prototype.loadProperties = function (entityNode) {
249
- var children = toArray(entityNode.elements());
250
- var elementCount = children.length;
251
- var nameAttr = XName.get("Name", "");
252
- var typeAttr = XName.get("Type", "");
253
- for (var i = 0; i < elementCount; i++) {
254
- var node = children[i];
255
- if (node.name.localName == "Property") {
256
- var name_1 = node.attribute(nameAttr).value;
257
- var type = node.attribute(typeAttr).value;
258
- this.properties.set(name_1, new EntityProperty(name_1, type));
259
- }
260
- }
261
- ;
262
- };
263
- Entity.prototype.loadPrimaryKey = function (entityNode) {
264
- var children = toArray(entityNode.elements());
265
- var elementCount = children.length;
266
- var nameAttr = XName.get("Name", "");
267
- for (var i = 0; i < elementCount; i++) {
268
- var node = children[i];
269
- if (node.name.localName == "Key") {
270
- var subChildren = toArray(node.elements());
271
- var keyNodeCOunt = subChildren.length;
272
- for (var j = 0; j < keyNodeCOunt; j++) {
273
- var keyNode = subChildren[j];
274
- if (keyNode.name.localName == "PropertyRef") {
275
- this.primaryKey.push(keyNode.attribute(nameAttr).value);
276
- }
277
- }
278
- }
279
- }
280
- ;
281
- };
282
- return Entity;
283
- }());
284
-
285
- var EntitySet = /** @class */ /*@__PURE__*/ (function () {
286
- function EntitySet(name, entityType) {
287
- this._entityName = null;
288
- this._entityNamespace = null;
289
- this._entityType = null;
290
- this._name = null;
291
- this.name = name;
292
- this.entityType = entityType;
293
- if (entityType.indexOf(".") >= 0) {
294
- var parts = entityType.split('.');
295
- if (parts.length == 2) {
296
- this.entityNamespace = parts[0];
297
- this.entityName = parts[1];
298
- }
299
- else {
300
- var i = entityType.lastIndexOf('.');
301
- this.entityNamespace = entityType.substr(0, i);
302
- this.entityName = entityType.substr(i + 1);
303
- }
304
- }
305
- else {
306
- this.entityNamespace = entityType;
307
- this.entityName = entityType;
308
- }
309
- }
310
- Object.defineProperty(EntitySet.prototype, "entityName", {
311
- get: function () {
312
- return this._entityName;
313
- },
314
- set: function (value) {
315
- this._entityName = value;
316
- },
317
- enumerable: false,
318
- configurable: true
319
- });
320
- Object.defineProperty(EntitySet.prototype, "entityNamespace", {
321
- get: function () {
322
- return this._entityNamespace;
323
- },
324
- set: function (value) {
325
- this._entityNamespace = value;
326
- },
327
- enumerable: false,
328
- configurable: true
329
- });
330
- Object.defineProperty(EntitySet.prototype, "entityType", {
331
- get: function () {
332
- return this._entityType;
333
- },
334
- set: function (value) {
335
- this._entityType = value;
336
- },
337
- enumerable: false,
338
- configurable: true
339
- });
340
- Object.defineProperty(EntitySet.prototype, "name", {
341
- get: function () {
342
- return this._name;
343
- },
344
- set: function (value) {
345
- this._name = value;
346
- },
347
- enumerable: false,
348
- configurable: true
349
- });
350
- return EntitySet;
351
- }());
352
-
353
- var ODataDataSourcePage = /** @class */ /*@__PURE__*/ (function () {
354
- function ODataDataSourcePage(sourceData_, schema, groupInformation, summaryInformation, pageIndex) {
355
- this._actualData = null;
356
- this._schema = null;
357
- this._pageIndex = 0;
358
- this._groupInformation = null;
359
- this._summaryInformation = null;
360
- if (sourceData_ == null) {
361
- this._actualData = null;
362
- }
363
- else {
364
- var count = (sourceData_.value.length);
365
- this._actualData = [];
366
- var dateProps = new Set();
367
- for (var i = 0; i < schema.propertyNames.length; i++) {
368
- if (schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeValue || schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeOffsetValue) {
369
- dateProps.add(schema.propertyNames[i]);
370
- }
371
- }
372
- var value_ = void 0;
373
- var _loop_1 = function (i_) {
374
- var currItem_ = sourceData_.value[i_];
375
- var dict = new Map();
376
- var properties = Array.from(Object.keys(currItem_));
377
- var values = (properties.map(function (k) { return currItem_[k]; }));
378
- for (var i1 = 0; i1 < properties.length; i1++) {
379
- value_ = values[i1];
380
- if (dateProps.has(properties[i1])) {
381
- value_ = new Date(value_);
382
- }
383
- dict.set(properties[i1], value_);
384
- }
385
- this_1._actualData[i_] = dict;
386
- };
387
- var this_1 = this;
388
- for (var i_ = 0; i_ < count; i_++) {
389
- _loop_1(i_);
390
- }
391
- }
392
- this._schema = schema;
393
- this._groupInformation = groupInformation;
394
- this._summaryInformation = summaryInformation;
395
- this._pageIndex = pageIndex;
396
- }
397
- ODataDataSourcePage.prototype.count = function () {
398
- return this._actualData.length;
399
- };
400
- ODataDataSourcePage.prototype.getItemAtIndex = function (index) {
401
- return this._actualData[index];
402
- };
403
- ODataDataSourcePage.prototype.getItemValueAtIndex = function (index, valueName) {
404
- var item = this._actualData[index];
405
- if (!item.has(valueName)) {
406
- return null;
407
- }
408
- return item.get(valueName);
409
- };
410
- ODataDataSourcePage.prototype.pageIndex = function () {
411
- return this._pageIndex;
412
- };
413
- ODataDataSourcePage.prototype.schema = function () {
414
- return this._schema;
415
- };
416
- ODataDataSourcePage.prototype.getGroupInformation = function () {
417
- return this._groupInformation;
418
- };
419
- ODataDataSourcePage.prototype.getSummaryInformation = function () {
420
- return this._summaryInformation;
421
- };
422
- return ODataDataSourcePage;
423
- }());
424
-
425
- var Schema = /** @class */ /*@__PURE__*/ (function () {
426
- function Schema(namespace, entityTypeElements, entitySetElements) {
427
- this._entities = null;
428
- this._entitySets = null;
429
- this._namespace = null;
430
- this.namespace = namespace;
431
- this.loadEntities(entityTypeElements);
432
- this.loadEntitySets(entitySetElements);
433
- }
434
- Object.defineProperty(Schema.prototype, "entities", {
435
- get: function () {
436
- if (null == this._entities) {
437
- this._entities = new Map();
438
- }
439
- return this._entities;
440
- },
441
- enumerable: false,
442
- configurable: true
443
- });
444
- Object.defineProperty(Schema.prototype, "entitySets", {
445
- get: function () {
446
- if (null == this._entitySets) {
447
- this._entitySets = new Map();
448
- }
449
- return this._entitySets;
450
- },
451
- enumerable: false,
452
- configurable: true
453
- });
454
- Object.defineProperty(Schema.prototype, "namespace", {
455
- get: function () {
456
- return this._namespace;
457
- },
458
- set: function (value) {
459
- this._namespace = value;
460
- },
461
- enumerable: false,
462
- configurable: true
463
- });
464
- Schema.prototype.loadEntities = function (entityTypeElements) {
465
- var list = entityTypeElements;
466
- var elementCount = list.length;
467
- var name = XName.get("Name", "");
468
- for (var i = 0; i < elementCount; i++) {
469
- var node = list[i];
470
- var entity = new Entity(node.attribute(name).value, node);
471
- this.entities.set(entity.name, entity);
472
- }
473
- ;
474
- };
475
- Schema.prototype.loadEntitySets = function (entitySetElements) {
476
- var list = entitySetElements;
477
- var elementCount = list.length;
478
- var nameAttr = XName.get("Name", "");
479
- var entityType = XName.get("EntityType", "");
480
- for (var i = 0; i < elementCount; i++) {
481
- var node = list[i];
482
- var entitySet = new EntitySet(node.attribute(nameAttr).value, node.attribute(entityType).value);
483
- this.entitySets.set(entitySet.name, entitySet);
484
- }
485
- ;
486
- };
487
- return Schema;
488
- }());
489
-
490
- var ODataSchemaProvider = /** @class */ /*@__PURE__*/ (function () {
491
- function ODataSchemaProvider(metadataDocument) {
492
- this._entityTypeSchemaNamespace = null;
493
- this._entitySetSchemaNamespace = null;
494
- this._schema = null;
495
- if (null == metadataDocument) {
496
- return;
497
- }
498
- var xmlDoc = XDocument.parse(metadataDocument);
499
- var schemaElements = toArray(first(fromEnum(first(fromEnum(xmlDoc.elements())).elements())).elements1(XName.get("Schema", ODataSchemaProvider.nS.namespaceName)));
500
- if (null == schemaElements) {
501
- return;
502
- }
503
- var entitySetElements = null;
504
- var entityTypeElements = null;
505
- var elementCount = schemaElements.length;
506
- var entityContainer = XName.get("EntityContainer", ODataSchemaProvider.nS.namespaceName);
507
- var entitySet = XName.get("EntitySet", ODataSchemaProvider.nS.namespaceName);
508
- var namespaceAttribute = XName.get("Namespace", "");
509
- var entityType = XName.get("EntityType", ODataSchemaProvider.nS.namespaceName);
510
- for (var i = 0; i < elementCount; i++) {
511
- var node = schemaElements[i];
512
- if (node.nodeType != XmlNodeType.Element) {
513
- continue;
514
- }
515
- var schemaElement = schemaElements[i];
516
- if (null == entitySetElements) {
517
- var nodes = toArray(schemaElement.elements1(entityContainer));
518
- if (null != nodes && nodes.length > 0) {
519
- entitySetElements = toArray((typeCast(XElement.$type, nodes[0])).elements1(entitySet));
520
- if (null != entitySetElements) {
521
- this._entitySetSchemaNamespace = schemaElement.attribute(namespaceAttribute).value;
522
- }
523
- }
524
- }
525
- if (null == entityTypeElements) {
526
- entityTypeElements = toArray(schemaElement.elements1(entityType));
527
- if (null != entityTypeElements) {
528
- this._entityTypeSchemaNamespace = schemaElement.attribute(namespaceAttribute).value;
529
- }
530
- }
531
- }
532
- if (null == entitySetElements || null == entityTypeElements) {
533
- return;
534
- }
535
- this.schema = new Schema(this._entityTypeSchemaNamespace, entityTypeElements, entitySetElements);
536
- }
537
- Object.defineProperty(ODataSchemaProvider.prototype, "schema", {
538
- get: function () {
539
- return this._schema;
540
- },
541
- set: function (value) {
542
- this._schema = value;
543
- },
544
- enumerable: false,
545
- configurable: true
546
- });
547
- ODataSchemaProvider.prototype.getODataDataSourceSchema = function (entitySet) {
548
- var e_1, _a, e_2, _b;
549
- if (this.schema == null) {
550
- return null;
551
- }
552
- var valueNames = [];
553
- var valueTypes = [];
554
- var primaryKey = [];
555
- var es = this.schema.entitySets.get(entitySet);
556
- if (null != es) {
557
- var entity = this.schema.entities.get(es.entityName);
558
- if (null != entity) {
559
- try {
560
- for (var _c = __values(entity.properties.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
561
- var property = _d.value;
562
- valueNames.push(property.name);
563
- if (property.type == "Edm.String") {
564
- valueTypes.push(DataSourceSchemaPropertyType.StringValue);
565
- }
566
- else if (property.type == "Edm.Int16" || property.type == "Edm.Int32") {
567
- valueTypes.push(DataSourceSchemaPropertyType.IntValue);
568
- }
569
- else if (property.type == "Edm.Double") {
570
- valueTypes.push(DataSourceSchemaPropertyType.DoubleValue);
571
- }
572
- else if (property.type == "Edm.Single") {
573
- valueTypes.push(DataSourceSchemaPropertyType.SingleValue);
574
- }
575
- else if (property.type == "Edm.Boolean") {
576
- valueTypes.push(DataSourceSchemaPropertyType.BooleanValue);
577
- }
578
- else if (property.type == "Edm.Byte") {
579
- valueTypes.push(DataSourceSchemaPropertyType.ShortValue);
580
- }
581
- else if (property.type == "Edm.DateTime" || property.type == "Edm.DateTimeOffset") {
582
- valueTypes.push(DataSourceSchemaPropertyType.DateTimeValue);
583
- }
584
- else if (property.type == "Edm.Int64") {
585
- valueTypes.push(DataSourceSchemaPropertyType.LongValue);
586
- }
587
- else if (property.type == "Edm.Decimal") {
588
- valueTypes.push(DataSourceSchemaPropertyType.DecimalValue);
589
- }
590
- else if (property.type == "Edm.SByte") {
591
- valueTypes.push(DataSourceSchemaPropertyType.ShortValue);
592
- }
593
- else {
594
- valueTypes.push(DataSourceSchemaPropertyType.ObjectValue);
595
- }
596
- }
597
- }
598
- catch (e_1_1) {
599
- e_1 = { error: e_1_1 };
600
- }
601
- finally {
602
- try {
603
- if (_d && !_d.done && (_a = _c.return))
604
- _a.call(_c);
605
- }
606
- finally {
607
- if (e_1)
608
- throw e_1.error;
609
- }
610
- }
611
- try {
612
- for (var _e = __values(entity.primaryKey), _f = _e.next(); !_f.done; _f = _e.next()) {
613
- var k = _f.value;
614
- primaryKey.push(k);
615
- }
616
- }
617
- catch (e_2_1) {
618
- e_2 = { error: e_2_1 };
619
- }
620
- finally {
621
- try {
622
- if (_f && !_f.done && (_b = _e.return))
623
- _b.call(_e);
624
- }
625
- finally {
626
- if (e_2)
627
- throw e_2.error;
628
- }
629
- }
630
- }
631
- }
632
- return new ODataDataSourceSchema(valueNames, valueTypes, primaryKey);
633
- };
634
- ODataSchemaProvider.nS = XNamespace.get("http://docs.oasis-open.org/odata/ns/edm");
635
- return ODataSchemaProvider;
636
- }());
637
-
638
- var ODataVirtualDataSourceProviderTaskDataHolder = /** @class */ /*@__PURE__*/ (function (_super) {
639
- __extends(ODataVirtualDataSourceProviderTaskDataHolder, _super);
640
- function ODataVirtualDataSourceProviderTaskDataHolder() {
641
- return _super !== null && _super.apply(this, arguments) || this;
642
- }
643
- ODataVirtualDataSourceProviderTaskDataHolder.$t = markType(ODataVirtualDataSourceProviderTaskDataHolder, 'ODataVirtualDataSourceProviderTaskDataHolder', AsyncVirtualDataSourceProviderTaskDataHolder.$type);
644
- return ODataVirtualDataSourceProviderTaskDataHolder;
645
- }(AsyncVirtualDataSourceProviderTaskDataHolder));
646
-
647
- var ODataVirtualDataSourceDataProviderWorker = /** @class */ /*@__PURE__*/ (function (_super) {
648
- __extends(ODataVirtualDataSourceDataProviderWorker, _super);
649
- function ODataVirtualDataSourceDataProviderWorker(settings) {
650
- var e_1, _a;
651
- var _this = _super.call(this, settings) || this;
652
- _this._baseUri = null;
653
- _this._entitySet = null;
654
- _this._sortDescriptions = null;
655
- _this._groupDescriptions = null;
656
- _this._filterExpressions = null;
657
- _this._summaryDescriptions = null;
658
- _this._desiredPropeties = null;
659
- _this._schemaIncludedProperties = null;
660
- _this._enableJsonp = true;
661
- _this._isAggregationSupported = false;
662
- _this._groupInformation = null;
663
- _this._summaryInformation = null;
664
- _this._filterString = null;
665
- _this._selectedString = null;
666
- _this.doWork = _this.doWork.bind(_this);
667
- _this._baseUri = settings.baseUri;
668
- _this._entitySet = settings.entitySet;
669
- _this._sortDescriptions = settings.sortDescriptions;
670
- _this._groupDescriptions = settings.groupDescriptions;
671
- if (_this._groupDescriptions != null && _this._groupDescriptions.size() > 0) {
672
- _this._sortDescriptions = new SortDescriptionCollection();
673
- try {
674
- for (var _b = __values(_this.iter(settings.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
675
- var sd = _c.value;
676
- _this._sortDescriptions.add(sd);
677
- }
678
- }
679
- catch (e_1_1) {
680
- e_1 = { error: e_1_1 };
681
- }
682
- finally {
683
- try {
684
- if (_c && !_c.done && (_a = _b.return))
685
- _a.call(_b);
686
- }
687
- finally {
688
- if (e_1)
689
- throw e_1.error;
690
- }
691
- }
692
- for (var i = 0; i < _this._groupDescriptions.size(); i++) {
693
- _this._sortDescriptions.insert(i, _this._groupDescriptions.get(i));
694
- }
695
- }
696
- _this._filterExpressions = settings.filterExpressions;
697
- _this._desiredPropeties = settings.propertiesRequested;
698
- if (settings.schemaIncludedProperties != null) {
699
- _this._schemaIncludedProperties = new Set();
700
- for (var i = 0; i < settings.schemaIncludedProperties.length; i++) {
701
- _this._schemaIncludedProperties.add(settings.schemaIncludedProperties[i]);
702
- }
703
- }
704
- _this._summaryDescriptions = settings.summaryDescriptions;
705
- _this._summaryScope = settings.summaryScope;
706
- _this._enableJsonp = settings.enableJsonp;
707
- _this._isAggregationSupported = settings.isAggregationSupported;
708
- window.setTimeout(_this.doWork, 100);
709
- return _this;
710
- }
711
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "sortDescriptions", {
712
- get: function () {
713
- return this._sortDescriptions;
714
- },
715
- enumerable: false,
716
- configurable: true
717
- });
718
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "filterExpressions", {
719
- get: function () {
720
- return this._filterExpressions;
721
- },
722
- enumerable: false,
723
- configurable: true
724
- });
725
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "desiredProperties", {
726
- get: function () {
727
- return this._desiredPropeties;
728
- },
729
- enumerable: false,
730
- configurable: true
731
- });
732
- ODataVirtualDataSourceDataProviderWorker.prototype.initialize = function () {
733
- _super.prototype.initialize.call(this);
734
- };
735
- ODataVirtualDataSourceDataProviderWorker.prototype.getTaskDataHolder = function () {
736
- var holder = new ODataVirtualDataSourceProviderTaskDataHolder();
737
- return holder;
738
- };
739
- ODataVirtualDataSourceDataProviderWorker.prototype.getCompletedTaskData = function (holder, completed) {
740
- _super.prototype.getCompletedTaskData.call(this, holder, completed);
741
- };
742
- ODataVirtualDataSourceDataProviderWorker.prototype.removeCompletedTaskData = function (holder, completed) {
743
- _super.prototype.removeCompletedTaskData.call(this, holder, completed);
744
- };
745
- ODataVirtualDataSourceDataProviderWorker.prototype.getTasksData = function (holder) {
746
- _super.prototype.getTasksData.call(this, holder);
747
- };
748
- ODataVirtualDataSourceDataProviderWorker.prototype.iter = function (coll) {
749
- var i;
750
- return __generator(this, function (_a) {
751
- switch (_a.label) {
752
- case 0:
753
- i = 0;
754
- _a.label = 1;
755
- case 1:
756
- if (!(i < coll.size()))
757
- return [3 /*break*/, 4];
758
- return [4 /*yield*/, coll.get(i)];
759
- case 2:
760
- _a.sent();
761
- _a.label = 3;
762
- case 3:
763
- i++;
764
- return [3 /*break*/, 1];
765
- case 4: return [2 /*return*/];
766
- }
767
- });
768
- };
769
- ODataVirtualDataSourceDataProviderWorker.prototype.iterFilter = function (coll) {
770
- var i;
771
- return __generator(this, function (_a) {
772
- switch (_a.label) {
773
- case 0:
774
- i = 0;
775
- _a.label = 1;
776
- case 1:
777
- if (!(i < coll.size()))
778
- return [3 /*break*/, 4];
779
- return [4 /*yield*/, coll.get(i)];
780
- case 2:
781
- _a.sent();
782
- _a.label = 3;
783
- case 3:
784
- i++;
785
- return [3 /*break*/, 1];
786
- case 4: return [2 /*return*/];
787
- }
788
- });
789
- };
790
- ODataVirtualDataSourceDataProviderWorker.prototype.iterSummaries = function (summaries) {
791
- var i;
792
- return __generator(this, function (_a) {
793
- switch (_a.label) {
794
- case 0:
795
- i = 0;
796
- _a.label = 1;
797
- case 1:
798
- if (!(i < summaries.size()))
799
- return [3 /*break*/, 4];
800
- return [4 /*yield*/, summaries.get(i)];
801
- case 2:
802
- _a.sent();
803
- _a.label = 3;
804
- case 3:
805
- i++;
806
- return [3 /*break*/, 1];
807
- case 4: return [2 /*return*/];
808
- }
809
- });
810
- };
811
- ODataVirtualDataSourceDataProviderWorker.prototype.processCompletedTask = function (completedTask, currentDelay, pageIndex, taskDataHolder) {
812
- var _this = this;
813
- var h = taskDataHolder;
814
- var schema = null;
815
- var result = null;
816
- var schemaFetchCount = -1;
817
- var task = completedTask.task;
818
- try {
819
- if (task.hasErrors) {
820
- this.retryIndex(pageIndex, currentDelay);
821
- return;
822
- }
823
- if (pageIndex == ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
824
- result = task.result;
825
- schemaFetchCount = (result['@odata.count']);
826
- }
827
- else {
828
- result = task.result;
829
- }
830
- }
831
- catch (e) {
832
- this.retryIndex(pageIndex, currentDelay);
833
- return;
834
- }
835
- if (schemaFetchCount >= 0) {
836
- this.actualCount = schemaFetchCount;
837
- }
838
- else {
839
- this.actualCount = (result['@odata.count']);
840
- }
841
- schema = this.actualSchema;
842
- if (schema == null) {
843
- var requests_1 = 0;
844
- this.resolveSchema(function (s) {
845
- // resolveSchema success callback
846
- _this.actualSchema = s;
847
- if (_this._isAggregationSupported && (_this._groupDescriptions.size() !== 0 || _this._summaryDescriptions.size() !== 0)) {
848
- if (_this._groupDescriptions.size() > 0) {
849
- requests_1++;
850
- _this.resolveGroupInformation(function (g) {
851
- // group info success
852
- requests_1--;
853
- if (requests_1 === 0) {
854
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
855
- }
856
- }, function () {
857
- // group info failure
858
- _this.retryIndex(pageIndex, currentDelay);
859
- return;
860
- });
861
- }
862
- if (_this._summaryDescriptions.size() > 0) {
863
- requests_1++;
864
- _this.resolveSummaryInformation(function (g) {
865
- // summary info success
866
- requests_1--;
867
- if (requests_1 === 0) {
868
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
869
- }
870
- }, function () {
871
- // summary info failure
872
- _this.retryIndex(pageIndex, currentDelay);
873
- return;
874
- });
875
- }
876
- }
877
- else {
878
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
879
- }
880
- }, function () {
881
- // resolveSchema failure callback
882
- _this.retryIndex(pageIndex, currentDelay);
883
- return;
884
- });
885
- return;
886
- }
887
- this.finishProcessingCompletedTask(task, pageIndex, schema, result);
888
- };
889
- ODataVirtualDataSourceDataProviderWorker.prototype.finishProcessingCompletedTask = function (task, pageIndex, schema, result) {
890
- var _this = this;
891
- var executionContext;
892
- var pageLoaded;
893
- var groupInformation;
894
- var summaryInformation;
895
- this.actualSchema = schema;
896
- executionContext = this.executionContext;
897
- groupInformation = this._groupInformation;
898
- summaryInformation = this._summaryInformation;
899
- pageLoaded = this.pageLoaded;
900
- var page = null;
901
- if (result != null) {
902
- page = new ODataDataSourcePage(result, schema, groupInformation, summaryInformation, pageIndex);
903
- if (!this.isLastPage(pageIndex) && page.count() > 0 && !this.populatedActualPageSize) {
904
- this.populatedActualPageSize = true;
905
- this.actualPageSize = page.count();
906
- }
907
- }
908
- else {
909
- page = new ODataDataSourcePage(null, schema, groupInformation, summaryInformation, pageIndex);
910
- }
911
- if (this.pageLoaded != null) {
912
- if (this.executionContext != null) {
913
- if (executionContext == null || pageLoaded == null) {
914
- this.shutdown();
915
- return;
916
- }
917
- executionContext.execute(function () { return pageLoaded(page, _this.actualCount, _this.actualPageSize); });
918
- }
919
- else {
920
- if (pageLoaded == null) {
921
- this.shutdown();
922
- return;
923
- }
924
- pageLoaded(page, this.actualCount, this.actualPageSize);
925
- }
926
- }
927
- };
928
- ODataVirtualDataSourceDataProviderWorker.prototype.resolveGroupInformation = function (finishAction, failureAction) {
929
- var e_2, _a;
930
- var _this = this;
931
- if (this._groupInformation != null) {
932
- finishAction(this._groupInformation);
933
- return;
934
- }
935
- var orderBy = "";
936
- var groupBy = "";
937
- var filter = null;
938
- var summary = "";
939
- if (this._groupDescriptions == null || this._groupDescriptions.size() == 0) {
940
- finishAction(null);
941
- return;
942
- }
943
- filter = this._filterString;
944
- this.updateFilterString();
945
- if (this._groupDescriptions != null) {
946
- var first1 = true;
947
- try {
948
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
949
- var group = _c.value;
950
- if (first1) {
951
- first1 = false;
952
- }
953
- else {
954
- orderBy += ", ";
955
- groupBy += ", ";
956
- }
957
- groupBy += group.propertyName;
958
- if (group.direction === ListSortDirection.Descending) {
959
- orderBy += group.propertyName + " desc";
960
- }
961
- else {
962
- orderBy += group.propertyName + " asc";
963
- }
964
- }
965
- }
966
- catch (e_2_1) {
967
- e_2 = { error: e_2_1 };
968
- }
969
- finally {
970
- try {
971
- if (_c && !_c.done && (_a = _b.return))
972
- _a.call(_b);
973
- }
974
- finally {
975
- if (e_2)
976
- throw e_2.error;
977
- }
978
- }
979
- }
980
- if (this._summaryScope === DataSourceSummaryScope.Both || this._summaryScope === DataSourceSummaryScope.Groups) {
981
- var summaryParameters = this.getSummaryQueryParameters(true);
982
- if (!stringIsNullOrEmpty(summaryParameters)) {
983
- summary = ", " + summaryParameters;
984
- }
985
- }
986
- var commandText = this._entitySet + "?$orderby=" + orderBy + "&$apply=";
987
- if (!stringIsNullOrEmpty(filter)) {
988
- commandText += "filter(" + filter + ")/";
989
- }
990
- commandText += "groupby((" + groupBy + "), aggregate($count as $__count" + summary + "))";
991
- try {
992
- var groupInformation_1 = [];
993
- var success_1 = function (data, response) { return _this.groupSuccess(data, response, finishAction, failureAction, groupInformation_1); };
994
- var failure_1 = function (err) { return _this.groupError(err, finishAction, failureAction, groupInformation_1); };
995
- var run_ = null;
996
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
997
- var request = {
998
- requestUri: this._baseUri + "/" + commandText,
999
- enableJsonpCallback: this._enableJsonp,
1000
- method: 'GET',
1001
- headers: headers,
1002
- data: null
1003
- };
1004
- run_ = function () {
1005
- odatajs.oData.request(request, success_1, failure_1);
1006
- };
1007
- run_();
1008
- }
1009
- catch (e) {
1010
- failureAction();
1011
- }
1012
- };
1013
- ODataVirtualDataSourceDataProviderWorker.prototype.groupError = function (err, finishAction, failureAction, groupInformation) {
1014
- this._groupInformation = null;
1015
- };
1016
- ODataVirtualDataSourceDataProviderWorker.prototype.groupSuccess = function (data, response, finishAction, failureAction, groupInformation) {
1017
- var e_3, _a;
1018
- var groupNames = [];
1019
- try {
1020
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
1021
- var group = _c.value;
1022
- groupNames.push(group.propertyName);
1023
- }
1024
- }
1025
- catch (e_3_1) {
1026
- e_3 = { error: e_3_1 };
1027
- }
1028
- finally {
1029
- try {
1030
- if (_c && !_c.done && (_a = _b.return))
1031
- _a.call(_b);
1032
- }
1033
- finally {
1034
- if (e_3)
1035
- throw e_3.error;
1036
- }
1037
- }
1038
- var groupNamesArray = groupNames;
1039
- if (data && data.value && data.value.length > 0) {
1040
- var currentIndex = 0;
1041
- for (var i = 0; i < data.value.length; i++) {
1042
- this.addGroup(groupInformation, groupNames, groupNames, currentIndex, data.value[i]);
1043
- }
1044
- }
1045
- this._groupInformation = groupInformation;
1046
- finishAction(this._groupInformation);
1047
- };
1048
- ODataVirtualDataSourceDataProviderWorker.prototype.addGroup = function (groupInformation, groupNames, groupNamesArray, currentIndex, group) {
1049
- var e_4, _a;
1050
- var groupValues = [];
1051
- try {
1052
- for (var groupNames_1 = __values(groupNames), groupNames_1_1 = groupNames_1.next(); !groupNames_1_1.done; groupNames_1_1 = groupNames_1.next()) {
1053
- var name_1 = groupNames_1_1.value;
1054
- if (group[name_1]) {
1055
- groupValues.push(group[name_1]);
1056
- }
1057
- }
1058
- }
1059
- catch (e_4_1) {
1060
- e_4 = { error: e_4_1 };
1061
- }
1062
- finally {
1063
- try {
1064
- if (groupNames_1_1 && !groupNames_1_1.done && (_a = groupNames_1.return))
1065
- _a.call(groupNames_1);
1066
- }
1067
- finally {
1068
- if (e_4)
1069
- throw e_4.error;
1070
- }
1071
- }
1072
- var groupCount = 0;
1073
- if (group["$__count"]) {
1074
- groupCount = Convert.toInt321(group["$__count"]);
1075
- }
1076
- var summaryResults = null;
1077
- if (this._summaryScope == DataSourceSummaryScope.Both || this._summaryScope == DataSourceSummaryScope.Groups) {
1078
- summaryResults = this.createSummaryResults(group);
1079
- }
1080
- var groupInfo = new DefaultSectionInformation(currentIndex, currentIndex + (groupCount - 1), groupNamesArray, groupValues, summaryResults);
1081
- groupInformation.push(groupInfo);
1082
- };
1083
- ODataVirtualDataSourceDataProviderWorker.prototype.resolveSummaryInformation = function (finishAction, failureAction) {
1084
- var _this = this;
1085
- if (this._summaryInformation != null) {
1086
- finishAction(this._summaryInformation);
1087
- return;
1088
- }
1089
- var filter = null;
1090
- var summary = null;
1091
- if (this._summaryDescriptions == null ||
1092
- this._summaryDescriptions.size() == 0 ||
1093
- this._summaryScope == DataSourceSummaryScope.Groups ||
1094
- this._summaryScope == DataSourceSummaryScope.None) {
1095
- finishAction(null);
1096
- return;
1097
- }
1098
- filter = this._filterString;
1099
- this.updateFilterString();
1100
- summary = this.getSummaryQueryParameters(false);
1101
- var commandText = this._entitySet + "?$apply=";
1102
- if (!stringIsNullOrEmpty(filter)) {
1103
- commandText += "filter(" + filter + ")/";
1104
- }
1105
- commandText += "aggregate(" + summary + ")";
1106
- try {
1107
- var summaryInformation_1 = [];
1108
- var success_2 = function (data, response) { return _this.summarySuccess(data, response, finishAction, failureAction, summaryInformation_1); };
1109
- var failure_2 = function (err) { return _this.summaryError(err, finishAction, failureAction, summaryInformation_1); };
1110
- var run_ = null;
1111
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
1112
- var request = {
1113
- requestUri: this._baseUri + "/" + commandText,
1114
- enableJsonpCallback: this._enableJsonp,
1115
- method: 'GET',
1116
- headers: headers,
1117
- data: null
1118
- };
1119
- run_ = function () {
1120
- odatajs.oData.request(request, success_2, failure_2);
1121
- };
1122
- run_();
1123
- }
1124
- catch (e) {
1125
- failureAction();
1126
- }
1127
- };
1128
- ODataVirtualDataSourceDataProviderWorker.prototype.summarySuccess = function (data, response, finishAction, failureAction, summaryInformation) {
1129
- if (data && data.value && data.value.length > 0) {
1130
- summaryInformation = this.createSummaryResults(data.value[0]);
1131
- }
1132
- this._summaryInformation = summaryInformation;
1133
- finishAction(this._summaryInformation);
1134
- };
1135
- ODataVirtualDataSourceDataProviderWorker.prototype.summaryError = function (err, finishAction, failureAction, summaryInformation) {
1136
- this._summaryInformation = null;
1137
- };
1138
- ODataVirtualDataSourceDataProviderWorker.prototype.getSummaryQueryParameters = function (ignoreCount) {
1139
- var e_5, _a;
1140
- var result = "";
1141
- if (this._summaryDescriptions != null) {
1142
- var first = true;
1143
- var countExists = false;
1144
- try {
1145
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
1146
- var summary = _c.value;
1147
- if (summary.operand == DataSourceSummaryOperand.Count && (ignoreCount || countExists)) {
1148
- continue;
1149
- }
1150
- if (!first) {
1151
- result += ", ";
1152
- }
1153
- switch (summary.operand) {
1154
- case DataSourceSummaryOperand.Average:
1155
- result += summary.propertyName + " with average as " + summary.propertyName + "Average";
1156
- break;
1157
- case DataSourceSummaryOperand.Min:
1158
- result += summary.propertyName + " with min as " + summary.propertyName + "Min";
1159
- break;
1160
- case DataSourceSummaryOperand.Max:
1161
- result += summary.propertyName + " with max as " + summary.propertyName + "Max";
1162
- break;
1163
- case DataSourceSummaryOperand.Sum:
1164
- result += summary.propertyName + " with sum as " + summary.propertyName + "Sum";
1165
- break;
1166
- case DataSourceSummaryOperand.Count:
1167
- result += "$count as $__count";
1168
- countExists = true;
1169
- break;
1170
- }
1171
- first = false;
1172
- }
1173
- }
1174
- catch (e_5_1) {
1175
- e_5 = { error: e_5_1 };
1176
- }
1177
- finally {
1178
- try {
1179
- if (_c && !_c.done && (_a = _b.return))
1180
- _a.call(_b);
1181
- }
1182
- finally {
1183
- if (e_5)
1184
- throw e_5.error;
1185
- }
1186
- }
1187
- }
1188
- return result;
1189
- };
1190
- ODataVirtualDataSourceDataProviderWorker.prototype.createSummaryResults = function (data) {
1191
- var e_6, _a;
1192
- var summaryResults = [];
1193
- try {
1194
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
1195
- var summary = _c.value;
1196
- var summaryName = summary.propertyName;
1197
- switch (summary.operand) {
1198
- case DataSourceSummaryOperand.Average:
1199
- summaryName += "Average";
1200
- break;
1201
- case DataSourceSummaryOperand.Min:
1202
- summaryName += "Min";
1203
- break;
1204
- case DataSourceSummaryOperand.Max:
1205
- summaryName += "Max";
1206
- break;
1207
- case DataSourceSummaryOperand.Sum:
1208
- summaryName += "Sum";
1209
- break;
1210
- case DataSourceSummaryOperand.Count:
1211
- summaryName = "$__count";
1212
- break;
1213
- }
1214
- var summaryValue = null;
1215
- if (data && data[summaryName]) {
1216
- summaryValue = data[summaryName];
1217
- }
1218
- var summaryResult = new DefaultSummaryResult(summary.propertyName, summary.operand, summaryValue);
1219
- summaryResults.push(summaryResult);
1220
- }
1221
- }
1222
- catch (e_6_1) {
1223
- e_6 = { error: e_6_1 };
1224
- }
1225
- finally {
1226
- try {
1227
- if (_c && !_c.done && (_a = _b.return))
1228
- _a.call(_b);
1229
- }
1230
- finally {
1231
- if (e_6)
1232
- throw e_6.error;
1233
- }
1234
- }
1235
- return summaryResults;
1236
- };
1237
- ODataVirtualDataSourceDataProviderWorker.prototype.resolveSchema = function (finishAction, failureAction) {
1238
- var _this = this;
1239
- var success_ = function (res) {
1240
- var sp = new ODataSchemaProvider(res);
1241
- var schema = sp.getODataDataSourceSchema(_this._entitySet);
1242
- if (_this._schemaIncludedProperties != null) {
1243
- var propertyNames = [];
1244
- var propertyTypes = [];
1245
- for (var i = 0; i < schema.propertyNames.length; i++) {
1246
- if (!_this._schemaIncludedProperties.has(schema.propertyNames[i])) {
1247
- continue;
1248
- }
1249
- propertyNames.push(schema.propertyNames[i]);
1250
- propertyTypes.push(schema.propertyTypes[i]);
1251
- }
1252
- schema = new ODataDataSourceSchema(propertyNames, propertyTypes, schema.primaryKey);
1253
- }
1254
- finishAction(schema);
1255
- };
1256
- var failure_ = function () { return failureAction(); };
1257
- var baseUri_ = this._baseUri;
1258
- var request = new XMLHttpRequest();
1259
- request.onreadystatechange = function () {
1260
- if (request.readyState === 4) {
1261
- if (request.status === 200) {
1262
- success_(request.responseText);
1263
- }
1264
- else {
1265
- failure_();
1266
- }
1267
- }
1268
- };
1269
- request.open('Get', baseUri_ + '/$metadata');
1270
- request.send();
1271
- ;
1272
- };
1273
- ODataVirtualDataSourceDataProviderWorker.prototype.makeTaskForRequest = function (request, retryDelay) {
1274
- var e_7, _a;
1275
- var actualPageSize = 0;
1276
- var sortDescriptions = null;
1277
- actualPageSize = this.actualPageSize;
1278
- sortDescriptions = this.sortDescriptions;
1279
- var requestUrl = this._baseUri;
1280
- requestUrl += "/" + this._entitySet;
1281
- var queryStarted = false;
1282
- this.updateFilterString();
1283
- if (this._filterString != null) {
1284
- if (!queryStarted) {
1285
- queryStarted = true;
1286
- requestUrl += "?";
1287
- }
1288
- else {
1289
- requestUrl += "&";
1290
- }
1291
- requestUrl += "$filter=" + this._filterString;
1292
- }
1293
- if (this.sortDescriptions != null) {
1294
- var sortString = null;
1295
- try {
1296
- for (var _b = __values(this.iter(this.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
1297
- var sort = _c.value;
1298
- if (sortString == null) {
1299
- sortString = "";
1300
- }
1301
- else {
1302
- sortString += ", ";
1303
- }
1304
- if (sort.direction == ListSortDirection.Descending) {
1305
- sortString += sort.propertyName + " desc";
1306
- }
1307
- else {
1308
- sortString += sort.propertyName;
1309
- }
1310
- }
1311
- }
1312
- catch (e_7_1) {
1313
- e_7 = { error: e_7_1 };
1314
- }
1315
- finally {
1316
- try {
1317
- if (_c && !_c.done && (_a = _b.return))
1318
- _a.call(_b);
1319
- }
1320
- finally {
1321
- if (e_7)
1322
- throw e_7.error;
1323
- }
1324
- }
1325
- if (sortString != null) {
1326
- if (!queryStarted) {
1327
- queryStarted = true;
1328
- requestUrl += "?";
1329
- }
1330
- else {
1331
- requestUrl += "&";
1332
- }
1333
- requestUrl += "$orderby=" + sortString;
1334
- }
1335
- }
1336
- if (this.desiredProperties != null && this.desiredProperties.length > 0) {
1337
- var selectString = "";
1338
- var first = true;
1339
- var $t = this.desiredProperties;
1340
- for (var i = 0; i < $t.length; i++) {
1341
- var select = $t[i];
1342
- if (first) {
1343
- first = false;
1344
- }
1345
- else {
1346
- selectString += ", ";
1347
- }
1348
- selectString += select;
1349
- }
1350
- if (!queryStarted) {
1351
- queryStarted = true;
1352
- requestUrl += "?";
1353
- }
1354
- else {
1355
- requestUrl += "&";
1356
- }
1357
- requestUrl += "$select=" + selectString;
1358
- }
1359
- var task = new AsyncVirtualDataTask();
1360
- if (request.index == ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
1361
- this.executeRequest(requestUrl, queryStarted, 0, actualPageSize, task);
1362
- }
1363
- else {
1364
- this.executeRequest(requestUrl, queryStarted, request.index * actualPageSize, actualPageSize, task);
1365
- }
1366
- request.taskHolder = new AsyncDataSourcePageTaskHolder();
1367
- request.taskHolder.task = task;
1368
- this.tasks.add(request);
1369
- };
1370
- ODataVirtualDataSourceDataProviderWorker.prototype.updateFilterString = function () {
1371
- var e_8, _a;
1372
- if (this.filterExpressions != null && this.filterExpressions.size() > 0 && this._filterString == null) {
1373
- var sb = "";
1374
- var first = true;
1375
- try {
1376
- for (var _b = __values(this.iterFilter(this.filterExpressions)), _c = _b.next(); !_c.done; _c = _b.next()) {
1377
- var expr = _c.value;
1378
- if (first) {
1379
- first = false;
1380
- }
1381
- else {
1382
- sb += " AND ";
1383
- }
1384
- var visitor = new ODataDataSourceFilterExpressionVisitor(0);
1385
- visitor.visit(expr);
1386
- var txt = visitor.toString();
1387
- if (this.filterExpressions.size() > 1) {
1388
- txt = "(" + txt + ")";
1389
- }
1390
- sb += (txt);
1391
- }
1392
- }
1393
- catch (e_8_1) {
1394
- e_8 = { error: e_8_1 };
1395
- }
1396
- finally {
1397
- try {
1398
- if (_c && !_c.done && (_a = _b.return))
1399
- _a.call(_b);
1400
- }
1401
- finally {
1402
- if (e_8)
1403
- throw e_8.error;
1404
- }
1405
- }
1406
- this._filterString = sb;
1407
- }
1408
- };
1409
- ODataVirtualDataSourceDataProviderWorker.prototype.executeRequest = function (requestUrl, queryStarted, skip, top, task) {
1410
- var _this = this;
1411
- if (!queryStarted) {
1412
- queryStarted = true;
1413
- requestUrl += "?";
1414
- }
1415
- else {
1416
- requestUrl += "&";
1417
- }
1418
- requestUrl += "$skip=" + skip + "&$top=" + top + "&$count=true";
1419
- var requestUrl_ = requestUrl;
1420
- var self_ = this;
1421
- var success_ = function (data, response) { return _this.success(task, data, response); };
1422
- var failure_ = function (err) { return _this.error(task, err); };
1423
- var run_ = null;
1424
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
1425
- var request = {
1426
- requestUri: requestUrl_,
1427
- enableJsonpCallback: this._enableJsonp,
1428
- method: 'GET',
1429
- headers: headers,
1430
- data: null
1431
- };
1432
- run_ = function () {
1433
- odatajs.oData.request(request, success_, failure_);
1434
- };
1435
- task.run = run_;
1436
- };
1437
- ODataVirtualDataSourceDataProviderWorker.prototype.success = function (t, data, response) {
1438
- t.result = data;
1439
- t.isCompleted = true;
1440
- };
1441
- ODataVirtualDataSourceDataProviderWorker.prototype.error = function (t, result) {
1442
- t.isCompleted = true;
1443
- t.hasErrors = true;
1444
- };
1445
- ODataVirtualDataSourceDataProviderWorker.prototype.createBatchRequest = function (changes) {
1446
- var requests = [];
1447
- for (var i = 0; i < changes.length; i++) {
1448
- var c = changes[i];
1449
- var headers = { "Content-Type": "application/json", "odata-version": "4.0" };
1450
- if (c.transactionType === TransactionType.Add) {
1451
- requests.push({
1452
- method: "POST",
1453
- id: "r".concat(i),
1454
- atomicityGroup: "g1",
1455
- url: "".concat(this._baseUri, "/").concat(this._entitySet),
1456
- headers: headers,
1457
- body: c.value,
1458
- });
1459
- }
1460
- else if (c.transactionType === TransactionType.Update) {
1461
- if (c.version) {
1462
- headers["If-Match"] = c.version;
1463
- }
1464
- requests.push({
1465
- method: "PATCH",
1466
- id: "r".concat(i),
1467
- atomicityGroup: "g1",
1468
- url: "".concat(this._baseUri, "/").concat(this.getRequestUriWithKey(c.id)),
1469
- headers: headers,
1470
- body: c.value,
1471
- });
1472
- }
1473
- else if (c.transactionType === TransactionType.Delete) {
1474
- if (c.version) {
1475
- headers["If-Match"] = c.version;
1476
- }
1477
- requests.push({
1478
- method: "DELETE",
1479
- id: "r".concat(i),
1480
- atomicityGroup: "g1",
1481
- url: "".concat(this._baseUri, "/").concat(this.getRequestUriWithKey(c.id)),
1482
- headers: headers,
1483
- });
1484
- }
1485
- }
1486
- var request = {
1487
- requestUri: "".concat(this._baseUri, "/$batch"),
1488
- method: "POST",
1489
- headers: { "Content-Type": "application/json" },
1490
- body: JSON.stringify({ requests: requests })
1491
- };
1492
- var self = this;
1493
- odatajs.oData.request(request, function (data) {
1494
- if (data && data.responses) {
1495
- if (data.responses.length > 0) {
1496
- var success = true;
1497
- var messages = [];
1498
- var _loop_1 = function (i) {
1499
- if (data.responses[i].status !== 200 &&
1500
- data.responses[i].status !== 204) {
1501
- success = false;
1502
- var failedRequest = requests.filter(function (r) { return r.id == data.responses[i].id; })[0];
1503
- if (failedRequest) {
1504
- var msg = "".concat(failedRequest.method, " request failed with code ").concat(data.responses[i].status);
1505
- messages.push(msg);
1506
- console.error(msg);
1507
- }
1508
- return "break";
1509
- }
1510
- };
1511
- for (var i = 0; i < data.responses.length; i++) {
1512
- var state_1 = _loop_1(i);
1513
- if (state_1 === "break")
1514
- break;
1515
- }
1516
- if (success) {
1517
- self.batchCompleted(true, true, null);
1518
- }
1519
- else {
1520
- self.batchCompleted(false, true, messages);
1521
- }
1522
- }
1523
- else {
1524
- self.batchCompleted(false, true, null);
1525
- }
1526
- }
1527
- }, function (error) {
1528
- var messages = [];
1529
- if (error && error.message) {
1530
- messages.push(error.message);
1531
- }
1532
- self.batchCompleted(false, true, messages);
1533
- });
1534
- };
1535
- ODataVirtualDataSourceDataProviderWorker.prototype.getRequestUriWithKey = function (key) {
1536
- var result = "";
1537
- var keys = Object.keys(key);
1538
- for (var i = 0; i < keys.length; i++) {
1539
- if (i > 0) {
1540
- result += ",";
1541
- }
1542
- result += "".concat(keys[i], "=").concat(key[keys[i]]);
1543
- }
1544
- return "".concat(this._entitySet, "(").concat(result, ")");
1545
- };
1546
- ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex = -1;
1547
- return ODataVirtualDataSourceDataProviderWorker;
1548
- }(AsyncVirtualDataSourceProviderWorker));
1549
-
1550
- var ODataVirtualDataSourceDataProviderWorkerSettings = /** @class */ /*@__PURE__*/ (function (_super) {
1551
- __extends(ODataVirtualDataSourceDataProviderWorkerSettings, _super);
1552
- function ODataVirtualDataSourceDataProviderWorkerSettings() {
1553
- var _this = _super !== null && _super.apply(this, arguments) || this;
1554
- _this._baseUri = null;
1555
- _this._entitySet = null;
1556
- _this._sortDescriptions = null;
1557
- _this._filterExpressions = null;
1558
- _this._propertiesRequested = null;
1559
- _this._schemaIncludedProperties = null;
1560
- _this._groupDescriptions = null;
1561
- _this._summaryDescriptions = null;
1562
- return _this;
1563
- }
1564
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "baseUri", {
1565
- get: function () {
1566
- return this._baseUri;
1567
- },
1568
- set: function (value) {
1569
- this._baseUri = value;
1570
- },
1571
- enumerable: false,
1572
- configurable: true
1573
- });
1574
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "entitySet", {
1575
- get: function () {
1576
- return this._entitySet;
1577
- },
1578
- set: function (value) {
1579
- this._entitySet = value;
1580
- },
1581
- enumerable: false,
1582
- configurable: true
1583
- });
1584
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "sortDescriptions", {
1585
- get: function () {
1586
- return this._sortDescriptions;
1587
- },
1588
- set: function (value) {
1589
- this._sortDescriptions = value;
1590
- },
1591
- enumerable: false,
1592
- configurable: true
1593
- });
1594
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "filterExpressions", {
1595
- get: function () {
1596
- return this._filterExpressions;
1597
- },
1598
- set: function (value) {
1599
- this._filterExpressions = value;
1600
- },
1601
- enumerable: false,
1602
- configurable: true
1603
- });
1604
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "propertiesRequested", {
1605
- get: function () {
1606
- return this._propertiesRequested;
1607
- },
1608
- set: function (value) {
1609
- this._propertiesRequested = value;
1610
- },
1611
- enumerable: false,
1612
- configurable: true
1613
- });
1614
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "schemaIncludedProperties", {
1615
- get: function () {
1616
- return this._schemaIncludedProperties;
1617
- },
1618
- set: function (value) {
1619
- this._schemaIncludedProperties = value;
1620
- },
1621
- enumerable: false,
1622
- configurable: true
1623
- });
1624
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "groupDescriptions", {
1625
- get: function () {
1626
- return this._groupDescriptions;
1627
- },
1628
- set: function (value) {
1629
- this._groupDescriptions = value;
1630
- },
1631
- enumerable: false,
1632
- configurable: true
1633
- });
1634
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "summaryDescriptions", {
1635
- get: function () {
1636
- return this._summaryDescriptions;
1637
- },
1638
- set: function (value) {
1639
- this._summaryDescriptions = value;
1640
- },
1641
- enumerable: false,
1642
- configurable: true
1643
- });
1644
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "summaryScope", {
1645
- get: function () {
1646
- return this._summaryscope;
1647
- },
1648
- set: function (value) {
1649
- this._summaryscope = value;
1650
- },
1651
- enumerable: false,
1652
- configurable: true
1653
- });
1654
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "enableJsonp", {
1655
- get: function () {
1656
- return this._enableJsonp;
1657
- },
1658
- set: function (isEnabled) {
1659
- this._enableJsonp = isEnabled;
1660
- },
1661
- enumerable: false,
1662
- configurable: true
1663
- });
1664
- Object.defineProperty(ODataVirtualDataSourceDataProviderWorkerSettings.prototype, "isAggregationSupported", {
1665
- get: function () {
1666
- return this._isAggregationSupported;
1667
- },
1668
- set: function (isSupported) {
1669
- this._isAggregationSupported = isSupported;
1670
- },
1671
- enumerable: false,
1672
- configurable: true
1673
- });
1674
- ODataVirtualDataSourceDataProviderWorkerSettings.$t = markType(ODataVirtualDataSourceDataProviderWorkerSettings, 'ODataVirtualDataSourceDataProviderWorkerSettings', AsyncVirtualDataSourceDataProviderWorkerSettings.$type);
1675
- return ODataVirtualDataSourceDataProviderWorkerSettings;
1676
- }(AsyncVirtualDataSourceDataProviderWorkerSettings));
1677
-
1678
- var ODataVirtualDataSourceDataProvider = /** @class */ /*@__PURE__*/ (function (_super) {
1679
- __extends(ODataVirtualDataSourceDataProvider, _super);
1680
- function ODataVirtualDataSourceDataProvider() {
1681
- var _this = _super.call(this) || this;
1682
- _this._worker = null;
1683
- _this._requests = new LinkedList();
1684
- _this._callback = null;
1685
- _this._pageLoaded = null;
1686
- _this._pageSizeRequested = 50;
1687
- _this._baseUri = null;
1688
- _this._entitySet = null;
1689
- _this._timeoutMilliseconds = 10000;
1690
- _this.schemaChanged = null;
1691
- _this._currentFullCount = 0;
1692
- _this._currentSchema = null;
1693
- _this._executionContext = null;
1694
- _this._updateNotifier = null;
1695
- _this._deferAutoRefresh = false;
1696
- _this._sortDescriptions = null;
1697
- _this._groupDescriptions = null;
1698
- _this._propertiesRequested = null;
1699
- _this._schemaIncludedProperties = null;
1700
- _this._filterExpressions = null;
1701
- _this._summaryDescriptions = null;
1702
- _this._enableJsonp = true;
1703
- _this._schemaFetchQueued = false;
1704
- _this._autoRefreshQueued = false;
1705
- _this._batchCompleted = null;
1706
- _this._sortDescriptions = new SortDescriptionCollection();
1707
- _this._sortDescriptions.onChanged = function () { return _this.sortDescriptions_CollectionChanged(null, null); };
1708
- _this._groupDescriptions = new SortDescriptionCollection();
1709
- _this._groupDescriptions.onChanged = function () { return _this.groupDescriptions_CollectionChanged(null, null); };
1710
- _this._filterExpressions = new FilterExpressionCollection();
1711
- _this._filterExpressions.onChanged = function () { return _this.filterExpressions_CollectionChanged(null, null); };
1712
- _this._summaryDescriptions = new SummaryDescriptionCollection();
1713
- _this._summaryDescriptions.onChanged = function () { return _this.summaryDescriptions_CollectionChanged(null, null); };
1714
- return _this;
1715
- }
1716
- ODataVirtualDataSourceDataProvider.prototype.filterExpressions_CollectionChanged = function (sender, e) {
1717
- this.queueAutoRefresh();
1718
- };
1719
- ODataVirtualDataSourceDataProvider.prototype.sortDescriptions_CollectionChanged = function (sender, e) {
1720
- this.queueAutoRefresh();
1721
- };
1722
- ODataVirtualDataSourceDataProvider.prototype.groupDescriptions_CollectionChanged = function (sender, e) {
1723
- this.queueAutoRefresh();
1724
- };
1725
- ODataVirtualDataSourceDataProvider.prototype.summaryDescriptions_CollectionChanged = function (sender, e) {
1726
- this.queueAutoRefresh();
1727
- };
1728
- ODataVirtualDataSourceDataProvider.prototype.addPageRequest = function (pageIndex, priority) {
1729
- if (this.deferAutoRefresh) {
1730
- return;
1731
- }
1732
- if (this._worker != null && this._worker.isShutdown) {
1733
- this._worker = null;
1734
- this._callback = null;
1735
- }
1736
- if (this._worker == null) {
1737
- this.createWorker();
1738
- }
1739
- if (priority == DataSourcePageRequestPriority.High) {
1740
- this._requests.addFirst(pageIndex);
1741
- }
1742
- else {
1743
- this._requests.addLast(pageIndex);
1744
- }
1745
- if (!this._worker.addPageRequest(pageIndex, priority)) {
1746
- this._worker = null;
1747
- this._callback = null;
1748
- this.addPageRequest(pageIndex, priority);
1749
- }
1750
- };
1751
- ODataVirtualDataSourceDataProvider.prototype.createWorker = function () {
1752
- if (!this.valid()) {
1753
- return;
1754
- }
1755
- this._callback = runOn(this, this.raisePageLoaded);
1756
- var settings = this.getWorkerSettings();
1757
- this._worker = new ODataVirtualDataSourceDataProviderWorker(settings);
1758
- };
1759
- ODataVirtualDataSourceDataProvider.prototype.valid = function () {
1760
- return this.entitySet != null && this.baseUri != null;
1761
- };
1762
- ODataVirtualDataSourceDataProvider.prototype.getWorkerSettings = function () {
1763
- var _this = this;
1764
- return ((function () {
1765
- var $ret = new ODataVirtualDataSourceDataProviderWorkerSettings();
1766
- $ret.baseUri = _this._baseUri;
1767
- $ret.entitySet = _this._entitySet;
1768
- $ret.pageSizeRequested = _this._pageSizeRequested;
1769
- $ret.timeoutMilliseconds = _this._timeoutMilliseconds;
1770
- $ret.pageLoaded = _this._callback;
1771
- $ret.batchCompleted = _this._batchCompleted;
1772
- $ret.executionContext = _this._executionContext;
1773
- $ret.sortDescriptions = _this._sortDescriptions;
1774
- $ret.groupDescriptions = _this._groupDescriptions;
1775
- $ret.filterExpressions = _this._filterExpressions;
1776
- $ret.propertiesRequested = _this._propertiesRequested;
1777
- $ret.schemaIncludedProperties = _this._schemaIncludedProperties;
1778
- $ret.summaryDescriptions = _this._summaryDescriptions;
1779
- $ret.summaryScope = _this._summaryScope;
1780
- $ret.enableJsonp = _this._enableJsonp;
1781
- $ret.isAggregationSupported = _this.isAggregationSupported;
1782
- return $ret;
1783
- })());
1784
- };
1785
- ODataVirtualDataSourceDataProvider.prototype.removePageRequest = function (pageIndex) {
1786
- var current = this._requests.first;
1787
- while (current != null) {
1788
- if (current.value == pageIndex) {
1789
- this._requests.remove(current);
1790
- }
1791
- current = current.next;
1792
- }
1793
- if (this._worker == null) {
1794
- return;
1795
- }
1796
- this._worker.removePageRequest(pageIndex);
1797
- };
1798
- ODataVirtualDataSourceDataProvider.prototype.removeAllPageRequests = function () {
1799
- this._requests.clear();
1800
- if (this._worker == null) {
1801
- return;
1802
- }
1803
- this._worker.removeAllPageRequests();
1804
- };
1805
- ODataVirtualDataSourceDataProvider.prototype.close = function () {
1806
- if (this._worker != null) {
1807
- this._worker.shutdown();
1808
- this._worker = null;
1809
- this._callback = null;
1810
- }
1811
- };
1812
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "pageLoaded", {
1813
- get: function () {
1814
- return this._pageLoaded;
1815
- },
1816
- set: function (value) {
1817
- this._pageLoaded = value;
1818
- this.queueAutoRefresh();
1819
- },
1820
- enumerable: false,
1821
- configurable: true
1822
- });
1823
- ODataVirtualDataSourceDataProvider.prototype.raisePageLoaded = function (page, fullCount, actualPageSize) {
1824
- if (this._pageLoaded != null) {
1825
- this._currentFullCount = fullCount;
1826
- if (this._currentSchema == null) {
1827
- var currentSchema = null;
1828
- if (page != null) {
1829
- currentSchema = page.schema();
1830
- }
1831
- this._currentSchema = currentSchema;
1832
- if (this.schemaChanged != null) {
1833
- this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this._currentSchema, this._currentFullCount));
1834
- }
1835
- }
1836
- if (page.pageIndex() != ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
1837
- this._pageLoaded(page, fullCount, actualPageSize);
1838
- }
1839
- }
1840
- };
1841
- ODataVirtualDataSourceDataProvider.prototype.killWorker = function () {
1842
- if (this._worker != null) {
1843
- this._worker.shutdown();
1844
- this._worker = null;
1845
- this._callback = null;
1846
- }
1847
- };
1848
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "pageSizeRequested", {
1849
- get: function () {
1850
- return this._pageSizeRequested;
1851
- },
1852
- set: function (value) {
1853
- this._pageSizeRequested = value;
1854
- this.queueAutoRefresh();
1855
- },
1856
- enumerable: false,
1857
- configurable: true
1858
- });
1859
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "baseUri", {
1860
- get: function () {
1861
- return this._baseUri;
1862
- },
1863
- set: function (value) {
1864
- var oldValue = this._baseUri;
1865
- this._baseUri = value;
1866
- if (oldValue != this._baseUri) {
1867
- this.queueAutoRefresh();
1868
- if (this.valid() && this.deferAutoRefresh) {
1869
- this.queueSchemaFetch();
1870
- }
1871
- }
1872
- },
1873
- enumerable: false,
1874
- configurable: true
1875
- });
1876
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "entitySet", {
1877
- get: function () {
1878
- return this._entitySet;
1879
- },
1880
- set: function (value) {
1881
- var oldValue = this._entitySet;
1882
- this._entitySet = value;
1883
- if (oldValue != this._entitySet) {
1884
- this.queueAutoRefresh();
1885
- if (this.valid() && this.deferAutoRefresh) {
1886
- this.queueSchemaFetch();
1887
- }
1888
- }
1889
- },
1890
- enumerable: false,
1891
- configurable: true
1892
- });
1893
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "timeoutMilliseconds", {
1894
- get: function () {
1895
- return this._timeoutMilliseconds;
1896
- },
1897
- set: function (value) {
1898
- this._timeoutMilliseconds = value;
1899
- this.queueAutoRefresh();
1900
- },
1901
- enumerable: false,
1902
- configurable: true
1903
- });
1904
- ODataVirtualDataSourceDataProvider.prototype.getItemValue = function (item, valueName) {
1905
- var dic = item;
1906
- if (dic.has(valueName)) {
1907
- return dic.get(valueName);
1908
- }
1909
- else {
1910
- return null;
1911
- }
1912
- };
1913
- ODataVirtualDataSourceDataProvider.prototype.setItemValue = function (item, valueName, value) {
1914
- // does nothing for virtual data.
1915
- };
1916
- ODataVirtualDataSourceDataProvider.prototype.removeItem = function (item) {
1917
- // does nothing for virtual data.
1918
- };
1919
- ODataVirtualDataSourceDataProvider.prototype.addItem = function (item) {
1920
- // does nothing for virtual data.
1921
- };
1922
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "actualCount", {
1923
- get: function () {
1924
- return this._currentFullCount;
1925
- },
1926
- enumerable: false,
1927
- configurable: true
1928
- });
1929
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "actualSchema", {
1930
- get: function () {
1931
- return this._currentSchema;
1932
- },
1933
- enumerable: false,
1934
- configurable: true
1935
- });
1936
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "executionContext", {
1937
- get: function () {
1938
- return this._executionContext;
1939
- },
1940
- set: function (value) {
1941
- this._executionContext = value;
1942
- this.queueAutoRefresh();
1943
- },
1944
- enumerable: false,
1945
- configurable: true
1946
- });
1947
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "updateNotifier", {
1948
- get: function () {
1949
- return this._updateNotifier;
1950
- },
1951
- set: function (value) {
1952
- this._updateNotifier = value;
1953
- },
1954
- enumerable: false,
1955
- configurable: true
1956
- });
1957
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "deferAutoRefresh", {
1958
- get: function () {
1959
- return this._deferAutoRefresh;
1960
- },
1961
- set: function (value) {
1962
- this._deferAutoRefresh = value;
1963
- if (!this._deferAutoRefresh) {
1964
- this.queueAutoRefresh();
1965
- }
1966
- if (this._deferAutoRefresh && this.valid() && this._currentSchema == null) {
1967
- this.queueSchemaFetch();
1968
- }
1969
- },
1970
- enumerable: false,
1971
- configurable: true
1972
- });
1973
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isSortingSupported", {
1974
- get: function () {
1975
- return true;
1976
- },
1977
- enumerable: false,
1978
- configurable: true
1979
- });
1980
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isGroupingSupported", {
1981
- get: function () {
1982
- return this.isAggregationSupported;
1983
- },
1984
- enumerable: false,
1985
- configurable: true
1986
- });
1987
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isFilteringSupported", {
1988
- get: function () {
1989
- return true;
1990
- },
1991
- enumerable: false,
1992
- configurable: true
1993
- });
1994
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isAggregationSupported", {
1995
- get: function () {
1996
- return this._isAggregationSupported;
1997
- },
1998
- set: function (isSupported) {
1999
- this._isAggregationSupported = isSupported;
2000
- },
2001
- enumerable: false,
2002
- configurable: true
2003
- });
2004
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "sortDescriptions", {
2005
- get: function () {
2006
- return this._sortDescriptions;
2007
- },
2008
- enumerable: false,
2009
- configurable: true
2010
- });
2011
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "groupDescriptions", {
2012
- get: function () {
2013
- return this._groupDescriptions;
2014
- },
2015
- enumerable: false,
2016
- configurable: true
2017
- });
2018
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "propertiesRequested", {
2019
- get: function () {
2020
- return this._propertiesRequested;
2021
- },
2022
- set: function (value) {
2023
- this._propertiesRequested = value;
2024
- this.queueAutoRefresh();
2025
- },
2026
- enumerable: false,
2027
- configurable: true
2028
- });
2029
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "schemaIncludedProperties", {
2030
- get: function () {
2031
- return this._schemaIncludedProperties;
2032
- },
2033
- set: function (value) {
2034
- this._schemaIncludedProperties = value;
2035
- this.queueAutoRefresh();
2036
- },
2037
- enumerable: false,
2038
- configurable: true
2039
- });
2040
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "filterExpressions", {
2041
- get: function () {
2042
- return this._filterExpressions;
2043
- },
2044
- enumerable: false,
2045
- configurable: true
2046
- });
2047
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "summaryDescriptions", {
2048
- get: function () {
2049
- return this._summaryDescriptions;
2050
- },
2051
- enumerable: false,
2052
- configurable: true
2053
- });
2054
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "summaryScope", {
2055
- get: function () {
2056
- return this._summaryScope;
2057
- },
2058
- set: function (value) {
2059
- this._summaryScope = value;
2060
- },
2061
- enumerable: false,
2062
- configurable: true
2063
- });
2064
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "enableJsonp", {
2065
- get: function () {
2066
- return this._enableJsonp;
2067
- },
2068
- set: function (isEnabled) {
2069
- this._enableJsonp = isEnabled;
2070
- },
2071
- enumerable: false,
2072
- configurable: true
2073
- });
2074
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "notifyUsingSourceIndexes", {
2075
- get: function () {
2076
- return true;
2077
- },
2078
- enumerable: false,
2079
- configurable: true
2080
- });
2081
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isItemIndexLookupSupported", {
2082
- get: function () {
2083
- return false;
2084
- },
2085
- enumerable: false,
2086
- configurable: true
2087
- });
2088
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "isKeyIndexLookupSupported", {
2089
- get: function () {
2090
- return false;
2091
- },
2092
- enumerable: false,
2093
- configurable: true
2094
- });
2095
- ODataVirtualDataSourceDataProvider.prototype.notifySetItem = function (index, oldItem, newItem) {
2096
- if (this.updateNotifier != null) {
2097
- this.updateNotifier.notifySetItem(index, oldItem, newItem);
2098
- }
2099
- };
2100
- ODataVirtualDataSourceDataProvider.prototype.notifyClearItems = function () {
2101
- if (this.updateNotifier != null) {
2102
- this.updateNotifier.notifyClearItems();
2103
- }
2104
- };
2105
- ODataVirtualDataSourceDataProvider.prototype.notifyInsertItem = function (index, newItem) {
2106
- if (this.updateNotifier != null) {
2107
- this.updateNotifier.notifyInsertItem(index, newItem);
2108
- }
2109
- };
2110
- ODataVirtualDataSourceDataProvider.prototype.notifyRemoveItem = function (index, oldItem) {
2111
- if (this.updateNotifier != null) {
2112
- this.updateNotifier.notifyRemoveItem(index, oldItem);
2113
- }
2114
- };
2115
- ODataVirtualDataSourceDataProvider.prototype.queueSchemaFetch = function () {
2116
- if (this._schemaFetchQueued) {
2117
- return;
2118
- }
2119
- if (this.executionContext != null) {
2120
- this._schemaFetchQueued = true;
2121
- this.executionContext.enqueueAction(runOn(this, this.doSchemaFetchInternal));
2122
- }
2123
- };
2124
- ODataVirtualDataSourceDataProvider.prototype.doSchemaFetchInternal = function () {
2125
- if (!this._schemaFetchQueued) {
2126
- return;
2127
- }
2128
- this._schemaFetchQueued = false;
2129
- this.schemaFetchInternal();
2130
- };
2131
- ODataVirtualDataSourceDataProvider.prototype.schemaFetchInternal = function () {
2132
- this.schemaFetchInternalOverride();
2133
- };
2134
- ODataVirtualDataSourceDataProvider.prototype.schemaFetchInternalOverride = function () {
2135
- if (!this.deferAutoRefresh) {
2136
- return;
2137
- }
2138
- this.removeAllPageRequests();
2139
- this.killWorker();
2140
- this.createWorker();
2141
- this.addSchemaRequest();
2142
- };
2143
- ODataVirtualDataSourceDataProvider.prototype.addSchemaRequest = function () {
2144
- this._worker.addPageRequest(ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex, DataSourcePageRequestPriority.High);
2145
- };
2146
- ODataVirtualDataSourceDataProvider.prototype.queueAutoRefresh = function () {
2147
- if (this.deferAutoRefresh) {
2148
- return;
2149
- }
2150
- if (this._autoRefreshQueued) {
2151
- return;
2152
- }
2153
- if (this.executionContext != null) {
2154
- this._autoRefreshQueued = true;
2155
- this.executionContext.enqueueAction(runOn(this, this.doRefreshInternal));
2156
- }
2157
- };
2158
- ODataVirtualDataSourceDataProvider.prototype.doRefreshInternal = function () {
2159
- if (this.deferAutoRefresh) {
2160
- this._autoRefreshQueued = false;
2161
- return;
2162
- }
2163
- if (!this._autoRefreshQueued) {
2164
- return;
2165
- }
2166
- this._autoRefreshQueued = false;
2167
- this.refreshInternal();
2168
- };
2169
- ODataVirtualDataSourceDataProvider.prototype.refreshInternal = function () {
2170
- this.refreshInternalOverride();
2171
- };
2172
- ODataVirtualDataSourceDataProvider.prototype.refreshInternalOverride = function () {
2173
- this.removeAllPageRequests();
2174
- this.killWorker();
2175
- this.createWorker();
2176
- this._worker.addPageRequest(0, DataSourcePageRequestPriority.Normal);
2177
- };
2178
- ODataVirtualDataSourceDataProvider.prototype.flushAutoRefresh = function () {
2179
- this.doRefreshInternal();
2180
- };
2181
- ODataVirtualDataSourceDataProvider.prototype.refresh = function () {
2182
- this.refreshInternal();
2183
- };
2184
- ODataVirtualDataSourceDataProvider.prototype.indexOfItem = function (item) {
2185
- return -1;
2186
- };
2187
- ODataVirtualDataSourceDataProvider.prototype.indexOfKey = function (key) {
2188
- return -1;
2189
- };
2190
- ODataVirtualDataSourceDataProvider.prototype.resolveSchemaPropertyType = function (propertyPath) {
2191
- if (this.actualSchema == null) {
2192
- return DataSourceSchemaPropertyType.ObjectValue;
2193
- }
2194
- if (stringContains(propertyPath, ".")) {
2195
- return DataSourceSchemaPropertyType.ObjectValue;
2196
- }
2197
- for (var i = 0; i < this.actualSchema.propertyNames.length; i++) {
2198
- var name_1 = this.actualSchema.propertyNames[i];
2199
- if (name_1 == propertyPath) {
2200
- return this.actualSchema.propertyTypes[i];
2201
- }
2202
- }
2203
- return DataSourceSchemaPropertyType.ObjectValue;
2204
- };
2205
- ODataVirtualDataSourceDataProvider.prototype.createBatchRequest = function (changes) {
2206
- if (this._worker) {
2207
- this._worker.createBatchRequest(changes);
2208
- }
2209
- };
2210
- Object.defineProperty(ODataVirtualDataSourceDataProvider.prototype, "batchCompleted", {
2211
- get: function () {
2212
- return this._batchCompleted;
2213
- },
2214
- set: function (value) {
2215
- this._batchCompleted = value;
2216
- },
2217
- enumerable: false,
2218
- configurable: true
2219
- });
2220
- ODataVirtualDataSourceDataProvider.$t = markType(ODataVirtualDataSourceDataProvider, 'ODataVirtualDataSourceDataProvider', Base.$type, [IDataSourceVirtualDataProvider_$type]);
2221
- return ODataVirtualDataSourceDataProvider;
2222
- }(Base));
2223
-
2224
- var ODataVirtualDataSource = /** @class */ /*@__PURE__*/ (function (_super) {
2225
- __extends(ODataVirtualDataSource, _super);
2226
- function ODataVirtualDataSource() {
2227
- var _this = _super.call(this) || this;
2228
- _this._baseUri = null;
2229
- _this._entitySet = null;
2230
- _this._timeoutMilliseconds = 10000;
2231
- _this._isAggregationSupportedByServer = false;
2232
- _this._enableJsonp = true;
2233
- _this.dataProvider = ((function () {
2234
- var $ret = new ODataVirtualDataSourceDataProvider();
2235
- $ret.executionContext = _this.executionContext;
2236
- $ret.enableJsonp = _this.enableJsonp;
2237
- $ret.isAggregationSupported = _this.isGroupingSupported;
2238
- return $ret;
2239
- })());
2240
- _this.externalDataSource = _this;
2241
- return _this;
2242
- }
2243
- ODataVirtualDataSource.prototype.onBaseUriChanged = function (oldValue, newValue) {
2244
- if (typeCast(ODataVirtualDataSourceDataProvider.$type, this.actualDataProvider) !== null) {
2245
- this.actualDataProvider.baseUri = this.baseUri;
2246
- }
2247
- this.queueAutoRefresh();
2248
- };
2249
- Object.defineProperty(ODataVirtualDataSource.prototype, "baseUri", {
2250
- get: function () {
2251
- return this._baseUri;
2252
- },
2253
- set: function (value) {
2254
- var oldValue = this._baseUri;
2255
- this._baseUri = value;
2256
- if (oldValue != this._baseUri) {
2257
- this.onBaseUriChanged(oldValue, this._baseUri);
2258
- }
2259
- },
2260
- enumerable: false,
2261
- configurable: true
2262
- });
2263
- ODataVirtualDataSource.prototype.onEntitySetChanged = function (oldValue, newValue) {
2264
- if (typeCast(ODataVirtualDataSourceDataProvider.$type, this.actualDataProvider) !== null) {
2265
- this.actualDataProvider.entitySet = this.entitySet;
2266
- }
2267
- this.queueAutoRefresh();
2268
- };
2269
- Object.defineProperty(ODataVirtualDataSource.prototype, "entitySet", {
2270
- get: function () {
2271
- return this._entitySet;
2272
- },
2273
- set: function (value) {
2274
- var oldValue = this._entitySet;
2275
- this._entitySet = value;
2276
- if (this._entitySet != oldValue) {
2277
- this.onEntitySetChanged(oldValue, this._entitySet);
2278
- }
2279
- },
2280
- enumerable: false,
2281
- configurable: true
2282
- });
2283
- ODataVirtualDataSource.prototype.onTimeoutMillisecondsChanged = function (oldValue, newValue) {
2284
- if (typeCast(ODataVirtualDataSourceDataProvider.$type, this.actualDataProvider) !== null) {
2285
- this.actualDataProvider.timeoutMilliseconds = this.timeoutMilliseconds;
2286
- }
2287
- };
2288
- Object.defineProperty(ODataVirtualDataSource.prototype, "timeoutMilliseconds", {
2289
- get: function () {
2290
- return this._timeoutMilliseconds;
2291
- },
2292
- set: function (value) {
2293
- var oldValue = this._timeoutMilliseconds;
2294
- this._timeoutMilliseconds = value;
2295
- if (oldValue != this._timeoutMilliseconds) {
2296
- this.onTimeoutMillisecondsChanged(oldValue, this._timeoutMilliseconds);
2297
- }
2298
- },
2299
- enumerable: false,
2300
- configurable: true
2301
- });
2302
- Object.defineProperty(ODataVirtualDataSource.prototype, "isSortingSupportedOverride", {
2303
- get: function () {
2304
- return true;
2305
- },
2306
- enumerable: false,
2307
- configurable: true
2308
- });
2309
- Object.defineProperty(ODataVirtualDataSource.prototype, "isFilteringSupportedOverride", {
2310
- get: function () {
2311
- return true;
2312
- },
2313
- enumerable: false,
2314
- configurable: true
2315
- });
2316
- Object.defineProperty(ODataVirtualDataSource.prototype, "isGroupingSupportedOverride", {
2317
- get: function () {
2318
- return this.isAggregationSupportedByServer;
2319
- },
2320
- enumerable: false,
2321
- configurable: true
2322
- });
2323
- Object.defineProperty(ODataVirtualDataSource.prototype, "isAggregationSupportedByServer", {
2324
- get: function () {
2325
- return this._isAggregationSupportedByServer;
2326
- },
2327
- set: function (isSupported) {
2328
- this._isAggregationSupportedByServer = isSupported;
2329
- if (typeCast(ODataVirtualDataSourceDataProvider.$type, this.actualDataProvider) !== null) {
2330
- this.actualDataProvider.isAggregationSupported = isSupported;
2331
- }
2332
- },
2333
- enumerable: false,
2334
- configurable: true
2335
- });
2336
- Object.defineProperty(ODataVirtualDataSource.prototype, "enableJsonp", {
2337
- get: function () {
2338
- return this._enableJsonp;
2339
- },
2340
- set: function (isEnabled) {
2341
- this._enableJsonp = isEnabled;
2342
- if (typeCast(ODataVirtualDataSourceDataProvider.$type, this.actualDataProvider) !== null) {
2343
- this.actualDataProvider.enableJsonp = isEnabled;
2344
- }
2345
- },
2346
- enumerable: false,
2347
- configurable: true
2348
- });
2349
- ODataVirtualDataSource.prototype.clone = function () {
2350
- var dataSource = new ODataVirtualDataSource();
2351
- dataSource.executionContext = this.executionContext;
2352
- dataSource.includeSummaryRowsInSection = this.includeSummaryRowsInSection;
2353
- dataSource.isSectionCollapsable = this.isSectionCollapsable;
2354
- dataSource.isSectionExpandedDefault = this.isSectionExpandedDefault;
2355
- //dataSource.isSectionHeaderNormalRow = this.isSectionHeaderNormalRow;
2356
- dataSource.isSectionSummaryRowsAtBottom = this.isSectionSummaryRowsAtBottom;
2357
- //dataSource.isSectionContentVisible = this.isSectionContentVisible;
2358
- dataSource.primaryKey = this.primaryKey;
2359
- dataSource.propertiesRequested = this.propertiesRequested;
2360
- dataSource.sectionHeaderDisplayMode = this.sectionHeaderDisplayMode;
2361
- dataSource.shouldEmitSectionFooters = this.shouldEmitSectionFooters;
2362
- dataSource.shouldEmitSectionHeaders = this.shouldEmitSectionHeaders;
2363
- dataSource.shouldEmitShiftedRows = this.shouldEmitShiftedRows;
2364
- dataSource.summaryScope = this.summaryScope;
2365
- for (var i = 0; i < this.groupDescriptions.size(); i++) {
2366
- dataSource.groupDescriptions.add(this.groupDescriptions.get(i));
2367
- }
2368
- for (var i = 0; i < this.sortDescriptions.size(); i++) {
2369
- dataSource.sortDescriptions.add(this.sortDescriptions.get(i));
2370
- }
2371
- for (var i = 0; i < this.filterExpressions.size(); i++) {
2372
- dataSource.filterExpressions.add(this.filterExpressions.get(i));
2373
- }
2374
- for (var i = 0; i < this.summaryDescriptions.size(); i++) {
2375
- dataSource.summaryDescriptions.add(this.summaryDescriptions.get(i));
2376
- }
2377
- dataSource.pageSizeRequested = this.pageSizeRequested;
2378
- dataSource.maxCachedPages = this.maxCachedPages;
2379
- dataSource.baseUri = this.baseUri;
2380
- dataSource.entitySet = this.entitySet;
2381
- dataSource.timeoutMilliseconds = this.timeoutMilliseconds;
2382
- dataSource.isAggregationSupportedByServer = this.isAggregationSupportedByServer;
2383
- dataSource.enableJsonp = this.enableJsonp;
2384
- return dataSource;
2385
- };
2386
- return ODataVirtualDataSource;
2387
- }(VirtualDataSource));
2388
-
2389
- var RestVirtualDataSourceProviderTaskDataHolder = /** @class */ /*@__PURE__*/ (function (_super) {
2390
- __extends(RestVirtualDataSourceProviderTaskDataHolder, _super);
2391
- function RestVirtualDataSourceProviderTaskDataHolder() {
2392
- return _super !== null && _super.apply(this, arguments) || this;
2393
- }
2394
- RestVirtualDataSourceProviderTaskDataHolder.$t = markType(RestVirtualDataSourceProviderTaskDataHolder, 'ODataVirtualDataSourceProviderTaskDataHolder', AsyncVirtualDataSourceProviderTaskDataHolder.$type);
2395
- return RestVirtualDataSourceProviderTaskDataHolder;
2396
- }(AsyncVirtualDataSourceProviderTaskDataHolder));
2397
-
2398
- var RestVirtualDataSourcePage = /** @class */ /*@__PURE__*/ (function () {
2399
- function RestVirtualDataSourcePage(sourceData_, schema, groupInformation, summaryInformation, pageIndex) {
2400
- this._actualData = null;
2401
- this._schema = null;
2402
- this._pageIndex = 0;
2403
- this._groupInformation = null;
2404
- this._summaryInformation = null;
2405
- if (sourceData_ == null) {
2406
- this._actualData = null;
2407
- }
2408
- else {
2409
- var count = (sourceData_.items.length);
2410
- this._actualData = [];
2411
- var dateProps = new Set();
2412
- for (var i = 0; i < schema.propertyNames.length; i++) {
2413
- if (schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeValue || schema.propertyTypes[i] == DataSourceSchemaPropertyType.DateTimeOffsetValue) {
2414
- dateProps.add(schema.propertyNames[i]);
2415
- }
2416
- }
2417
- var value_ = void 0;
2418
- var _loop_1 = function (i_) {
2419
- var currItem_ = sourceData_.items[i_];
2420
- var dict = new Map();
2421
- var properties = Array.from(Object.keys(currItem_));
2422
- var values = (properties.map(function (k) { return currItem_[k]; }));
2423
- for (var i1 = 0; i1 < properties.length; i1++) {
2424
- value_ = values[i1];
2425
- if (dateProps.has(properties[i1])) {
2426
- value_ = new Date(value_);
2427
- }
2428
- dict.set(properties[i1], value_);
2429
- }
2430
- this_1._actualData[i_] = dict;
2431
- };
2432
- var this_1 = this;
2433
- for (var i_ = 0; i_ < count; i_++) {
2434
- _loop_1(i_);
2435
- }
2436
- }
2437
- this._schema = schema;
2438
- this._groupInformation = groupInformation;
2439
- this._summaryInformation = summaryInformation;
2440
- this._pageIndex = pageIndex;
2441
- }
2442
- RestVirtualDataSourcePage.prototype.count = function () {
2443
- return this._actualData.length;
2444
- };
2445
- RestVirtualDataSourcePage.prototype.getItemAtIndex = function (index) {
2446
- return this._actualData[index];
2447
- };
2448
- RestVirtualDataSourcePage.prototype.getItemValueAtIndex = function (index, valueName) {
2449
- var item = this._actualData[index];
2450
- if (!item.has(valueName)) {
2451
- return null;
2452
- }
2453
- return item.get(valueName);
2454
- };
2455
- RestVirtualDataSourcePage.prototype.pageIndex = function () {
2456
- return this._pageIndex;
2457
- };
2458
- RestVirtualDataSourcePage.prototype.schema = function () {
2459
- return this._schema;
2460
- };
2461
- RestVirtualDataSourcePage.prototype.getGroupInformation = function () {
2462
- return this._groupInformation;
2463
- };
2464
- RestVirtualDataSourcePage.prototype.getSummaryInformation = function () {
2465
- return this._summaryInformation;
2466
- };
2467
- return RestVirtualDataSourcePage;
2468
- }());
2469
-
2470
- var RestVirtualDataSourceDataProviderWorker = /** @class */ /*@__PURE__*/ (function (_super) {
2471
- __extends(RestVirtualDataSourceDataProviderWorker, _super);
2472
- function RestVirtualDataSourceDataProviderWorker(settings) {
2473
- var e_1, _a;
2474
- var _this = _super.call(this, settings) || this;
2475
- _this._baseUri = null;
2476
- _this._entitySet = null;
2477
- _this._sortDescriptions = null;
2478
- _this._groupDescriptions = null;
2479
- _this._filterExpressions = null;
2480
- _this._summaryDescriptions = null;
2481
- _this._desiredPropeties = null;
2482
- _this._schemaIncludedProperties = null;
2483
- _this._enableJsonp = true;
2484
- _this._isAggregationSupported = false;
2485
- _this._provideFullCount = null;
2486
- _this._provideOrderByParameter = null;
2487
- _this._provideFilterParameter = null;
2488
- _this._provideAggregationParameter = null;
2489
- _this._provideAggregatedCount = null;
2490
- _this._providePagingParameter = null;
2491
- _this._provideDesiredPropertiesParameter = null;
2492
- _this._provideUri = null;
2493
- _this._performFetch = null;
2494
- _this._fixedFullCount = -1;
2495
- _this._groupInformation = null;
2496
- _this._summaryInformation = null;
2497
- _this._filterString = null;
2498
- _this._selectedString = null;
2499
- _this.doWork = _this.doWork.bind(_this);
2500
- _this._baseUri = settings.baseUri;
2501
- _this._entitySet = settings.entitySet;
2502
- _this._sortDescriptions = settings.sortDescriptions;
2503
- _this._groupDescriptions = settings.groupDescriptions;
2504
- if (_this._groupDescriptions != null && _this._groupDescriptions.size() > 0) {
2505
- _this._sortDescriptions = new SortDescriptionCollection();
2506
- try {
2507
- for (var _b = __values(_this.iter(settings.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
2508
- var sd = _c.value;
2509
- _this._sortDescriptions.add(sd);
2510
- }
2511
- }
2512
- catch (e_1_1) {
2513
- e_1 = { error: e_1_1 };
2514
- }
2515
- finally {
2516
- try {
2517
- if (_c && !_c.done && (_a = _b.return))
2518
- _a.call(_b);
2519
- }
2520
- finally {
2521
- if (e_1)
2522
- throw e_1.error;
2523
- }
2524
- }
2525
- for (var i = 0; i < _this._groupDescriptions.size(); i++) {
2526
- _this._sortDescriptions.insert(i, _this._groupDescriptions.get(i));
2527
- }
2528
- }
2529
- _this._filterExpressions = settings.filterExpressions;
2530
- _this._desiredPropeties = settings.propertiesRequested;
2531
- if (settings.schemaIncludedProperties != null) {
2532
- _this._schemaIncludedProperties = new Set();
2533
- for (var i = 0; i < settings.schemaIncludedProperties.length; i++) {
2534
- _this._schemaIncludedProperties.add(settings.schemaIncludedProperties[i]);
2535
- }
2536
- }
2537
- _this._summaryDescriptions = settings.summaryDescriptions;
2538
- _this._fixedFullCount = settings.fixedFullCount;
2539
- _this._summaryScope = settings.summaryScope;
2540
- _this._enableJsonp = settings.enableJsonp;
2541
- _this._provideFullCount = settings.provideFullCount;
2542
- _this._performFetch = settings.performFetch;
2543
- _this._provideAggregationParameter = settings.provideAggregationParameter;
2544
- _this._provideFilterParameter = settings.provideFilterParameter;
2545
- _this._provideOrderByParameter = settings.provideOrderByParameter;
2546
- _this._provideUri = settings.provideUri;
2547
- _this._providePagingParameter = settings.providePagingParameter;
2548
- _this._provideDesiredPropertiesParameter = settings.provideDesiredPropertiesParameter;
2549
- _this._provideItems = settings.provideItems;
2550
- _this._provideAggregatedCount = settings.provideAggregatedCount;
2551
- if (!_this._provideItems) {
2552
- _this._provideItems = function (res) {
2553
- return res ? res.items : null;
2554
- };
2555
- }
2556
- if (!_this._provideFullCount) {
2557
- _this._provideFullCount = function (p) {
2558
- if (p.fullCount) {
2559
- return p.fullCount;
2560
- }
2561
- else {
2562
- return _this._fixedFullCount >= 0 ? _this._fixedFullCount : 0;
2563
- }
2564
- };
2565
- }
2566
- if (!_this._provideOrderByParameter) {
2567
- _this._provideOrderByParameter = function (args, orderByString, orderBy) {
2568
- args.push({ name: "orderBy", value: encodeURIComponent(orderByString) });
2569
- };
2570
- }
2571
- if (!_this._providePagingParameter) {
2572
- _this._providePagingParameter = function (args, skip, take) {
2573
- args.push({ name: "skip", value: skip });
2574
- args.push({ name: "take", value: take });
2575
- };
2576
- }
2577
- if (!_this._provideAggregationParameter) {
2578
- _this._provideAggregationParameter = function (args, fetchCountOnly, groupByString, groupBy, summaryString, summary) {
2579
- args.push({ name: "groupBy", value: groupByString });
2580
- args.push({ name: "aggregate", value: "count" });
2581
- };
2582
- }
2583
- if (!_this._provideUri) {
2584
- _this._provideUri = function (baseUri, entitySet, args) {
2585
- var requestUri = baseUri;
2586
- requestUri += "/" + entitySet;
2587
- if (args.length > 0) {
2588
- requestUri += "?";
2589
- }
2590
- var argsString = "";
2591
- for (var i = 0; i < args.length; i++) {
2592
- if (i > 0) {
2593
- argsString += "&";
2594
- }
2595
- argsString += args[i].name + "=" + args[i].value;
2596
- }
2597
- return requestUri + argsString;
2598
- };
2599
- }
2600
- _this._isAggregationSupported = settings.isAggregationSupported;
2601
- window.setTimeout(_this.doWork, 100);
2602
- return _this;
2603
- }
2604
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "sortDescriptions", {
2605
- get: function () {
2606
- return this._sortDescriptions;
2607
- },
2608
- enumerable: false,
2609
- configurable: true
2610
- });
2611
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "filterExpressions", {
2612
- get: function () {
2613
- return this._filterExpressions;
2614
- },
2615
- enumerable: false,
2616
- configurable: true
2617
- });
2618
- Object.defineProperty(RestVirtualDataSourceDataProviderWorker.prototype, "desiredProperties", {
2619
- get: function () {
2620
- return this._desiredPropeties;
2621
- },
2622
- enumerable: false,
2623
- configurable: true
2624
- });
2625
- RestVirtualDataSourceDataProviderWorker.prototype.initialize = function () {
2626
- _super.prototype.initialize.call(this);
2627
- };
2628
- RestVirtualDataSourceDataProviderWorker.prototype.getTaskDataHolder = function () {
2629
- var holder = new RestVirtualDataSourceProviderTaskDataHolder();
2630
- return holder;
2631
- };
2632
- RestVirtualDataSourceDataProviderWorker.prototype.getCompletedTaskData = function (holder, completed) {
2633
- _super.prototype.getCompletedTaskData.call(this, holder, completed);
2634
- };
2635
- RestVirtualDataSourceDataProviderWorker.prototype.removeCompletedTaskData = function (holder, completed) {
2636
- _super.prototype.removeCompletedTaskData.call(this, holder, completed);
2637
- };
2638
- RestVirtualDataSourceDataProviderWorker.prototype.getTasksData = function (holder) {
2639
- _super.prototype.getTasksData.call(this, holder);
2640
- };
2641
- RestVirtualDataSourceDataProviderWorker.prototype.iter = function (coll) {
2642
- var i;
2643
- return __generator(this, function (_a) {
2644
- switch (_a.label) {
2645
- case 0:
2646
- i = 0;
2647
- _a.label = 1;
2648
- case 1:
2649
- if (!(i < coll.size()))
2650
- return [3 /*break*/, 4];
2651
- return [4 /*yield*/, coll.get(i)];
2652
- case 2:
2653
- _a.sent();
2654
- _a.label = 3;
2655
- case 3:
2656
- i++;
2657
- return [3 /*break*/, 1];
2658
- case 4: return [2 /*return*/];
2659
- }
2660
- });
2661
- };
2662
- RestVirtualDataSourceDataProviderWorker.prototype.iterFilter = function (coll) {
2663
- var i;
2664
- return __generator(this, function (_a) {
2665
- switch (_a.label) {
2666
- case 0:
2667
- i = 0;
2668
- _a.label = 1;
2669
- case 1:
2670
- if (!(i < coll.size()))
2671
- return [3 /*break*/, 4];
2672
- return [4 /*yield*/, coll.get(i)];
2673
- case 2:
2674
- _a.sent();
2675
- _a.label = 3;
2676
- case 3:
2677
- i++;
2678
- return [3 /*break*/, 1];
2679
- case 4: return [2 /*return*/];
2680
- }
2681
- });
2682
- };
2683
- RestVirtualDataSourceDataProviderWorker.prototype.iterSummaries = function (summaries) {
2684
- var i;
2685
- return __generator(this, function (_a) {
2686
- switch (_a.label) {
2687
- case 0:
2688
- i = 0;
2689
- _a.label = 1;
2690
- case 1:
2691
- if (!(i < summaries.size()))
2692
- return [3 /*break*/, 4];
2693
- return [4 /*yield*/, summaries.get(i)];
2694
- case 2:
2695
- _a.sent();
2696
- _a.label = 3;
2697
- case 3:
2698
- i++;
2699
- return [3 /*break*/, 1];
2700
- case 4: return [2 /*return*/];
2701
- }
2702
- });
2703
- };
2704
- RestVirtualDataSourceDataProviderWorker.prototype.processCompletedTask = function (completedTask, currentDelay, pageIndex, taskDataHolder) {
2705
- var _this = this;
2706
- var h = taskDataHolder;
2707
- var schema = null;
2708
- var result = null;
2709
- var schemaFetchCount = -1;
2710
- var task = completedTask.task;
2711
- try {
2712
- if (task.hasErrors) {
2713
- this.retryIndex(pageIndex, currentDelay);
2714
- return;
2715
- }
2716
- if (pageIndex == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
2717
- result = task.result;
2718
- schemaFetchCount = (this._provideFullCount(result));
2719
- }
2720
- else {
2721
- result = task.result;
2722
- }
2723
- }
2724
- catch (e) {
2725
- this.retryIndex(pageIndex, currentDelay);
2726
- return;
2727
- }
2728
- if (schemaFetchCount >= 0) {
2729
- this.actualCount = schemaFetchCount;
2730
- }
2731
- else {
2732
- this.actualCount = (this._provideFullCount(result));
2733
- }
2734
- schema = this.actualSchema;
2735
- if (schema == null) {
2736
- var requests_1 = 0;
2737
- this.resolveSchema(function (s) {
2738
- // resolveSchema success callback
2739
- _this.actualSchema = s;
2740
- if (_this._isAggregationSupported && (_this._groupDescriptions.size() !== 0 || _this._summaryDescriptions.size() !== 0)) {
2741
- if (_this._groupDescriptions.size() > 0) {
2742
- requests_1++;
2743
- _this.resolveGroupInformation(function (g) {
2744
- // group info success
2745
- requests_1--;
2746
- if (requests_1 === 0) {
2747
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
2748
- }
2749
- }, function () {
2750
- // group info failure
2751
- _this.retryIndex(pageIndex, currentDelay);
2752
- return;
2753
- });
2754
- }
2755
- if (_this._summaryDescriptions.size() > 0) {
2756
- requests_1++;
2757
- _this.resolveSummaryInformation(function (g) {
2758
- // summary info success
2759
- requests_1--;
2760
- if (requests_1 === 0) {
2761
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
2762
- }
2763
- }, function () {
2764
- // summary info failure
2765
- _this.retryIndex(pageIndex, currentDelay);
2766
- return;
2767
- });
2768
- }
2769
- }
2770
- else {
2771
- _this.finishProcessingCompletedTask(task, pageIndex, s, result);
2772
- }
2773
- }, function () {
2774
- // resolveSchema failure callback
2775
- _this.retryIndex(pageIndex, currentDelay);
2776
- return;
2777
- });
2778
- return;
2779
- }
2780
- this.finishProcessingCompletedTask(task, pageIndex, schema, result);
2781
- };
2782
- RestVirtualDataSourceDataProviderWorker.prototype.finishProcessingCompletedTask = function (task, pageIndex, schema, result) {
2783
- var _this = this;
2784
- var executionContext;
2785
- var pageLoaded;
2786
- var groupInformation;
2787
- var summaryInformation;
2788
- this.actualSchema = schema;
2789
- executionContext = this.executionContext;
2790
- groupInformation = this._groupInformation;
2791
- summaryInformation = this._summaryInformation;
2792
- pageLoaded = this.pageLoaded;
2793
- var page = null;
2794
- if (result != null) {
2795
- page = new RestVirtualDataSourcePage(result, schema, groupInformation, summaryInformation, pageIndex);
2796
- if (!this.isLastPage(pageIndex) && page.count() > 0 && !this.populatedActualPageSize) {
2797
- this.populatedActualPageSize = true;
2798
- this.actualPageSize = page.count();
2799
- }
2800
- }
2801
- else {
2802
- page = new RestVirtualDataSourcePage(null, schema, groupInformation, summaryInformation, pageIndex);
2803
- }
2804
- if (this.pageLoaded != null) {
2805
- if (this.executionContext != null) {
2806
- if (executionContext == null || pageLoaded == null) {
2807
- this.shutdown();
2808
- return;
2809
- }
2810
- executionContext.execute(function () { return pageLoaded(page, _this.actualCount, _this.actualPageSize); });
2811
- }
2812
- else {
2813
- if (pageLoaded == null) {
2814
- this.shutdown();
2815
- return;
2816
- }
2817
- pageLoaded(page, this.actualCount, this.actualPageSize);
2818
- }
2819
- }
2820
- };
2821
- RestVirtualDataSourceDataProviderWorker.prototype.resolveGroupInformation = function (finishAction, failureAction) {
2822
- var e_2, _a;
2823
- var _this = this;
2824
- if (this._groupInformation != null) {
2825
- finishAction(this._groupInformation);
2826
- return;
2827
- }
2828
- var orderBy = "";
2829
- var groupBy = "";
2830
- var filter = null;
2831
- var summary = "";
2832
- if (this._groupDescriptions == null || this._groupDescriptions.size() == 0) {
2833
- finishAction(null);
2834
- return;
2835
- }
2836
- if (this._provideAggregationParameter == null) {
2837
- finishAction(null);
2838
- return;
2839
- }
2840
- filter = this._filterString;
2841
- this.updateFilterString();
2842
- if (this._groupDescriptions != null) {
2843
- var first1 = true;
2844
- try {
2845
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
2846
- var group = _c.value;
2847
- if (first1) {
2848
- first1 = false;
2849
- }
2850
- else {
2851
- orderBy += ", ";
2852
- groupBy += ", ";
2853
- }
2854
- groupBy += group.propertyName;
2855
- if (group.direction === ListSortDirection.Descending) {
2856
- orderBy += group.propertyName + " desc";
2857
- }
2858
- else {
2859
- orderBy += group.propertyName + " asc";
2860
- }
2861
- }
2862
- }
2863
- catch (e_2_1) {
2864
- e_2 = { error: e_2_1 };
2865
- }
2866
- finally {
2867
- try {
2868
- if (_c && !_c.done && (_a = _b.return))
2869
- _a.call(_b);
2870
- }
2871
- finally {
2872
- if (e_2)
2873
- throw e_2.error;
2874
- }
2875
- }
2876
- }
2877
- if (this._summaryScope === DataSourceSummaryScope.Both || this._summaryScope === DataSourceSummaryScope.Groups) {
2878
- var summaryParameters = this.getSummaryQueryParameters(true);
2879
- if (!stringIsNullOrEmpty(summaryParameters)) {
2880
- summary = ", " + summaryParameters;
2881
- }
2882
- }
2883
- var args = [];
2884
- if (this._provideOrderByParameter) {
2885
- this._provideOrderByParameter(args, orderBy, this._groupDescriptions);
2886
- }
2887
- if (this._provideFilterParameter && filter != null) {
2888
- this._provideFilterParameter(args, filter, this._filterExpressions);
2889
- }
2890
- if (this._provideAggregationParameter) {
2891
- this._provideAggregationParameter(args, true, groupBy, this._groupDescriptions, summary, this._summaryDescriptions);
2892
- }
2893
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
2894
- try {
2895
- var groupInformation_1 = [];
2896
- var success_1 = function (data, response) { return _this.groupSuccess(data, response, finishAction, failureAction, groupInformation_1); };
2897
- var failure_1 = function (err) { return _this.groupError(err, finishAction, failureAction, groupInformation_1); };
2898
- var run_ = null;
2899
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
2900
- var request = {
2901
- requestUri: uri,
2902
- enableJsonpCallback: this._enableJsonp,
2903
- method: 'GET',
2904
- headers: headers,
2905
- data: null
2906
- };
2907
- run_ = function () {
2908
- _this.fetchUri(request, success_1, failure_1);
2909
- };
2910
- run_();
2911
- }
2912
- catch (e) {
2913
- failureAction();
2914
- }
2915
- };
2916
- RestVirtualDataSourceDataProviderWorker.prototype.fetchUri = function (request, success, failure) {
2917
- if (this._performFetch) {
2918
- this._performFetch(request, success, failure);
2919
- }
2920
- else {
2921
- fetch(request.requestUri, {
2922
- method: request.method,
2923
- headers: request.headers,
2924
- }).then(function (res) {
2925
- res.json().then(function (j) {
2926
- success(j, res);
2927
- });
2928
- }).catch(function (e) {
2929
- failure(e);
2930
- });
2931
- }
2932
- };
2933
- RestVirtualDataSourceDataProviderWorker.prototype.groupError = function (err, finishAction, failureAction, groupInformation) {
2934
- this._groupInformation = null;
2935
- };
2936
- RestVirtualDataSourceDataProviderWorker.prototype.groupSuccess = function (data, response, finishAction, failureAction, groupInformation) {
2937
- var e_3, _a;
2938
- var groupNames = [];
2939
- try {
2940
- for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
2941
- var group = _c.value;
2942
- groupNames.push(group.propertyName);
2943
- }
2944
- }
2945
- catch (e_3_1) {
2946
- e_3 = { error: e_3_1 };
2947
- }
2948
- finally {
2949
- try {
2950
- if (_c && !_c.done && (_a = _b.return))
2951
- _a.call(_b);
2952
- }
2953
- finally {
2954
- if (e_3)
2955
- throw e_3.error;
2956
- }
2957
- }
2958
- var groupNamesArray = groupNames;
2959
- var items = this._provideItems(data);
2960
- if (items && items.length > 0) {
2961
- var currentIndex = 0;
2962
- for (var i = 0; i < items.length; i++) {
2963
- this.addGroup(groupInformation, groupNames, groupNames, currentIndex, items[i]);
2964
- }
2965
- }
2966
- this._groupInformation = groupInformation;
2967
- finishAction(this._groupInformation);
2968
- };
2969
- RestVirtualDataSourceDataProviderWorker.prototype.addGroup = function (groupInformation, groupNames, groupNamesArray, currentIndex, group) {
2970
- var e_4, _a;
2971
- var groupValues = [];
2972
- try {
2973
- for (var groupNames_1 = __values(groupNames), groupNames_1_1 = groupNames_1.next(); !groupNames_1_1.done; groupNames_1_1 = groupNames_1.next()) {
2974
- var name_1 = groupNames_1_1.value;
2975
- if (group[name_1]) {
2976
- groupValues.push(group[name_1]);
2977
- }
2978
- }
2979
- }
2980
- catch (e_4_1) {
2981
- e_4 = { error: e_4_1 };
2982
- }
2983
- finally {
2984
- try {
2985
- if (groupNames_1_1 && !groupNames_1_1.done && (_a = groupNames_1.return))
2986
- _a.call(groupNames_1);
2987
- }
2988
- finally {
2989
- if (e_4)
2990
- throw e_4.error;
2991
- }
2992
- }
2993
- var groupCount = 0;
2994
- //todo: make this customizable
2995
- if (this._provideAggregatedCount) {
2996
- var ct = this._provideAggregatedCount(group);
2997
- }
2998
- else {
2999
- if (group["aggregatedCount"]) {
3000
- groupCount = Convert.toInt321(group["aggregatedCount"]);
3001
- }
3002
- }
3003
- var summaryResults = null;
3004
- if (this._summaryScope == DataSourceSummaryScope.Both || this._summaryScope == DataSourceSummaryScope.Groups) {
3005
- summaryResults = this.createSummaryResults(group);
3006
- }
3007
- var groupInfo = new DefaultSectionInformation(currentIndex, currentIndex + (groupCount - 1), groupNamesArray, groupValues, summaryResults);
3008
- groupInformation.push(groupInfo);
3009
- };
3010
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSummaryInformation = function (finishAction, failureAction) {
3011
- var _this = this;
3012
- if (this._summaryInformation != null) {
3013
- finishAction(this._summaryInformation);
3014
- return;
3015
- }
3016
- var filter = null;
3017
- var summary = null;
3018
- if (this._summaryDescriptions == null ||
3019
- this._summaryDescriptions.size() == 0 ||
3020
- this._summaryScope == DataSourceSummaryScope.Groups ||
3021
- this._summaryScope == DataSourceSummaryScope.None) {
3022
- finishAction(null);
3023
- return;
3024
- }
3025
- filter = this._filterString;
3026
- this.updateFilterString();
3027
- summary = this.getSummaryQueryParameters(false);
3028
- var args = [];
3029
- // if (this._provideOrderByParameter) {
3030
- // args.push({ name: "orderBy", value: this._provideOrderByParameter(orderBy, this._sortDescriptions) });
3031
- // }
3032
- if (this._provideFilterParameter && filter != null) {
3033
- this._provideFilterParameter(args, filter, this._filterExpressions);
3034
- }
3035
- if (this._provideAggregationParameter) {
3036
- this._provideAggregationParameter(args, true, null, null, summary, this._summaryDescriptions);
3037
- }
3038
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
3039
- // let commandText = this._entitySet + "?$apply=";
3040
- // if (!stringIsNullOrEmpty(filter)) {
3041
- // commandText += "filter(" + filter + ")/";
3042
- // }
3043
- // commandText += "aggregate(" + summary + ")";
3044
- try {
3045
- var summaryInformation_1 = [];
3046
- var success_2 = function (data, response) { return _this.summarySuccess(data, response, finishAction, failureAction, summaryInformation_1); };
3047
- var failure_2 = function (err) { return _this.summaryError(err, finishAction, failureAction, summaryInformation_1); };
3048
- var run_ = null;
3049
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
3050
- var request = {
3051
- requestUri: uri,
3052
- enableJsonpCallback: this._enableJsonp,
3053
- method: 'GET',
3054
- headers: headers,
3055
- data: null
3056
- };
3057
- run_ = function () {
3058
- _this.fetchUri(request, success_2, failure_2);
3059
- };
3060
- run_();
3061
- }
3062
- catch (e) {
3063
- failureAction();
3064
- }
3065
- };
3066
- RestVirtualDataSourceDataProviderWorker.prototype.summarySuccess = function (data, response, finishAction, failureAction, summaryInformation) {
3067
- if (data && data.value && data.value.length > 0) {
3068
- summaryInformation = this.createSummaryResults(data.value[0]);
3069
- }
3070
- this._summaryInformation = summaryInformation;
3071
- finishAction(this._summaryInformation);
3072
- };
3073
- RestVirtualDataSourceDataProviderWorker.prototype.summaryError = function (err, finishAction, failureAction, summaryInformation) {
3074
- this._summaryInformation = null;
3075
- };
3076
- RestVirtualDataSourceDataProviderWorker.prototype.getSummaryQueryParameters = function (ignoreCount) {
3077
- var e_5, _a;
3078
- var result = "";
3079
- if (this._summaryDescriptions != null) {
3080
- var first = true;
3081
- var countExists = false;
3082
- try {
3083
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
3084
- var summary = _c.value;
3085
- if (summary.operand == DataSourceSummaryOperand.Count && (ignoreCount || countExists)) {
3086
- continue;
3087
- }
3088
- if (!first) {
3089
- result += ", ";
3090
- }
3091
- switch (summary.operand) {
3092
- case DataSourceSummaryOperand.Average:
3093
- result += summary.propertyName + " with average as " + summary.propertyName + "Average";
3094
- break;
3095
- case DataSourceSummaryOperand.Min:
3096
- result += summary.propertyName + " with min as " + summary.propertyName + "Min";
3097
- break;
3098
- case DataSourceSummaryOperand.Max:
3099
- result += summary.propertyName + " with max as " + summary.propertyName + "Max";
3100
- break;
3101
- case DataSourceSummaryOperand.Sum:
3102
- result += summary.propertyName + " with sum as " + summary.propertyName + "Sum";
3103
- break;
3104
- case DataSourceSummaryOperand.Count:
3105
- result += "$count as $__count";
3106
- countExists = true;
3107
- break;
3108
- }
3109
- first = false;
3110
- }
3111
- }
3112
- catch (e_5_1) {
3113
- e_5 = { error: e_5_1 };
3114
- }
3115
- finally {
3116
- try {
3117
- if (_c && !_c.done && (_a = _b.return))
3118
- _a.call(_b);
3119
- }
3120
- finally {
3121
- if (e_5)
3122
- throw e_5.error;
3123
- }
3124
- }
3125
- }
3126
- return result;
3127
- };
3128
- RestVirtualDataSourceDataProviderWorker.prototype.createSummaryResults = function (data) {
3129
- var e_6, _a;
3130
- var summaryResults = [];
3131
- try {
3132
- for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
3133
- var summary = _c.value;
3134
- var summaryName = summary.propertyName;
3135
- switch (summary.operand) {
3136
- case DataSourceSummaryOperand.Average:
3137
- summaryName += "Average";
3138
- break;
3139
- case DataSourceSummaryOperand.Min:
3140
- summaryName += "Min";
3141
- break;
3142
- case DataSourceSummaryOperand.Max:
3143
- summaryName += "Max";
3144
- break;
3145
- case DataSourceSummaryOperand.Sum:
3146
- summaryName += "Sum";
3147
- break;
3148
- case DataSourceSummaryOperand.Count:
3149
- summaryName = "$__count";
3150
- break;
3151
- }
3152
- var summaryValue = null;
3153
- if (data && data[summaryName]) {
3154
- summaryValue = data[summaryName];
3155
- }
3156
- var summaryResult = new DefaultSummaryResult(summary.propertyName, summary.operand, summaryValue);
3157
- summaryResults.push(summaryResult);
3158
- }
3159
- }
3160
- catch (e_6_1) {
3161
- e_6 = { error: e_6_1 };
3162
- }
3163
- finally {
3164
- try {
3165
- if (_c && !_c.done && (_a = _b.return))
3166
- _a.call(_b);
3167
- }
3168
- finally {
3169
- if (e_6)
3170
- throw e_6.error;
3171
- }
3172
- }
3173
- return summaryResults;
3174
- };
3175
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSchemaFromItems = function (items) {
3176
- var lds = new LocalDataSource();
3177
- lds.dataSource = items;
3178
- lds.flushAutoRefresh();
3179
- return lds.actualSchema;
3180
- };
3181
- RestVirtualDataSourceDataProviderWorker.prototype.resolveSchema = function (finishAction, failureAction) {
3182
- var _this = this;
3183
- if (!this._provideItems || !this._providePagingParameter) {
3184
- failureAction("required providers for items and paging are not specified");
3185
- return;
3186
- }
3187
- var success_ = function (res) {
3188
- var items = _this._provideItems(res);
3189
- if (items && items.length > 0) {
3190
- var schema = _this.resolveSchemaFromItems(items);
3191
- if (_this._schemaIncludedProperties != null) {
3192
- var propertyNames = [];
3193
- var propertyTypes = [];
3194
- for (var i = 0; i < schema.propertyNames.length; i++) {
3195
- if (!_this._schemaIncludedProperties.has(schema.propertyNames[i])) {
3196
- continue;
3197
- }
3198
- propertyNames.push(schema.propertyNames[i]);
3199
- propertyTypes.push(schema.propertyTypes[i]);
3200
- }
3201
- schema = new DefaultDataSourceSchema(propertyNames, propertyTypes, schema.primaryKey, schema.propertyDataIntents, schema.subSchemas);
3202
- }
3203
- finishAction(schema);
3204
- }
3205
- else {
3206
- failureAction("could not find items to resolve schema");
3207
- }
3208
- };
3209
- var failure_ = function (e) { return failureAction(e); };
3210
- var args = [];
3211
- if (this._providePagingParameter) {
3212
- this._providePagingParameter(args, 0, this.actualPageSize);
3213
- }
3214
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
3215
- try {
3216
- var run_ = null;
3217
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
3218
- var request = {
3219
- requestUri: uri,
3220
- enableJsonpCallback: this._enableJsonp,
3221
- method: 'GET',
3222
- headers: headers,
3223
- data: null
3224
- };
3225
- run_ = function () {
3226
- _this.fetchUri(request, success_, failure_);
3227
- };
3228
- run_();
3229
- }
3230
- catch (e) {
3231
- failureAction(e);
3232
- }
3233
- };
3234
- RestVirtualDataSourceDataProviderWorker.prototype.makeTaskForRequest = function (request, retryDelay) {
3235
- var e_7, _a;
3236
- var args = [];
3237
- // if (this._provideAggregationParameter) {
3238
- // args.push({ name: "apply", value: this._provideAggregationParameter(true, groupBy, this._groupDescriptions, summary, this._summaryDescriptions) });
3239
- // }
3240
- var actualPageSize = 0;
3241
- var sortDescriptions = null;
3242
- actualPageSize = this.actualPageSize;
3243
- sortDescriptions = this.sortDescriptions;
3244
- //let requestUrl: string = this._baseUri;
3245
- //requestUrl += "/" + this._entitySet;
3246
- var queryStarted = false;
3247
- this.updateFilterString();
3248
- if (this._filterString != null) {
3249
- if (this._provideFilterParameter) {
3250
- this._provideFilterParameter(args, this._filterString, this._filterExpressions);
3251
- }
3252
- }
3253
- if (this.sortDescriptions != null) {
3254
- var sortString = null;
3255
- try {
3256
- for (var _b = __values(this.iter(this.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
3257
- var sort = _c.value;
3258
- if (sortString == null) {
3259
- sortString = "";
3260
- }
3261
- else {
3262
- sortString += ", ";
3263
- }
3264
- if (sort.direction == ListSortDirection.Descending) {
3265
- sortString += sort.propertyName + " desc";
3266
- }
3267
- else {
3268
- sortString += sort.propertyName;
3269
- }
3270
- }
3271
- }
3272
- catch (e_7_1) {
3273
- e_7 = { error: e_7_1 };
3274
- }
3275
- finally {
3276
- try {
3277
- if (_c && !_c.done && (_a = _b.return))
3278
- _a.call(_b);
3279
- }
3280
- finally {
3281
- if (e_7)
3282
- throw e_7.error;
3283
- }
3284
- }
3285
- if (sortString != null) {
3286
- if (this._provideOrderByParameter) {
3287
- this._provideOrderByParameter(args, sortString, this._sortDescriptions);
3288
- }
3289
- }
3290
- }
3291
- if (this.desiredProperties != null && this.desiredProperties.length > 0) {
3292
- var selectString = "";
3293
- var first = true;
3294
- var $t = this.desiredProperties;
3295
- for (var i = 0; i < $t.length; i++) {
3296
- var select = $t[i];
3297
- if (first) {
3298
- first = false;
3299
- }
3300
- else {
3301
- selectString += ", ";
3302
- }
3303
- selectString += select;
3304
- }
3305
- if (this._provideDesiredPropertiesParameter) {
3306
- this._provideDesiredPropertiesParameter(args, selectString, this._desiredPropeties);
3307
- }
3308
- }
3309
- if (this._providePagingParameter) {
3310
- if (request.index == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
3311
- this._providePagingParameter(args, 0, actualPageSize);
3312
- }
3313
- else {
3314
- this._providePagingParameter(args, request.index * actualPageSize, actualPageSize);
3315
- }
3316
- }
3317
- var task = new AsyncVirtualDataTask();
3318
- var uri = this._provideUri(this._baseUri, this._entitySet, args);
3319
- if (request.index == RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
3320
- this.executeRequest(uri, queryStarted, 0, actualPageSize, task);
3321
- }
3322
- else {
3323
- this.executeRequest(uri, queryStarted, request.index * actualPageSize, actualPageSize, task);
3324
- }
3325
- request.taskHolder = new AsyncDataSourcePageTaskHolder();
3326
- request.taskHolder.task = task;
3327
- this.tasks.add(request);
3328
- };
3329
- RestVirtualDataSourceDataProviderWorker.prototype.updateFilterString = function () {
3330
- var e_8, _a;
3331
- if (this.filterExpressions != null && this.filterExpressions.size() > 0 && this._filterString == null) {
3332
- var sb = "";
3333
- var first = true;
3334
- try {
3335
- for (var _b = __values(this.iterFilter(this.filterExpressions)), _c = _b.next(); !_c.done; _c = _b.next()) {
3336
- var expr = _c.value;
3337
- if (first) {
3338
- first = false;
3339
- }
3340
- else {
3341
- sb += " AND ";
3342
- }
3343
- var visitor = new ODataDataSourceFilterExpressionVisitor(0);
3344
- visitor.visit(expr);
3345
- var txt = visitor.toString();
3346
- if (this.filterExpressions.size() > 1) {
3347
- txt = "(" + txt + ")";
3348
- }
3349
- sb += (txt);
3350
- }
3351
- }
3352
- catch (e_8_1) {
3353
- e_8 = { error: e_8_1 };
3354
- }
3355
- finally {
3356
- try {
3357
- if (_c && !_c.done && (_a = _b.return))
3358
- _a.call(_b);
3359
- }
3360
- finally {
3361
- if (e_8)
3362
- throw e_8.error;
3363
- }
3364
- }
3365
- this._filterString = sb;
3366
- }
3367
- };
3368
- RestVirtualDataSourceDataProviderWorker.prototype.executeRequest = function (requestUrl, queryStarted, skip, top, task) {
3369
- var _this = this;
3370
- // if (!queryStarted) {
3371
- // queryStarted = true;
3372
- // requestUrl += "?";
3373
- // } else {
3374
- // requestUrl += "&";
3375
- // }
3376
- // requestUrl += "$skip=" + skip + "&$top=" + top + "&$count=true";
3377
- var requestUrl_ = requestUrl;
3378
- var self_ = this;
3379
- var success_ = function (data, response) { return _this.success(task, data, response); };
3380
- var failure_ = function (err) { return _this.error(task, err); };
3381
- var run_ = null;
3382
- var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
3383
- var request = {
3384
- requestUri: requestUrl_,
3385
- enableJsonpCallback: this._enableJsonp,
3386
- method: 'GET',
3387
- headers: headers,
3388
- data: null
3389
- };
3390
- run_ = function () {
3391
- _this.fetchUri(request, success_, failure_);
3392
- };
3393
- task.run = run_;
3394
- };
3395
- RestVirtualDataSourceDataProviderWorker.prototype.success = function (t, data, response) {
3396
- t.result = data;
3397
- t.isCompleted = true;
3398
- };
3399
- RestVirtualDataSourceDataProviderWorker.prototype.error = function (t, result) {
3400
- t.isCompleted = true;
3401
- t.hasErrors = true;
3402
- };
3403
- RestVirtualDataSourceDataProviderWorker.prototype.createBatchRequest = function (changes) {
3404
- //TODO: updates
3405
- };
3406
- RestVirtualDataSourceDataProviderWorker.prototype.getRequestUriWithKey = function (key) {
3407
- var result = "";
3408
- var keys = Object.keys(key);
3409
- for (var i = 0; i < keys.length; i++) {
3410
- if (i > 0) {
3411
- result += ",";
3412
- }
3413
- result += "".concat(keys[i], "=").concat(key[keys[i]]);
3414
- }
3415
- return "".concat(this._entitySet, "(").concat(result, ")");
3416
- };
3417
- RestVirtualDataSourceDataProviderWorker.schemaRequestIndex = -1;
3418
- return RestVirtualDataSourceDataProviderWorker;
3419
- }(AsyncVirtualDataSourceProviderWorker));
3420
-
3421
- var RestVirtualDataSourceDataProviderWorkerSettings = /** @class */ /*@__PURE__*/ (function (_super) {
3422
- __extends(RestVirtualDataSourceDataProviderWorkerSettings, _super);
3423
- function RestVirtualDataSourceDataProviderWorkerSettings() {
3424
- var _this = _super !== null && _super.apply(this, arguments) || this;
3425
- _this._baseUri = null;
3426
- _this._entitySet = null;
3427
- _this._sortDescriptions = null;
3428
- _this._filterExpressions = null;
3429
- _this._propertiesRequested = null;
3430
- _this._schemaIncludedProperties = null;
3431
- _this._groupDescriptions = null;
3432
- _this._summaryDescriptions = null;
3433
- _this._fixedFullCount = -1;
3434
- _this._provideFullCount = null;
3435
- _this._provideOrderByParameter = null;
3436
- _this._provideFilterParameter = null;
3437
- _this._provideAggregationParameter = null;
3438
- _this._provideAggregatedCount = null;
3439
- _this._provideUri = null;
3440
- _this._providePagingParameter = null;
3441
- _this._provideDesiredPropertiesParameter = null;
3442
- _this._performFetch = null;
3443
- return _this;
3444
- }
3445
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "baseUri", {
3446
- get: function () {
3447
- return this._baseUri;
3448
- },
3449
- set: function (value) {
3450
- this._baseUri = value;
3451
- },
3452
- enumerable: false,
3453
- configurable: true
3454
- });
3455
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "entitySet", {
3456
- get: function () {
3457
- return this._entitySet;
3458
- },
3459
- set: function (value) {
3460
- this._entitySet = value;
3461
- },
3462
- enumerable: false,
3463
- configurable: true
3464
- });
3465
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "sortDescriptions", {
3466
- get: function () {
3467
- return this._sortDescriptions;
3468
- },
3469
- set: function (value) {
3470
- this._sortDescriptions = value;
3471
- },
3472
- enumerable: false,
3473
- configurable: true
3474
- });
3475
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "filterExpressions", {
3476
- get: function () {
3477
- return this._filterExpressions;
3478
- },
3479
- set: function (value) {
3480
- this._filterExpressions = value;
3481
- },
3482
- enumerable: false,
3483
- configurable: true
3484
- });
3485
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "propertiesRequested", {
3486
- get: function () {
3487
- return this._propertiesRequested;
3488
- },
3489
- set: function (value) {
3490
- this._propertiesRequested = value;
3491
- },
3492
- enumerable: false,
3493
- configurable: true
3494
- });
3495
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "schemaIncludedProperties", {
3496
- get: function () {
3497
- return this._schemaIncludedProperties;
3498
- },
3499
- set: function (value) {
3500
- this._schemaIncludedProperties = value;
3501
- },
3502
- enumerable: false,
3503
- configurable: true
3504
- });
3505
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "groupDescriptions", {
3506
- get: function () {
3507
- return this._groupDescriptions;
3508
- },
3509
- set: function (value) {
3510
- this._groupDescriptions = value;
3511
- },
3512
- enumerable: false,
3513
- configurable: true
3514
- });
3515
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "summaryDescriptions", {
3516
- get: function () {
3517
- return this._summaryDescriptions;
3518
- },
3519
- set: function (value) {
3520
- this._summaryDescriptions = value;
3521
- },
3522
- enumerable: false,
3523
- configurable: true
3524
- });
3525
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "summaryScope", {
3526
- get: function () {
3527
- return this._summaryscope;
3528
- },
3529
- set: function (value) {
3530
- this._summaryscope = value;
3531
- },
3532
- enumerable: false,
3533
- configurable: true
3534
- });
3535
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "enableJsonp", {
3536
- get: function () {
3537
- return this._enableJsonp;
3538
- },
3539
- set: function (isEnabled) {
3540
- this._enableJsonp = isEnabled;
3541
- },
3542
- enumerable: false,
3543
- configurable: true
3544
- });
3545
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "isAggregationSupported", {
3546
- get: function () {
3547
- return this._isAggregationSupported;
3548
- },
3549
- set: function (isSupported) {
3550
- this._isAggregationSupported = isSupported;
3551
- },
3552
- enumerable: false,
3553
- configurable: true
3554
- });
3555
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "fixedFullCount", {
3556
- get: function () {
3557
- return this._fixedFullCount;
3558
- },
3559
- set: function (value) {
3560
- this._fixedFullCount = value;
3561
- },
3562
- enumerable: false,
3563
- configurable: true
3564
- });
3565
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideFullCount", {
3566
- get: function () {
3567
- return this._provideFullCount;
3568
- },
3569
- set: function (value) {
3570
- this._provideFullCount = value;
3571
- },
3572
- enumerable: false,
3573
- configurable: true
3574
- });
3575
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideOrderByParameter", {
3576
- get: function () {
3577
- return this._provideOrderByParameter;
3578
- },
3579
- set: function (value) {
3580
- this._provideOrderByParameter = value;
3581
- },
3582
- enumerable: false,
3583
- configurable: true
3584
- });
3585
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideFilterParameter", {
3586
- get: function () {
3587
- return this._provideFilterParameter;
3588
- },
3589
- set: function (value) {
3590
- this._provideFilterParameter = value;
3591
- },
3592
- enumerable: false,
3593
- configurable: true
3594
- });
3595
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideAggregationParameter", {
3596
- get: function () {
3597
- return this._provideAggregationParameter;
3598
- },
3599
- set: function (value) {
3600
- this._provideAggregationParameter = value;
3601
- },
3602
- enumerable: false,
3603
- configurable: true
3604
- });
3605
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideAggregatedCount", {
3606
- get: function () {
3607
- return this._provideAggregatedCount;
3608
- },
3609
- set: function (value) {
3610
- this._provideAggregatedCount = value;
3611
- },
3612
- enumerable: false,
3613
- configurable: true
3614
- });
3615
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideUri", {
3616
- get: function () {
3617
- return this._provideUri;
3618
- },
3619
- set: function (value) {
3620
- this._provideUri = value;
3621
- },
3622
- enumerable: false,
3623
- configurable: true
3624
- });
3625
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "providePagingParameter", {
3626
- get: function () {
3627
- return this._providePagingParameter;
3628
- },
3629
- set: function (value) {
3630
- this._providePagingParameter = value;
3631
- },
3632
- enumerable: false,
3633
- configurable: true
3634
- });
3635
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideDesiredPropertiesParameter", {
3636
- get: function () {
3637
- return this._provideDesiredPropertiesParameter;
3638
- },
3639
- set: function (value) {
3640
- this._provideDesiredPropertiesParameter = value;
3641
- },
3642
- enumerable: false,
3643
- configurable: true
3644
- });
3645
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "provideItems", {
3646
- get: function () {
3647
- return this._provideItems;
3648
- },
3649
- set: function (value) {
3650
- this._provideItems = value;
3651
- },
3652
- enumerable: false,
3653
- configurable: true
3654
- });
3655
- Object.defineProperty(RestVirtualDataSourceDataProviderWorkerSettings.prototype, "performFetch", {
3656
- get: function () {
3657
- return this._performFetch;
3658
- },
3659
- set: function (value) {
3660
- this._performFetch = value;
3661
- },
3662
- enumerable: false,
3663
- configurable: true
3664
- });
3665
- RestVirtualDataSourceDataProviderWorkerSettings.$t = markType(RestVirtualDataSourceDataProviderWorkerSettings, 'RestVirtualDataSourceDataProviderWorkerSettings', AsyncVirtualDataSourceDataProviderWorkerSettings.$type);
3666
- return RestVirtualDataSourceDataProviderWorkerSettings;
3667
- }(AsyncVirtualDataSourceDataProviderWorkerSettings));
3668
-
3669
- var RestVirtualDataSourceDataProvider = /** @class */ /*@__PURE__*/ (function (_super) {
3670
- __extends(RestVirtualDataSourceDataProvider, _super);
3671
- function RestVirtualDataSourceDataProvider() {
3672
- var _this = _super.call(this) || this;
3673
- _this._worker = null;
3674
- _this._requests = new LinkedList();
3675
- _this._callback = null;
3676
- _this._pageLoaded = null;
3677
- _this._pageSizeRequested = 50;
3678
- _this._baseUri = null;
3679
- _this._entitySet = null;
3680
- _this._timeoutMilliseconds = 10000;
3681
- _this.schemaChanged = null;
3682
- _this._currentFullCount = 0;
3683
- _this._currentSchema = null;
3684
- _this._executionContext = null;
3685
- _this._updateNotifier = null;
3686
- _this._deferAutoRefresh = false;
3687
- _this._sortDescriptions = null;
3688
- _this._groupDescriptions = null;
3689
- _this._propertiesRequested = null;
3690
- _this._schemaIncludedProperties = null;
3691
- _this._filterExpressions = null;
3692
- _this._summaryDescriptions = null;
3693
- _this._enableJsonp = true;
3694
- _this._fixedFullCount = -1;
3695
- _this._provideFullCount = null;
3696
- _this._provideOrderByParameter = null;
3697
- _this._provideFilterParameter = null;
3698
- _this._provideAggregationParameter = null;
3699
- _this._provideAggregatedCount = null;
3700
- _this._provideUri = null;
3701
- _this._performFetch = null;
3702
- _this._providePagingParameter = null;
3703
- _this._provideDesiredPropertiesParameter = null;
3704
- _this._schemaFetchQueued = false;
3705
- _this._autoRefreshQueued = false;
3706
- _this._sortDescriptions = new SortDescriptionCollection();
3707
- _this._sortDescriptions.onChanged = function () { return _this.sortDescriptions_CollectionChanged(null, null); };
3708
- _this._groupDescriptions = new SortDescriptionCollection();
3709
- _this._groupDescriptions.onChanged = function () { return _this.groupDescriptions_CollectionChanged(null, null); };
3710
- _this._filterExpressions = new FilterExpressionCollection();
3711
- _this._filterExpressions.onChanged = function () { return _this.filterExpressions_CollectionChanged(null, null); };
3712
- _this._summaryDescriptions = new SummaryDescriptionCollection();
3713
- _this._summaryDescriptions.onChanged = function () { return _this.summaryDescriptions_CollectionChanged(null, null); };
3714
- return _this;
3715
- }
3716
- RestVirtualDataSourceDataProvider.prototype.filterExpressions_CollectionChanged = function (sender, e) {
3717
- this.queueAutoRefresh();
3718
- };
3719
- RestVirtualDataSourceDataProvider.prototype.sortDescriptions_CollectionChanged = function (sender, e) {
3720
- this.queueAutoRefresh();
3721
- };
3722
- RestVirtualDataSourceDataProvider.prototype.groupDescriptions_CollectionChanged = function (sender, e) {
3723
- this.queueAutoRefresh();
3724
- };
3725
- RestVirtualDataSourceDataProvider.prototype.summaryDescriptions_CollectionChanged = function (sender, e) {
3726
- this.queueAutoRefresh();
3727
- };
3728
- RestVirtualDataSourceDataProvider.prototype.addPageRequest = function (pageIndex, priority) {
3729
- if (this.deferAutoRefresh) {
3730
- return;
3731
- }
3732
- if (this._worker != null && this._worker.isShutdown) {
3733
- this._worker = null;
3734
- this._callback = null;
3735
- }
3736
- if (this._worker == null) {
3737
- this.createWorker();
3738
- }
3739
- if (priority == DataSourcePageRequestPriority.High) {
3740
- this._requests.addFirst(pageIndex);
3741
- }
3742
- else {
3743
- this._requests.addLast(pageIndex);
3744
- }
3745
- if (!this._worker.addPageRequest(pageIndex, priority)) {
3746
- this._worker = null;
3747
- this._callback = null;
3748
- this.addPageRequest(pageIndex, priority);
3749
- }
3750
- };
3751
- RestVirtualDataSourceDataProvider.prototype.createWorker = function () {
3752
- if (!this.valid()) {
3753
- return;
3754
- }
3755
- this._callback = runOn(this, this.raisePageLoaded);
3756
- var settings = this.getWorkerSettings();
3757
- this._worker = new RestVirtualDataSourceDataProviderWorker(settings);
3758
- };
3759
- RestVirtualDataSourceDataProvider.prototype.valid = function () {
3760
- return this.entitySet != null && this.baseUri != null;
3761
- };
3762
- RestVirtualDataSourceDataProvider.prototype.getWorkerSettings = function () {
3763
- var _this = this;
3764
- return ((function () {
3765
- var $ret = new RestVirtualDataSourceDataProviderWorkerSettings();
3766
- $ret.baseUri = _this._baseUri;
3767
- $ret.entitySet = _this._entitySet;
3768
- $ret.pageSizeRequested = _this._pageSizeRequested;
3769
- $ret.timeoutMilliseconds = _this._timeoutMilliseconds;
3770
- $ret.pageLoaded = _this._callback;
3771
- $ret.executionContext = _this._executionContext;
3772
- $ret.sortDescriptions = _this._sortDescriptions;
3773
- $ret.groupDescriptions = _this._groupDescriptions;
3774
- $ret.filterExpressions = _this._filterExpressions;
3775
- $ret.propertiesRequested = _this._propertiesRequested;
3776
- $ret.schemaIncludedProperties = _this._schemaIncludedProperties;
3777
- $ret.summaryDescriptions = _this._summaryDescriptions;
3778
- $ret.summaryScope = _this._summaryScope;
3779
- $ret.enableJsonp = _this._enableJsonp;
3780
- $ret.isAggregationSupported = _this.isAggregationSupported;
3781
- $ret.performFetch = _this.performFetch;
3782
- $ret.provideAggregationParameter = _this.provideAggregationParameter;
3783
- $ret.provideAggregatedCount = _this.provideAggregatedCount;
3784
- $ret.provideDesiredPropertiesParameter = _this.provideDesiredPropertiesParameter;
3785
- $ret.provideFilterParameter = _this.provideFilterParameter;
3786
- $ret.provideFullCount = _this.provideFullCount;
3787
- $ret.provideItems = _this.provideItems;
3788
- $ret.provideOrderByParameter = _this.provideOrderByParameter;
3789
- $ret.providePagingParameter = _this.providePagingParameter;
3790
- $ret.provideUri = _this.provideUri;
3791
- $ret.fixedFullCount = _this.fixedFullCount;
3792
- return $ret;
3793
- })());
3794
- };
3795
- RestVirtualDataSourceDataProvider.prototype.removePageRequest = function (pageIndex) {
3796
- var current = this._requests.first;
3797
- while (current != null) {
3798
- if (current.value == pageIndex) {
3799
- this._requests.remove(current);
3800
- }
3801
- current = current.next;
3802
- }
3803
- if (this._worker == null) {
3804
- return;
3805
- }
3806
- this._worker.removePageRequest(pageIndex);
3807
- };
3808
- RestVirtualDataSourceDataProvider.prototype.removeAllPageRequests = function () {
3809
- this._requests.clear();
3810
- if (this._worker == null) {
3811
- return;
3812
- }
3813
- this._worker.removeAllPageRequests();
3814
- };
3815
- RestVirtualDataSourceDataProvider.prototype.close = function () {
3816
- if (this._worker != null) {
3817
- this._worker.shutdown();
3818
- this._worker = null;
3819
- this._callback = null;
3820
- }
3821
- };
3822
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "pageLoaded", {
3823
- get: function () {
3824
- return this._pageLoaded;
3825
- },
3826
- set: function (value) {
3827
- this._pageLoaded = value;
3828
- this.queueAutoRefresh();
3829
- },
3830
- enumerable: false,
3831
- configurable: true
3832
- });
3833
- RestVirtualDataSourceDataProvider.prototype.raisePageLoaded = function (page, fullCount, actualPageSize) {
3834
- if (this._pageLoaded != null) {
3835
- this._currentFullCount = fullCount;
3836
- if (this._currentSchema == null) {
3837
- var currentSchema = null;
3838
- if (page != null) {
3839
- currentSchema = page.schema();
3840
- }
3841
- this._currentSchema = currentSchema;
3842
- if (this.schemaChanged != null) {
3843
- this.schemaChanged(this, new DataSourceDataProviderSchemaChangedEventArgs(this._currentSchema, this._currentFullCount));
3844
- }
3845
- }
3846
- if (page.pageIndex() != RestVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
3847
- this._pageLoaded(page, fullCount, actualPageSize);
3848
- }
3849
- }
3850
- };
3851
- RestVirtualDataSourceDataProvider.prototype.killWorker = function () {
3852
- if (this._worker != null) {
3853
- this._worker.shutdown();
3854
- this._worker = null;
3855
- this._callback = null;
3856
- }
3857
- };
3858
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "pageSizeRequested", {
3859
- get: function () {
3860
- return this._pageSizeRequested;
3861
- },
3862
- set: function (value) {
3863
- this._pageSizeRequested = value;
3864
- this.queueAutoRefresh();
3865
- },
3866
- enumerable: false,
3867
- configurable: true
3868
- });
3869
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "baseUri", {
3870
- get: function () {
3871
- return this._baseUri;
3872
- },
3873
- set: function (value) {
3874
- var oldValue = this._baseUri;
3875
- this._baseUri = value;
3876
- if (oldValue != this._baseUri) {
3877
- this.queueAutoRefresh();
3878
- if (this.valid() && this.deferAutoRefresh) {
3879
- this.queueSchemaFetch();
3880
- }
3881
- }
3882
- },
3883
- enumerable: false,
3884
- configurable: true
3885
- });
3886
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "entitySet", {
3887
- get: function () {
3888
- return this._entitySet;
3889
- },
3890
- set: function (value) {
3891
- var oldValue = this._entitySet;
3892
- this._entitySet = value;
3893
- if (oldValue != this._entitySet) {
3894
- this.queueAutoRefresh();
3895
- if (this.valid() && this.deferAutoRefresh) {
3896
- this.queueSchemaFetch();
3897
- }
3898
- }
3899
- },
3900
- enumerable: false,
3901
- configurable: true
3902
- });
3903
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "timeoutMilliseconds", {
3904
- get: function () {
3905
- return this._timeoutMilliseconds;
3906
- },
3907
- set: function (value) {
3908
- this._timeoutMilliseconds = value;
3909
- this.queueAutoRefresh();
3910
- },
3911
- enumerable: false,
3912
- configurable: true
3913
- });
3914
- RestVirtualDataSourceDataProvider.prototype.getItemValue = function (item, valueName) {
3915
- var dic = item;
3916
- if (dic.has(valueName)) {
3917
- return dic.get(valueName);
3918
- }
3919
- else {
3920
- return null;
3921
- }
3922
- };
3923
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "actualCount", {
3924
- get: function () {
3925
- return this._currentFullCount;
3926
- },
3927
- enumerable: false,
3928
- configurable: true
3929
- });
3930
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "actualSchema", {
3931
- get: function () {
3932
- return this._currentSchema;
3933
- },
3934
- enumerable: false,
3935
- configurable: true
3936
- });
3937
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "executionContext", {
3938
- get: function () {
3939
- return this._executionContext;
3940
- },
3941
- set: function (value) {
3942
- this._executionContext = value;
3943
- this.queueAutoRefresh();
3944
- },
3945
- enumerable: false,
3946
- configurable: true
3947
- });
3948
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "updateNotifier", {
3949
- get: function () {
3950
- return this._updateNotifier;
3951
- },
3952
- set: function (value) {
3953
- this._updateNotifier = value;
3954
- },
3955
- enumerable: false,
3956
- configurable: true
3957
- });
3958
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "deferAutoRefresh", {
3959
- get: function () {
3960
- return this._deferAutoRefresh;
3961
- },
3962
- set: function (value) {
3963
- this._deferAutoRefresh = value;
3964
- if (!this._deferAutoRefresh) {
3965
- this.queueAutoRefresh();
3966
- }
3967
- if (this._deferAutoRefresh && this.valid() && this._currentSchema == null) {
3968
- this.queueSchemaFetch();
3969
- }
3970
- },
3971
- enumerable: false,
3972
- configurable: true
3973
- });
3974
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isSortingSupported", {
3975
- get: function () {
3976
- return true;
3977
- },
3978
- enumerable: false,
3979
- configurable: true
3980
- });
3981
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isGroupingSupported", {
3982
- get: function () {
3983
- return this.isAggregationSupported;
3984
- },
3985
- enumerable: false,
3986
- configurable: true
3987
- });
3988
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isFilteringSupported", {
3989
- get: function () {
3990
- return true;
3991
- },
3992
- enumerable: false,
3993
- configurable: true
3994
- });
3995
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isAggregationSupported", {
3996
- get: function () {
3997
- return this._isAggregationSupported;
3998
- },
3999
- set: function (isSupported) {
4000
- this._isAggregationSupported = isSupported;
4001
- },
4002
- enumerable: false,
4003
- configurable: true
4004
- });
4005
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "sortDescriptions", {
4006
- get: function () {
4007
- return this._sortDescriptions;
4008
- },
4009
- enumerable: false,
4010
- configurable: true
4011
- });
4012
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "groupDescriptions", {
4013
- get: function () {
4014
- return this._groupDescriptions;
4015
- },
4016
- enumerable: false,
4017
- configurable: true
4018
- });
4019
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "propertiesRequested", {
4020
- get: function () {
4021
- return this._propertiesRequested;
4022
- },
4023
- set: function (value) {
4024
- this._propertiesRequested = value;
4025
- this.queueAutoRefresh();
4026
- },
4027
- enumerable: false,
4028
- configurable: true
4029
- });
4030
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "schemaIncludedProperties", {
4031
- get: function () {
4032
- return this._schemaIncludedProperties;
4033
- },
4034
- set: function (value) {
4035
- this._schemaIncludedProperties = value;
4036
- this.queueAutoRefresh();
4037
- },
4038
- enumerable: false,
4039
- configurable: true
4040
- });
4041
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "filterExpressions", {
4042
- get: function () {
4043
- return this._filterExpressions;
4044
- },
4045
- enumerable: false,
4046
- configurable: true
4047
- });
4048
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "summaryDescriptions", {
4049
- get: function () {
4050
- return this._summaryDescriptions;
4051
- },
4052
- enumerable: false,
4053
- configurable: true
4054
- });
4055
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "summaryScope", {
4056
- get: function () {
4057
- return this._summaryScope;
4058
- },
4059
- set: function (value) {
4060
- this._summaryScope = value;
4061
- },
4062
- enumerable: false,
4063
- configurable: true
4064
- });
4065
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "enableJsonp", {
4066
- get: function () {
4067
- return this._enableJsonp;
4068
- },
4069
- set: function (isEnabled) {
4070
- this._enableJsonp = isEnabled;
4071
- },
4072
- enumerable: false,
4073
- configurable: true
4074
- });
4075
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "fixedFullCount", {
4076
- get: function () {
4077
- return this._fixedFullCount;
4078
- },
4079
- set: function (value) {
4080
- this._fixedFullCount = value;
4081
- },
4082
- enumerable: false,
4083
- configurable: true
4084
- });
4085
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideFullCount", {
4086
- get: function () {
4087
- return this._provideFullCount;
4088
- },
4089
- set: function (value) {
4090
- this._provideFullCount = value;
4091
- },
4092
- enumerable: false,
4093
- configurable: true
4094
- });
4095
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideOrderByParameter", {
4096
- get: function () {
4097
- return this._provideOrderByParameter;
4098
- },
4099
- set: function (value) {
4100
- this._provideOrderByParameter = value;
4101
- },
4102
- enumerable: false,
4103
- configurable: true
4104
- });
4105
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideFilterParameter", {
4106
- get: function () {
4107
- return this._provideFilterParameter;
4108
- },
4109
- set: function (value) {
4110
- this._provideFilterParameter = value;
4111
- },
4112
- enumerable: false,
4113
- configurable: true
4114
- });
4115
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideAggregationParameter", {
4116
- get: function () {
4117
- return this._provideAggregationParameter;
4118
- },
4119
- set: function (value) {
4120
- this._provideAggregationParameter = value;
4121
- },
4122
- enumerable: false,
4123
- configurable: true
4124
- });
4125
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideAggregatedCount", {
4126
- get: function () {
4127
- return this._provideAggregatedCount;
4128
- },
4129
- set: function (value) {
4130
- this._provideAggregatedCount = value;
4131
- },
4132
- enumerable: false,
4133
- configurable: true
4134
- });
4135
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideUri", {
4136
- get: function () {
4137
- return this._provideUri;
4138
- },
4139
- set: function (value) {
4140
- this._provideUri = value;
4141
- },
4142
- enumerable: false,
4143
- configurable: true
4144
- });
4145
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "performFetch", {
4146
- get: function () {
4147
- return this._performFetch;
4148
- },
4149
- set: function (value) {
4150
- this._performFetch = value;
4151
- },
4152
- enumerable: false,
4153
- configurable: true
4154
- });
4155
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "providePagingParameter", {
4156
- get: function () {
4157
- return this._providePagingParameter;
4158
- },
4159
- set: function (value) {
4160
- this._providePagingParameter = value;
4161
- },
4162
- enumerable: false,
4163
- configurable: true
4164
- });
4165
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideDesiredPropertiesParameter", {
4166
- get: function () {
4167
- return this._provideDesiredPropertiesParameter;
4168
- },
4169
- set: function (value) {
4170
- this._provideDesiredPropertiesParameter = value;
4171
- },
4172
- enumerable: false,
4173
- configurable: true
4174
- });
4175
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "provideItems", {
4176
- get: function () {
4177
- return this._provideItems;
4178
- },
4179
- set: function (value) {
4180
- this._provideItems = value;
4181
- },
4182
- enumerable: false,
4183
- configurable: true
4184
- });
4185
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "notifyUsingSourceIndexes", {
4186
- get: function () {
4187
- return true;
4188
- },
4189
- enumerable: false,
4190
- configurable: true
4191
- });
4192
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isItemIndexLookupSupported", {
4193
- get: function () {
4194
- return false;
4195
- },
4196
- enumerable: false,
4197
- configurable: true
4198
- });
4199
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "isKeyIndexLookupSupported", {
4200
- get: function () {
4201
- return false;
4202
- },
4203
- enumerable: false,
4204
- configurable: true
4205
- });
4206
- RestVirtualDataSourceDataProvider.prototype.notifySetItem = function (index, oldItem, newItem) {
4207
- if (this.updateNotifier != null) {
4208
- this.updateNotifier.notifySetItem(index, oldItem, newItem);
4209
- }
4210
- };
4211
- RestVirtualDataSourceDataProvider.prototype.notifyClearItems = function () {
4212
- if (this.updateNotifier != null) {
4213
- this.updateNotifier.notifyClearItems();
4214
- }
4215
- };
4216
- RestVirtualDataSourceDataProvider.prototype.notifyInsertItem = function (index, newItem) {
4217
- if (this.updateNotifier != null) {
4218
- this.updateNotifier.notifyInsertItem(index, newItem);
4219
- }
4220
- };
4221
- RestVirtualDataSourceDataProvider.prototype.notifyRemoveItem = function (index, oldItem) {
4222
- if (this.updateNotifier != null) {
4223
- this.updateNotifier.notifyRemoveItem(index, oldItem);
4224
- }
4225
- };
4226
- RestVirtualDataSourceDataProvider.prototype.queueSchemaFetch = function () {
4227
- if (this._schemaFetchQueued) {
4228
- return;
4229
- }
4230
- if (this.executionContext != null) {
4231
- this._schemaFetchQueued = true;
4232
- this.executionContext.enqueueAction(runOn(this, this.doSchemaFetchInternal));
4233
- }
4234
- };
4235
- RestVirtualDataSourceDataProvider.prototype.doSchemaFetchInternal = function () {
4236
- if (!this._schemaFetchQueued) {
4237
- return;
4238
- }
4239
- this._schemaFetchQueued = false;
4240
- this.schemaFetchInternal();
4241
- };
4242
- RestVirtualDataSourceDataProvider.prototype.schemaFetchInternal = function () {
4243
- this.schemaFetchInternalOverride();
4244
- };
4245
- RestVirtualDataSourceDataProvider.prototype.schemaFetchInternalOverride = function () {
4246
- if (!this.deferAutoRefresh) {
4247
- return;
4248
- }
4249
- this.removeAllPageRequests();
4250
- this.killWorker();
4251
- this.createWorker();
4252
- this.addSchemaRequest();
4253
- };
4254
- RestVirtualDataSourceDataProvider.prototype.addSchemaRequest = function () {
4255
- this._worker.addPageRequest(RestVirtualDataSourceDataProviderWorker.schemaRequestIndex, DataSourcePageRequestPriority.High);
4256
- };
4257
- RestVirtualDataSourceDataProvider.prototype.queueAutoRefresh = function () {
4258
- if (this.deferAutoRefresh) {
4259
- return;
4260
- }
4261
- if (this._autoRefreshQueued) {
4262
- return;
4263
- }
4264
- if (this.executionContext != null) {
4265
- this._autoRefreshQueued = true;
4266
- this.executionContext.enqueueAction(runOn(this, this.doRefreshInternal));
4267
- }
4268
- };
4269
- RestVirtualDataSourceDataProvider.prototype.doRefreshInternal = function () {
4270
- if (this.deferAutoRefresh) {
4271
- this._autoRefreshQueued = false;
4272
- return;
4273
- }
4274
- if (!this._autoRefreshQueued) {
4275
- return;
4276
- }
4277
- this._autoRefreshQueued = false;
4278
- this.refreshInternal();
4279
- };
4280
- RestVirtualDataSourceDataProvider.prototype.refreshInternal = function () {
4281
- this.refreshInternalOverride();
4282
- };
4283
- RestVirtualDataSourceDataProvider.prototype.refreshInternalOverride = function () {
4284
- this.removeAllPageRequests();
4285
- this.killWorker();
4286
- this.createWorker();
4287
- this._worker.addPageRequest(0, DataSourcePageRequestPriority.Normal);
4288
- };
4289
- RestVirtualDataSourceDataProvider.prototype.flushAutoRefresh = function () {
4290
- this.doRefreshInternal();
4291
- };
4292
- RestVirtualDataSourceDataProvider.prototype.refresh = function () {
4293
- this.refreshInternal();
4294
- };
4295
- RestVirtualDataSourceDataProvider.prototype.indexOfItem = function (item) {
4296
- return -1;
4297
- };
4298
- RestVirtualDataSourceDataProvider.prototype.indexOfKey = function (key) {
4299
- return -1;
4300
- };
4301
- RestVirtualDataSourceDataProvider.prototype.resolveSchemaPropertyType = function (propertyPath) {
4302
- if (this.actualSchema == null) {
4303
- return DataSourceSchemaPropertyType.ObjectValue;
4304
- }
4305
- if (stringContains(propertyPath, ".")) {
4306
- return DataSourceSchemaPropertyType.ObjectValue;
4307
- }
4308
- for (var i = 0; i < this.actualSchema.propertyNames.length; i++) {
4309
- var name_1 = this.actualSchema.propertyNames[i];
4310
- if (name_1 == propertyPath) {
4311
- return this.actualSchema.propertyTypes[i];
4312
- }
4313
- }
4314
- return DataSourceSchemaPropertyType.ObjectValue;
4315
- };
4316
- RestVirtualDataSourceDataProvider.prototype.setItemValue = function (item, valueName, value) {
4317
- // does nothing.
4318
- };
4319
- RestVirtualDataSourceDataProvider.prototype.removeItem = function (item) {
4320
- // does nothing.
4321
- };
4322
- RestVirtualDataSourceDataProvider.prototype.addItem = function (item) {
4323
- // does nothing.
4324
- };
4325
- RestVirtualDataSourceDataProvider.prototype.createBatchRequest = function (changes) {
4326
- if (this._worker != null) {
4327
- this._worker.createBatchRequest(changes);
4328
- }
4329
- };
4330
- Object.defineProperty(RestVirtualDataSourceDataProvider.prototype, "batchCompleted", {
4331
- get: function () {
4332
- return this._batchCompleted;
4333
- },
4334
- set: function (v) {
4335
- this._batchCompleted = v;
4336
- },
4337
- enumerable: false,
4338
- configurable: true
4339
- });
4340
- RestVirtualDataSourceDataProvider.$t = markType(RestVirtualDataSourceDataProvider, 'ODataVirtualDataSourceDataProvider', Base.$type, [IDataSourceVirtualDataProvider_$type]);
4341
- return RestVirtualDataSourceDataProvider;
4342
- }(Base));
4343
-
4344
- var RestVirtualDataSource = /** @class */ /*@__PURE__*/ (function (_super) {
4345
- __extends(RestVirtualDataSource, _super);
4346
- function RestVirtualDataSource() {
4347
- var _this = _super.call(this) || this;
4348
- _this._baseUri = null;
4349
- _this._isFilteringSupportedByServer = false;
4350
- _this._entitySet = null;
4351
- _this._timeoutMilliseconds = 10000;
4352
- _this._isAggregationSupportedByServer = false;
4353
- _this._enableJsonp = true;
4354
- _this._fixedFullCount = -1;
4355
- _this._provideFullCount = null;
4356
- _this._provideOrderByParameter = null;
4357
- _this._provideFilterParameter = null;
4358
- _this._provideAggregationParameter = null;
4359
- _this._provideAggregatedCount = null;
4360
- _this._provideUri = null;
4361
- _this._performFetch = null;
4362
- _this._providePagingParameter = null;
4363
- _this._provideDesiredPropertiesParameter = null;
4364
- _this.dataProvider = ((function () {
4365
- var $ret = new RestVirtualDataSourceDataProvider();
4366
- $ret.executionContext = _this.executionContext;
4367
- $ret.enableJsonp = _this.enableJsonp;
4368
- $ret.isAggregationSupported = _this.isGroupingSupported;
4369
- return $ret;
4370
- })());
4371
- _this.externalDataSource = _this;
4372
- return _this;
4373
- }
4374
- RestVirtualDataSource.prototype.onBaseUriChanged = function (oldValue, newValue) {
4375
- if (this.actualDataProvider) {
4376
- this.actualDataProvider.baseUri = this.baseUri;
4377
- this.queueAutoRefresh();
4378
- }
4379
- };
4380
- Object.defineProperty(RestVirtualDataSource.prototype, "baseUri", {
4381
- get: function () {
4382
- return this._baseUri;
4383
- },
4384
- set: function (value) {
4385
- var oldValue = this._baseUri;
4386
- this._baseUri = value;
4387
- if (oldValue != this._baseUri) {
4388
- this.onBaseUriChanged(oldValue, this._baseUri);
4389
- }
4390
- },
4391
- enumerable: false,
4392
- configurable: true
4393
- });
4394
- RestVirtualDataSource.prototype.onEntitySetChanged = function (oldValue, newValue) {
4395
- if (this.actualDataProvider) {
4396
- this.actualDataProvider.entitySet = this.entitySet;
4397
- this.queueAutoRefresh();
4398
- }
4399
- this.queueAutoRefresh();
4400
- };
4401
- Object.defineProperty(RestVirtualDataSource.prototype, "isFilteringSupportedByServer", {
4402
- get: function () {
4403
- return this._isFilteringSupportedByServer;
4404
- },
4405
- set: function (v) {
4406
- this._isFilteringSupportedByServer = v;
4407
- },
4408
- enumerable: false,
4409
- configurable: true
4410
- });
4411
- RestVirtualDataSource.prototype.get_isFilteringSupported = function () {
4412
- if (this._isFilteringSupportedByServer) {
4413
- return true;
4414
- }
4415
- return false;
4416
- };
4417
- Object.defineProperty(RestVirtualDataSource.prototype, "entitySet", {
4418
- get: function () {
4419
- return this._entitySet;
4420
- },
4421
- set: function (value) {
4422
- var oldValue = this._entitySet;
4423
- this._entitySet = value;
4424
- if (this._entitySet != oldValue) {
4425
- this.onEntitySetChanged(oldValue, this._entitySet);
4426
- }
4427
- },
4428
- enumerable: false,
4429
- configurable: true
4430
- });
4431
- RestVirtualDataSource.prototype.onTimeoutMillisecondsChanged = function (oldValue, newValue) {
4432
- if (this.actualDataProvider) {
4433
- this.actualDataProvider.timeoutMilliseconds = this.timeoutMilliseconds;
4434
- }
4435
- };
4436
- Object.defineProperty(RestVirtualDataSource.prototype, "timeoutMilliseconds", {
4437
- get: function () {
4438
- return this._timeoutMilliseconds;
4439
- },
4440
- set: function (value) {
4441
- var oldValue = this._timeoutMilliseconds;
4442
- this._timeoutMilliseconds = value;
4443
- if (oldValue != this._timeoutMilliseconds) {
4444
- this.onTimeoutMillisecondsChanged(oldValue, this._timeoutMilliseconds);
4445
- }
4446
- },
4447
- enumerable: false,
4448
- configurable: true
4449
- });
4450
- Object.defineProperty(RestVirtualDataSource.prototype, "isSortingSupportedOverride", {
4451
- get: function () {
4452
- return true;
4453
- },
4454
- enumerable: false,
4455
- configurable: true
4456
- });
4457
- Object.defineProperty(RestVirtualDataSource.prototype, "isFilteringSupportedOverride", {
4458
- get: function () {
4459
- return true;
4460
- },
4461
- enumerable: false,
4462
- configurable: true
4463
- });
4464
- Object.defineProperty(RestVirtualDataSource.prototype, "isGroupingSupportedOverride", {
4465
- get: function () {
4466
- return this.isAggregationSupportedByServer;
4467
- },
4468
- enumerable: false,
4469
- configurable: true
4470
- });
4471
- Object.defineProperty(RestVirtualDataSource.prototype, "isAggregationSupportedByServer", {
4472
- get: function () {
4473
- return this._isAggregationSupportedByServer;
4474
- },
4475
- set: function (isSupported) {
4476
- this._isAggregationSupportedByServer = isSupported;
4477
- if (this.actualDataProvider) {
4478
- this.actualDataProvider.isAggregationSupported = this.isAggregationSupportedByServer;
4479
- }
4480
- },
4481
- enumerable: false,
4482
- configurable: true
4483
- });
4484
- Object.defineProperty(RestVirtualDataSource.prototype, "enableJsonp", {
4485
- get: function () {
4486
- return this._enableJsonp;
4487
- },
4488
- set: function (isEnabled) {
4489
- this._enableJsonp = isEnabled;
4490
- if (this.actualDataProvider) {
4491
- this.actualDataProvider.enableJsonp = this.enableJsonp;
4492
- }
4493
- },
4494
- enumerable: false,
4495
- configurable: true
4496
- });
4497
- Object.defineProperty(RestVirtualDataSource.prototype, "fixedFullCount", {
4498
- get: function () {
4499
- return this._fixedFullCount;
4500
- },
4501
- set: function (value) {
4502
- this._fixedFullCount = value;
4503
- },
4504
- enumerable: false,
4505
- configurable: true
4506
- });
4507
- Object.defineProperty(RestVirtualDataSource.prototype, "provideFullCount", {
4508
- get: function () {
4509
- return this._provideFullCount;
4510
- },
4511
- set: function (value) {
4512
- this._provideFullCount = value;
4513
- if (this.actualDataProvider) {
4514
- this.actualDataProvider.provideFullCount = this.provideFullCount;
4515
- this.queueAutoRefresh();
4516
- }
4517
- },
4518
- enumerable: false,
4519
- configurable: true
4520
- });
4521
- Object.defineProperty(RestVirtualDataSource.prototype, "provideOrderByParameter", {
4522
- get: function () {
4523
- return this._provideOrderByParameter;
4524
- },
4525
- set: function (value) {
4526
- this._provideOrderByParameter = value;
4527
- if (this.actualDataProvider) {
4528
- this.actualDataProvider.provideOrderByParameter = this.provideOrderByParameter;
4529
- this.queueAutoRefresh();
4530
- }
4531
- },
4532
- enumerable: false,
4533
- configurable: true
4534
- });
4535
- Object.defineProperty(RestVirtualDataSource.prototype, "provideFilterParameter", {
4536
- get: function () {
4537
- return this._provideFilterParameter;
4538
- },
4539
- set: function (value) {
4540
- this._provideFilterParameter = value;
4541
- if (this.actualDataProvider) {
4542
- this.actualDataProvider.provideFilterParameter = this.provideFilterParameter;
4543
- this.queueAutoRefresh();
4544
- }
4545
- },
4546
- enumerable: false,
4547
- configurable: true
4548
- });
4549
- Object.defineProperty(RestVirtualDataSource.prototype, "provideAggregationParameter", {
4550
- get: function () {
4551
- return this._provideAggregationParameter;
4552
- },
4553
- set: function (value) {
4554
- this._provideAggregationParameter = value;
4555
- if (this.actualDataProvider) {
4556
- this.actualDataProvider.provideAggregationParameter = this.provideAggregationParameter;
4557
- this.queueAutoRefresh();
4558
- }
4559
- },
4560
- enumerable: false,
4561
- configurable: true
4562
- });
4563
- Object.defineProperty(RestVirtualDataSource.prototype, "provideAggregatedCount", {
4564
- get: function () {
4565
- return this._provideAggregatedCount;
4566
- },
4567
- set: function (value) {
4568
- this._provideAggregatedCount = value;
4569
- if (this.actualDataProvider) {
4570
- this.actualDataProvider.provideAggregatedCount = this.provideAggregatedCount;
4571
- this.queueAutoRefresh();
4572
- }
4573
- },
4574
- enumerable: false,
4575
- configurable: true
4576
- });
4577
- Object.defineProperty(RestVirtualDataSource.prototype, "provideUri", {
4578
- get: function () {
4579
- return this._provideUri;
4580
- },
4581
- set: function (value) {
4582
- this._provideUri = value;
4583
- if (this.actualDataProvider) {
4584
- this.actualDataProvider.provideUri = this.provideUri;
4585
- this.queueAutoRefresh();
4586
- }
4587
- },
4588
- enumerable: false,
4589
- configurable: true
4590
- });
4591
- Object.defineProperty(RestVirtualDataSource.prototype, "performFetch", {
4592
- get: function () {
4593
- return this._performFetch;
4594
- },
4595
- set: function (value) {
4596
- this._performFetch = value;
4597
- if (this.actualDataProvider) {
4598
- this.actualDataProvider.performFetch = this.performFetch;
4599
- this.queueAutoRefresh();
4600
- }
4601
- },
4602
- enumerable: false,
4603
- configurable: true
4604
- });
4605
- Object.defineProperty(RestVirtualDataSource.prototype, "providePagingParameter", {
4606
- get: function () {
4607
- return this._providePagingParameter;
4608
- },
4609
- set: function (value) {
4610
- this._providePagingParameter = value;
4611
- if (this.actualDataProvider) {
4612
- this.actualDataProvider.providePagingParameter = this.providePagingParameter;
4613
- this.queueAutoRefresh();
4614
- }
4615
- },
4616
- enumerable: false,
4617
- configurable: true
4618
- });
4619
- Object.defineProperty(RestVirtualDataSource.prototype, "provideDesiredPropertiesParameter", {
4620
- get: function () {
4621
- return this._provideDesiredPropertiesParameter;
4622
- },
4623
- set: function (value) {
4624
- this._provideDesiredPropertiesParameter = value;
4625
- if (this.actualDataProvider) {
4626
- this.actualDataProvider.provideDesiredPropertiesParameter = this.provideDesiredPropertiesParameter;
4627
- this.queueAutoRefresh();
4628
- }
4629
- },
4630
- enumerable: false,
4631
- configurable: true
4632
- });
4633
- Object.defineProperty(RestVirtualDataSource.prototype, "provideItems", {
4634
- get: function () {
4635
- return this._provideItems;
4636
- },
4637
- set: function (value) {
4638
- this._provideItems = value;
4639
- if (this.actualDataProvider) {
4640
- this.actualDataProvider.provideItems = this.provideItems;
4641
- this.queueAutoRefresh();
4642
- }
4643
- },
4644
- enumerable: false,
4645
- configurable: true
4646
- });
4647
- RestVirtualDataSource.prototype.clone = function () {
4648
- var dataSource = new RestVirtualDataSource();
4649
- dataSource.executionContext = this.executionContext;
4650
- dataSource.includeSummaryRowsInSection = this.includeSummaryRowsInSection;
4651
- dataSource.isSectionCollapsable = this.isSectionCollapsable;
4652
- dataSource.isSectionExpandedDefault = this.isSectionExpandedDefault;
4653
- //dataSource.isSectionHeaderNormalRow = this.isSectionHeaderNormalRow;
4654
- dataSource.isSectionSummaryRowsAtBottom = this.isSectionSummaryRowsAtBottom;
4655
- //dataSource.isSectionContentVisible = this.isSectionContentVisible;
4656
- dataSource.primaryKey = this.primaryKey;
4657
- dataSource.propertiesRequested = this.propertiesRequested;
4658
- dataSource.sectionHeaderDisplayMode = this.sectionHeaderDisplayMode;
4659
- dataSource.shouldEmitSectionFooters = this.shouldEmitSectionFooters;
4660
- dataSource.shouldEmitSectionHeaders = this.shouldEmitSectionHeaders;
4661
- dataSource.shouldEmitShiftedRows = this.shouldEmitShiftedRows;
4662
- dataSource.summaryScope = this.summaryScope;
4663
- for (var i = 0; i < this.groupDescriptions.size(); i++) {
4664
- dataSource.groupDescriptions.add(this.groupDescriptions.get(i));
4665
- }
4666
- for (var i = 0; i < this.sortDescriptions.size(); i++) {
4667
- dataSource.sortDescriptions.add(this.sortDescriptions.get(i));
4668
- }
4669
- for (var i = 0; i < this.filterExpressions.size(); i++) {
4670
- dataSource.filterExpressions.add(this.filterExpressions.get(i));
4671
- }
4672
- for (var i = 0; i < this.summaryDescriptions.size(); i++) {
4673
- dataSource.summaryDescriptions.add(this.summaryDescriptions.get(i));
4674
- }
4675
- dataSource.pageSizeRequested = this.pageSizeRequested;
4676
- dataSource.maxCachedPages = this.maxCachedPages;
4677
- dataSource.baseUri = this.baseUri;
4678
- dataSource.entitySet = this.entitySet;
4679
- dataSource.timeoutMilliseconds = this.timeoutMilliseconds;
4680
- dataSource.isAggregationSupportedByServer = this.isAggregationSupportedByServer;
4681
- dataSource.enableJsonp = this.enableJsonp;
4682
- dataSource.fixedFullCount = this.fixedFullCount;
4683
- dataSource.provideAggregationParameter = this.provideAggregationParameter;
4684
- dataSource.provideAggregatedCount = this.provideAggregatedCount;
4685
- dataSource.provideFilterParameter = this.provideFilterParameter;
4686
- dataSource.provideFullCount = this.provideFullCount;
4687
- dataSource.provideOrderByParameter = this.provideOrderByParameter;
4688
- dataSource.provideUri = this.provideUri;
4689
- dataSource.performFetch = this.performFetch;
4690
- dataSource.providePagingParameter = this.providePagingParameter;
4691
- dataSource.provideItems = this.provideItems;
4692
- dataSource.provideDesiredPropertiesParameter = this.provideDesiredPropertiesParameter;
4693
- return dataSource;
4694
- };
4695
- return RestVirtualDataSource;
4696
- }(VirtualDataSource));
4697
-
4698
- export { Entity, EntityProperty, EntitySet, LinkedList, LinkedListNode, ODataDataSourcePage, ODataSchemaProvider, ODataVirtualDataSource, ODataVirtualDataSourceDataProvider, ODataVirtualDataSourceDataProviderWorker, ODataVirtualDataSourceDataProviderWorkerSettings, ODataVirtualDataSourceProviderTaskDataHolder, RestVirtualDataSource, RestVirtualDataSourceDataProvider, RestVirtualDataSourceDataProviderWorker, RestVirtualDataSourceDataProviderWorkerSettings, RestVirtualDataSourcePage, RestVirtualDataSourceProviderTaskDataHolder, Schema, first, toArray };