igniteui-webcomponents-datasources 7.1.1-beta.1 → 7.1.1-beta.2
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.
- package/fesm2022/igniteui-webcomponents-datasources.mjs +3611 -0
- package/igniteui-webcomponents-datasources.d.ts +754 -1
- package/package.json +13 -9
- package/bundles/igniteui-webcomponents-datasources.umd.js +0 -4725
- package/bundles/igniteui-webcomponents-datasources.umd.min.js +0 -7
- package/esm2015/igniteui-webcomponents-datasources.js +0 -1
- package/esm2015/lib/Entity.js +0 -65
- package/esm2015/lib/EntityProperty.js +0 -27
- package/esm2015/lib/EntitySet.js +0 -50
- package/esm2015/lib/ODataDataSourcePage.js +0 -67
- package/esm2015/lib/ODataSchemaProvider.js +0 -123
- package/esm2015/lib/ODataVirtualDataSource.js +0 -132
- package/esm2015/lib/ODataVirtualDataSourceDataProvider.js +0 -453
- package/esm2015/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -713
- package/esm2015/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -86
- package/esm2015/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -9
- package/esm2015/lib/RestVirtualDataSource.js +0 -272
- package/esm2015/lib/RestVirtualDataSourceDataProvider.js +0 -538
- package/esm2015/lib/RestVirtualDataSourceDataProviderWorker.js +0 -765
- package/esm2015/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -162
- package/esm2015/lib/RestVirtualDataSourcePage.js +0 -67
- package/esm2015/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -9
- package/esm2015/lib/Schema.js +0 -54
- package/esm2015/lib/util.js +0 -116
- package/esm2015/public_api.js +0 -18
- package/esm5/igniteui-webcomponents-datasources.js +0 -1
- package/esm5/lib/Entity.js +0 -79
- package/esm5/lib/EntityProperty.js +0 -41
- package/esm5/lib/EntitySet.js +0 -68
- package/esm5/lib/ODataDataSourcePage.js +0 -73
- package/esm5/lib/ODataSchemaProvider.js +0 -158
- package/esm5/lib/ODataVirtualDataSource.js +0 -169
- package/esm5/lib/ODataVirtualDataSourceDataProvider.js +0 -558
- package/esm5/lib/ODataVirtualDataSourceDataProviderWorker.js +0 -920
- package/esm5/lib/ODataVirtualDataSourceDataProviderWorkerSettings.js +0 -130
- package/esm5/lib/ODataVirtualDataSourceProviderTaskDataHolder.js +0 -11
- package/esm5/lib/RestVirtualDataSource.js +0 -357
- package/esm5/lib/RestVirtualDataSourceDataProvider.js +0 -687
- package/esm5/lib/RestVirtualDataSourceDataProviderWorker.js +0 -967
- package/esm5/lib/RestVirtualDataSourceDataProviderWorkerSettings.js +0 -250
- package/esm5/lib/RestVirtualDataSourcePage.js +0 -73
- package/esm5/lib/RestVirtualDataSourceProviderTaskDataHolder.js +0 -11
- package/esm5/lib/Schema.js +0 -68
- package/esm5/lib/util.js +0 -160
- package/esm5/public_api.js +0 -18
- package/fesm2015/igniteui-webcomponents-datasources.js +0 -3638
- package/fesm5/igniteui-webcomponents-datasources.js +0 -4698
- package/lib/Entity.d.ts +0 -14
- package/lib/EntityProperty.d.ts +0 -12
- package/lib/EntitySet.d.ts +0 -15
- package/lib/ODataDataSourcePage.d.ts +0 -19
- package/lib/ODataSchemaProvider.d.ts +0 -12
- package/lib/ODataVirtualDataSource.d.ts +0 -28
- package/lib/ODataVirtualDataSourceDataProvider.d.ts +0 -120
- package/lib/ODataVirtualDataSourceDataProviderWorker.d.ts +0 -57
- package/lib/ODataVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -42
- package/lib/ODataVirtualDataSourceProviderTaskDataHolder.d.ts +0 -5
- package/lib/RestVirtualDataSource.d.ts +0 -86
- package/lib/RestVirtualDataSourceDataProvider.d.ts +0 -171
- package/lib/RestVirtualDataSourceDataProviderWorker.d.ts +0 -70
- package/lib/RestVirtualDataSourceDataProviderWorkerSettings.d.ts +0 -93
- package/lib/RestVirtualDataSourcePage.d.ts +0 -19
- package/lib/RestVirtualDataSourceProviderTaskDataHolder.d.ts +0 -5
- package/lib/Schema.d.ts +0 -15
- package/lib/util.d.ts +0 -27
- package/public_api.d.ts +0 -18
|
@@ -1,920 +0,0 @@
|
|
|
1
|
-
import { __extends, __generator, __values } from "tslib";
|
|
2
|
-
import { AsyncVirtualDataSourceProviderWorker } from "igniteui-webcomponents-core";
|
|
3
|
-
import { SortDescriptionCollection } from "igniteui-webcomponents-core";
|
|
4
|
-
import { ODataVirtualDataSourceProviderTaskDataHolder } from "./ODataVirtualDataSourceProviderTaskDataHolder";
|
|
5
|
-
import { AsyncDataSourcePageTaskHolder } from "igniteui-webcomponents-core";
|
|
6
|
-
import { AsyncVirtualDataTask } from "igniteui-webcomponents-core";
|
|
7
|
-
import { ODataDataSourcePage } from "./ODataDataSourcePage";
|
|
8
|
-
import { DefaultSectionInformation } from "igniteui-webcomponents-core";
|
|
9
|
-
import { Convert } from "igniteui-webcomponents-core";
|
|
10
|
-
import { ODataSchemaProvider } from "./ODataSchemaProvider";
|
|
11
|
-
import { ODataDataSourceFilterExpressionVisitor } from "igniteui-webcomponents-core";
|
|
12
|
-
import { ListSortDirection } from "igniteui-webcomponents-core";
|
|
13
|
-
import { stringIsNullOrEmpty } from "igniteui-webcomponents-core";
|
|
14
|
-
import { DataSourceSummaryOperand } from "igniteui-webcomponents-core";
|
|
15
|
-
import { DataSourceSummaryScope } from "igniteui-webcomponents-core";
|
|
16
|
-
import { DefaultSummaryResult } from "igniteui-webcomponents-core";
|
|
17
|
-
import { TransactionType } from "igniteui-webcomponents-core";
|
|
18
|
-
import { ODataDataSourceSchema } from "igniteui-webcomponents-core";
|
|
19
|
-
export var ODataVirtualDataSourceDataProviderWorker = /** @class */ /*@__PURE__*/ (function (_super) {
|
|
20
|
-
__extends(ODataVirtualDataSourceDataProviderWorker, _super);
|
|
21
|
-
function ODataVirtualDataSourceDataProviderWorker(settings) {
|
|
22
|
-
var e_1, _a;
|
|
23
|
-
var _this = _super.call(this, settings) || this;
|
|
24
|
-
_this._baseUri = null;
|
|
25
|
-
_this._entitySet = null;
|
|
26
|
-
_this._sortDescriptions = null;
|
|
27
|
-
_this._groupDescriptions = null;
|
|
28
|
-
_this._filterExpressions = null;
|
|
29
|
-
_this._summaryDescriptions = null;
|
|
30
|
-
_this._desiredPropeties = null;
|
|
31
|
-
_this._schemaIncludedProperties = null;
|
|
32
|
-
_this._enableJsonp = true;
|
|
33
|
-
_this._isAggregationSupported = false;
|
|
34
|
-
_this._groupInformation = null;
|
|
35
|
-
_this._summaryInformation = null;
|
|
36
|
-
_this._filterString = null;
|
|
37
|
-
_this._selectedString = null;
|
|
38
|
-
_this.doWork = _this.doWork.bind(_this);
|
|
39
|
-
_this._baseUri = settings.baseUri;
|
|
40
|
-
_this._entitySet = settings.entitySet;
|
|
41
|
-
_this._sortDescriptions = settings.sortDescriptions;
|
|
42
|
-
_this._groupDescriptions = settings.groupDescriptions;
|
|
43
|
-
if (_this._groupDescriptions != null && _this._groupDescriptions.size() > 0) {
|
|
44
|
-
_this._sortDescriptions = new SortDescriptionCollection();
|
|
45
|
-
try {
|
|
46
|
-
for (var _b = __values(_this.iter(settings.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
47
|
-
var sd = _c.value;
|
|
48
|
-
_this._sortDescriptions.add(sd);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (e_1_1) {
|
|
52
|
-
e_1 = { error: e_1_1 };
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
try {
|
|
56
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
57
|
-
_a.call(_b);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
if (e_1)
|
|
61
|
-
throw e_1.error;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
for (var i = 0; i < _this._groupDescriptions.size(); i++) {
|
|
65
|
-
_this._sortDescriptions.insert(i, _this._groupDescriptions.get(i));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
_this._filterExpressions = settings.filterExpressions;
|
|
69
|
-
_this._desiredPropeties = settings.propertiesRequested;
|
|
70
|
-
if (settings.schemaIncludedProperties != null) {
|
|
71
|
-
_this._schemaIncludedProperties = new Set();
|
|
72
|
-
for (var i = 0; i < settings.schemaIncludedProperties.length; i++) {
|
|
73
|
-
_this._schemaIncludedProperties.add(settings.schemaIncludedProperties[i]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
_this._summaryDescriptions = settings.summaryDescriptions;
|
|
77
|
-
_this._summaryScope = settings.summaryScope;
|
|
78
|
-
_this._enableJsonp = settings.enableJsonp;
|
|
79
|
-
_this._isAggregationSupported = settings.isAggregationSupported;
|
|
80
|
-
window.setTimeout(_this.doWork, 100);
|
|
81
|
-
return _this;
|
|
82
|
-
}
|
|
83
|
-
Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "sortDescriptions", {
|
|
84
|
-
get: function () {
|
|
85
|
-
return this._sortDescriptions;
|
|
86
|
-
},
|
|
87
|
-
enumerable: false,
|
|
88
|
-
configurable: true
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "filterExpressions", {
|
|
91
|
-
get: function () {
|
|
92
|
-
return this._filterExpressions;
|
|
93
|
-
},
|
|
94
|
-
enumerable: false,
|
|
95
|
-
configurable: true
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(ODataVirtualDataSourceDataProviderWorker.prototype, "desiredProperties", {
|
|
98
|
-
get: function () {
|
|
99
|
-
return this._desiredPropeties;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.initialize = function () {
|
|
105
|
-
_super.prototype.initialize.call(this);
|
|
106
|
-
};
|
|
107
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.getTaskDataHolder = function () {
|
|
108
|
-
var holder = new ODataVirtualDataSourceProviderTaskDataHolder();
|
|
109
|
-
return holder;
|
|
110
|
-
};
|
|
111
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.getCompletedTaskData = function (holder, completed) {
|
|
112
|
-
_super.prototype.getCompletedTaskData.call(this, holder, completed);
|
|
113
|
-
};
|
|
114
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.removeCompletedTaskData = function (holder, completed) {
|
|
115
|
-
_super.prototype.removeCompletedTaskData.call(this, holder, completed);
|
|
116
|
-
};
|
|
117
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.getTasksData = function (holder) {
|
|
118
|
-
_super.prototype.getTasksData.call(this, holder);
|
|
119
|
-
};
|
|
120
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.iter = function (coll) {
|
|
121
|
-
var i;
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
switch (_a.label) {
|
|
124
|
-
case 0:
|
|
125
|
-
i = 0;
|
|
126
|
-
_a.label = 1;
|
|
127
|
-
case 1:
|
|
128
|
-
if (!(i < coll.size()))
|
|
129
|
-
return [3 /*break*/, 4];
|
|
130
|
-
return [4 /*yield*/, coll.get(i)];
|
|
131
|
-
case 2:
|
|
132
|
-
_a.sent();
|
|
133
|
-
_a.label = 3;
|
|
134
|
-
case 3:
|
|
135
|
-
i++;
|
|
136
|
-
return [3 /*break*/, 1];
|
|
137
|
-
case 4: return [2 /*return*/];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.iterFilter = function (coll) {
|
|
142
|
-
var i;
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0:
|
|
146
|
-
i = 0;
|
|
147
|
-
_a.label = 1;
|
|
148
|
-
case 1:
|
|
149
|
-
if (!(i < coll.size()))
|
|
150
|
-
return [3 /*break*/, 4];
|
|
151
|
-
return [4 /*yield*/, coll.get(i)];
|
|
152
|
-
case 2:
|
|
153
|
-
_a.sent();
|
|
154
|
-
_a.label = 3;
|
|
155
|
-
case 3:
|
|
156
|
-
i++;
|
|
157
|
-
return [3 /*break*/, 1];
|
|
158
|
-
case 4: return [2 /*return*/];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.iterSummaries = function (summaries) {
|
|
163
|
-
var i;
|
|
164
|
-
return __generator(this, function (_a) {
|
|
165
|
-
switch (_a.label) {
|
|
166
|
-
case 0:
|
|
167
|
-
i = 0;
|
|
168
|
-
_a.label = 1;
|
|
169
|
-
case 1:
|
|
170
|
-
if (!(i < summaries.size()))
|
|
171
|
-
return [3 /*break*/, 4];
|
|
172
|
-
return [4 /*yield*/, summaries.get(i)];
|
|
173
|
-
case 2:
|
|
174
|
-
_a.sent();
|
|
175
|
-
_a.label = 3;
|
|
176
|
-
case 3:
|
|
177
|
-
i++;
|
|
178
|
-
return [3 /*break*/, 1];
|
|
179
|
-
case 4: return [2 /*return*/];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.processCompletedTask = function (completedTask, currentDelay, pageIndex, taskDataHolder) {
|
|
184
|
-
var _this = this;
|
|
185
|
-
var h = taskDataHolder;
|
|
186
|
-
var schema = null;
|
|
187
|
-
var result = null;
|
|
188
|
-
var schemaFetchCount = -1;
|
|
189
|
-
var task = completedTask.task;
|
|
190
|
-
try {
|
|
191
|
-
if (task.hasErrors) {
|
|
192
|
-
this.retryIndex(pageIndex, currentDelay);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
if (pageIndex == ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
|
|
196
|
-
result = task.result;
|
|
197
|
-
schemaFetchCount = (result['@odata.count']);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
result = task.result;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
catch (e) {
|
|
204
|
-
this.retryIndex(pageIndex, currentDelay);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (schemaFetchCount >= 0) {
|
|
208
|
-
this.actualCount = schemaFetchCount;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this.actualCount = (result['@odata.count']);
|
|
212
|
-
}
|
|
213
|
-
schema = this.actualSchema;
|
|
214
|
-
if (schema == null) {
|
|
215
|
-
var requests_1 = 0;
|
|
216
|
-
this.resolveSchema(function (s) {
|
|
217
|
-
// resolveSchema success callback
|
|
218
|
-
_this.actualSchema = s;
|
|
219
|
-
if (_this._isAggregationSupported && (_this._groupDescriptions.size() !== 0 || _this._summaryDescriptions.size() !== 0)) {
|
|
220
|
-
if (_this._groupDescriptions.size() > 0) {
|
|
221
|
-
requests_1++;
|
|
222
|
-
_this.resolveGroupInformation(function (g) {
|
|
223
|
-
// group info success
|
|
224
|
-
requests_1--;
|
|
225
|
-
if (requests_1 === 0) {
|
|
226
|
-
_this.finishProcessingCompletedTask(task, pageIndex, s, result);
|
|
227
|
-
}
|
|
228
|
-
}, function () {
|
|
229
|
-
// group info failure
|
|
230
|
-
_this.retryIndex(pageIndex, currentDelay);
|
|
231
|
-
return;
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
if (_this._summaryDescriptions.size() > 0) {
|
|
235
|
-
requests_1++;
|
|
236
|
-
_this.resolveSummaryInformation(function (g) {
|
|
237
|
-
// summary info success
|
|
238
|
-
requests_1--;
|
|
239
|
-
if (requests_1 === 0) {
|
|
240
|
-
_this.finishProcessingCompletedTask(task, pageIndex, s, result);
|
|
241
|
-
}
|
|
242
|
-
}, function () {
|
|
243
|
-
// summary info failure
|
|
244
|
-
_this.retryIndex(pageIndex, currentDelay);
|
|
245
|
-
return;
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
_this.finishProcessingCompletedTask(task, pageIndex, s, result);
|
|
251
|
-
}
|
|
252
|
-
}, function () {
|
|
253
|
-
// resolveSchema failure callback
|
|
254
|
-
_this.retryIndex(pageIndex, currentDelay);
|
|
255
|
-
return;
|
|
256
|
-
});
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
this.finishProcessingCompletedTask(task, pageIndex, schema, result);
|
|
260
|
-
};
|
|
261
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.finishProcessingCompletedTask = function (task, pageIndex, schema, result) {
|
|
262
|
-
var _this = this;
|
|
263
|
-
var executionContext;
|
|
264
|
-
var pageLoaded;
|
|
265
|
-
var groupInformation;
|
|
266
|
-
var summaryInformation;
|
|
267
|
-
this.actualSchema = schema;
|
|
268
|
-
executionContext = this.executionContext;
|
|
269
|
-
groupInformation = this._groupInformation;
|
|
270
|
-
summaryInformation = this._summaryInformation;
|
|
271
|
-
pageLoaded = this.pageLoaded;
|
|
272
|
-
var page = null;
|
|
273
|
-
if (result != null) {
|
|
274
|
-
page = new ODataDataSourcePage(result, schema, groupInformation, summaryInformation, pageIndex);
|
|
275
|
-
if (!this.isLastPage(pageIndex) && page.count() > 0 && !this.populatedActualPageSize) {
|
|
276
|
-
this.populatedActualPageSize = true;
|
|
277
|
-
this.actualPageSize = page.count();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
page = new ODataDataSourcePage(null, schema, groupInformation, summaryInformation, pageIndex);
|
|
282
|
-
}
|
|
283
|
-
if (this.pageLoaded != null) {
|
|
284
|
-
if (this.executionContext != null) {
|
|
285
|
-
if (executionContext == null || pageLoaded == null) {
|
|
286
|
-
this.shutdown();
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
executionContext.execute(function () { return pageLoaded(page, _this.actualCount, _this.actualPageSize); });
|
|
290
|
-
}
|
|
291
|
-
else {
|
|
292
|
-
if (pageLoaded == null) {
|
|
293
|
-
this.shutdown();
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
pageLoaded(page, this.actualCount, this.actualPageSize);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.resolveGroupInformation = function (finishAction, failureAction) {
|
|
301
|
-
var e_2, _a;
|
|
302
|
-
var _this = this;
|
|
303
|
-
if (this._groupInformation != null) {
|
|
304
|
-
finishAction(this._groupInformation);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
var orderBy = "";
|
|
308
|
-
var groupBy = "";
|
|
309
|
-
var filter = null;
|
|
310
|
-
var summary = "";
|
|
311
|
-
if (this._groupDescriptions == null || this._groupDescriptions.size() == 0) {
|
|
312
|
-
finishAction(null);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
filter = this._filterString;
|
|
316
|
-
this.updateFilterString();
|
|
317
|
-
if (this._groupDescriptions != null) {
|
|
318
|
-
var first1 = true;
|
|
319
|
-
try {
|
|
320
|
-
for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
321
|
-
var group = _c.value;
|
|
322
|
-
if (first1) {
|
|
323
|
-
first1 = false;
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
orderBy += ", ";
|
|
327
|
-
groupBy += ", ";
|
|
328
|
-
}
|
|
329
|
-
groupBy += group.propertyName;
|
|
330
|
-
if (group.direction === ListSortDirection.Descending) {
|
|
331
|
-
orderBy += group.propertyName + " desc";
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
orderBy += group.propertyName + " asc";
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
catch (e_2_1) {
|
|
339
|
-
e_2 = { error: e_2_1 };
|
|
340
|
-
}
|
|
341
|
-
finally {
|
|
342
|
-
try {
|
|
343
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
344
|
-
_a.call(_b);
|
|
345
|
-
}
|
|
346
|
-
finally {
|
|
347
|
-
if (e_2)
|
|
348
|
-
throw e_2.error;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (this._summaryScope === DataSourceSummaryScope.Both || this._summaryScope === DataSourceSummaryScope.Groups) {
|
|
353
|
-
var summaryParameters = this.getSummaryQueryParameters(true);
|
|
354
|
-
if (!stringIsNullOrEmpty(summaryParameters)) {
|
|
355
|
-
summary = ", " + summaryParameters;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
var commandText = this._entitySet + "?$orderby=" + orderBy + "&$apply=";
|
|
359
|
-
if (!stringIsNullOrEmpty(filter)) {
|
|
360
|
-
commandText += "filter(" + filter + ")/";
|
|
361
|
-
}
|
|
362
|
-
commandText += "groupby((" + groupBy + "), aggregate($count as $__count" + summary + "))";
|
|
363
|
-
try {
|
|
364
|
-
var groupInformation_1 = [];
|
|
365
|
-
var success_1 = function (data, response) { return _this.groupSuccess(data, response, finishAction, failureAction, groupInformation_1); };
|
|
366
|
-
var failure_1 = function (err) { return _this.groupError(err, finishAction, failureAction, groupInformation_1); };
|
|
367
|
-
var run_ = null;
|
|
368
|
-
var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
369
|
-
var request = {
|
|
370
|
-
requestUri: this._baseUri + "/" + commandText,
|
|
371
|
-
enableJsonpCallback: this._enableJsonp,
|
|
372
|
-
method: 'GET',
|
|
373
|
-
headers: headers,
|
|
374
|
-
data: null
|
|
375
|
-
};
|
|
376
|
-
run_ = function () {
|
|
377
|
-
odatajs.oData.request(request, success_1, failure_1);
|
|
378
|
-
};
|
|
379
|
-
run_();
|
|
380
|
-
}
|
|
381
|
-
catch (e) {
|
|
382
|
-
failureAction();
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.groupError = function (err, finishAction, failureAction, groupInformation) {
|
|
386
|
-
this._groupInformation = null;
|
|
387
|
-
};
|
|
388
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.groupSuccess = function (data, response, finishAction, failureAction, groupInformation) {
|
|
389
|
-
var e_3, _a;
|
|
390
|
-
var groupNames = [];
|
|
391
|
-
try {
|
|
392
|
-
for (var _b = __values(this.iter(this._groupDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
393
|
-
var group = _c.value;
|
|
394
|
-
groupNames.push(group.propertyName);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
catch (e_3_1) {
|
|
398
|
-
e_3 = { error: e_3_1 };
|
|
399
|
-
}
|
|
400
|
-
finally {
|
|
401
|
-
try {
|
|
402
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
403
|
-
_a.call(_b);
|
|
404
|
-
}
|
|
405
|
-
finally {
|
|
406
|
-
if (e_3)
|
|
407
|
-
throw e_3.error;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
var groupNamesArray = groupNames;
|
|
411
|
-
if (data && data.value && data.value.length > 0) {
|
|
412
|
-
var currentIndex = 0;
|
|
413
|
-
for (var i = 0; i < data.value.length; i++) {
|
|
414
|
-
this.addGroup(groupInformation, groupNames, groupNames, currentIndex, data.value[i]);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
this._groupInformation = groupInformation;
|
|
418
|
-
finishAction(this._groupInformation);
|
|
419
|
-
};
|
|
420
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.addGroup = function (groupInformation, groupNames, groupNamesArray, currentIndex, group) {
|
|
421
|
-
var e_4, _a;
|
|
422
|
-
var groupValues = [];
|
|
423
|
-
try {
|
|
424
|
-
for (var groupNames_1 = __values(groupNames), groupNames_1_1 = groupNames_1.next(); !groupNames_1_1.done; groupNames_1_1 = groupNames_1.next()) {
|
|
425
|
-
var name_1 = groupNames_1_1.value;
|
|
426
|
-
if (group[name_1]) {
|
|
427
|
-
groupValues.push(group[name_1]);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
catch (e_4_1) {
|
|
432
|
-
e_4 = { error: e_4_1 };
|
|
433
|
-
}
|
|
434
|
-
finally {
|
|
435
|
-
try {
|
|
436
|
-
if (groupNames_1_1 && !groupNames_1_1.done && (_a = groupNames_1.return))
|
|
437
|
-
_a.call(groupNames_1);
|
|
438
|
-
}
|
|
439
|
-
finally {
|
|
440
|
-
if (e_4)
|
|
441
|
-
throw e_4.error;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
var groupCount = 0;
|
|
445
|
-
if (group["$__count"]) {
|
|
446
|
-
groupCount = Convert.toInt321(group["$__count"]);
|
|
447
|
-
}
|
|
448
|
-
var summaryResults = null;
|
|
449
|
-
if (this._summaryScope == DataSourceSummaryScope.Both || this._summaryScope == DataSourceSummaryScope.Groups) {
|
|
450
|
-
summaryResults = this.createSummaryResults(group);
|
|
451
|
-
}
|
|
452
|
-
var groupInfo = new DefaultSectionInformation(currentIndex, currentIndex + (groupCount - 1), groupNamesArray, groupValues, summaryResults);
|
|
453
|
-
groupInformation.push(groupInfo);
|
|
454
|
-
};
|
|
455
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.resolveSummaryInformation = function (finishAction, failureAction) {
|
|
456
|
-
var _this = this;
|
|
457
|
-
if (this._summaryInformation != null) {
|
|
458
|
-
finishAction(this._summaryInformation);
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
var filter = null;
|
|
462
|
-
var summary = null;
|
|
463
|
-
if (this._summaryDescriptions == null ||
|
|
464
|
-
this._summaryDescriptions.size() == 0 ||
|
|
465
|
-
this._summaryScope == DataSourceSummaryScope.Groups ||
|
|
466
|
-
this._summaryScope == DataSourceSummaryScope.None) {
|
|
467
|
-
finishAction(null);
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
filter = this._filterString;
|
|
471
|
-
this.updateFilterString();
|
|
472
|
-
summary = this.getSummaryQueryParameters(false);
|
|
473
|
-
var commandText = this._entitySet + "?$apply=";
|
|
474
|
-
if (!stringIsNullOrEmpty(filter)) {
|
|
475
|
-
commandText += "filter(" + filter + ")/";
|
|
476
|
-
}
|
|
477
|
-
commandText += "aggregate(" + summary + ")";
|
|
478
|
-
try {
|
|
479
|
-
var summaryInformation_1 = [];
|
|
480
|
-
var success_2 = function (data, response) { return _this.summarySuccess(data, response, finishAction, failureAction, summaryInformation_1); };
|
|
481
|
-
var failure_2 = function (err) { return _this.summaryError(err, finishAction, failureAction, summaryInformation_1); };
|
|
482
|
-
var run_ = null;
|
|
483
|
-
var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
484
|
-
var request = {
|
|
485
|
-
requestUri: this._baseUri + "/" + commandText,
|
|
486
|
-
enableJsonpCallback: this._enableJsonp,
|
|
487
|
-
method: 'GET',
|
|
488
|
-
headers: headers,
|
|
489
|
-
data: null
|
|
490
|
-
};
|
|
491
|
-
run_ = function () {
|
|
492
|
-
odatajs.oData.request(request, success_2, failure_2);
|
|
493
|
-
};
|
|
494
|
-
run_();
|
|
495
|
-
}
|
|
496
|
-
catch (e) {
|
|
497
|
-
failureAction();
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.summarySuccess = function (data, response, finishAction, failureAction, summaryInformation) {
|
|
501
|
-
if (data && data.value && data.value.length > 0) {
|
|
502
|
-
summaryInformation = this.createSummaryResults(data.value[0]);
|
|
503
|
-
}
|
|
504
|
-
this._summaryInformation = summaryInformation;
|
|
505
|
-
finishAction(this._summaryInformation);
|
|
506
|
-
};
|
|
507
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.summaryError = function (err, finishAction, failureAction, summaryInformation) {
|
|
508
|
-
this._summaryInformation = null;
|
|
509
|
-
};
|
|
510
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.getSummaryQueryParameters = function (ignoreCount) {
|
|
511
|
-
var e_5, _a;
|
|
512
|
-
var result = "";
|
|
513
|
-
if (this._summaryDescriptions != null) {
|
|
514
|
-
var first = true;
|
|
515
|
-
var countExists = false;
|
|
516
|
-
try {
|
|
517
|
-
for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
518
|
-
var summary = _c.value;
|
|
519
|
-
if (summary.operand == DataSourceSummaryOperand.Count && (ignoreCount || countExists)) {
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
if (!first) {
|
|
523
|
-
result += ", ";
|
|
524
|
-
}
|
|
525
|
-
switch (summary.operand) {
|
|
526
|
-
case DataSourceSummaryOperand.Average:
|
|
527
|
-
result += summary.propertyName + " with average as " + summary.propertyName + "Average";
|
|
528
|
-
break;
|
|
529
|
-
case DataSourceSummaryOperand.Min:
|
|
530
|
-
result += summary.propertyName + " with min as " + summary.propertyName + "Min";
|
|
531
|
-
break;
|
|
532
|
-
case DataSourceSummaryOperand.Max:
|
|
533
|
-
result += summary.propertyName + " with max as " + summary.propertyName + "Max";
|
|
534
|
-
break;
|
|
535
|
-
case DataSourceSummaryOperand.Sum:
|
|
536
|
-
result += summary.propertyName + " with sum as " + summary.propertyName + "Sum";
|
|
537
|
-
break;
|
|
538
|
-
case DataSourceSummaryOperand.Count:
|
|
539
|
-
result += "$count as $__count";
|
|
540
|
-
countExists = true;
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
first = false;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
catch (e_5_1) {
|
|
547
|
-
e_5 = { error: e_5_1 };
|
|
548
|
-
}
|
|
549
|
-
finally {
|
|
550
|
-
try {
|
|
551
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
552
|
-
_a.call(_b);
|
|
553
|
-
}
|
|
554
|
-
finally {
|
|
555
|
-
if (e_5)
|
|
556
|
-
throw e_5.error;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return result;
|
|
561
|
-
};
|
|
562
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.createSummaryResults = function (data) {
|
|
563
|
-
var e_6, _a;
|
|
564
|
-
var summaryResults = [];
|
|
565
|
-
try {
|
|
566
|
-
for (var _b = __values(this.iterSummaries(this._summaryDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
567
|
-
var summary = _c.value;
|
|
568
|
-
var summaryName = summary.propertyName;
|
|
569
|
-
switch (summary.operand) {
|
|
570
|
-
case DataSourceSummaryOperand.Average:
|
|
571
|
-
summaryName += "Average";
|
|
572
|
-
break;
|
|
573
|
-
case DataSourceSummaryOperand.Min:
|
|
574
|
-
summaryName += "Min";
|
|
575
|
-
break;
|
|
576
|
-
case DataSourceSummaryOperand.Max:
|
|
577
|
-
summaryName += "Max";
|
|
578
|
-
break;
|
|
579
|
-
case DataSourceSummaryOperand.Sum:
|
|
580
|
-
summaryName += "Sum";
|
|
581
|
-
break;
|
|
582
|
-
case DataSourceSummaryOperand.Count:
|
|
583
|
-
summaryName = "$__count";
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
var summaryValue = null;
|
|
587
|
-
if (data && data[summaryName]) {
|
|
588
|
-
summaryValue = data[summaryName];
|
|
589
|
-
}
|
|
590
|
-
var summaryResult = new DefaultSummaryResult(summary.propertyName, summary.operand, summaryValue);
|
|
591
|
-
summaryResults.push(summaryResult);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
catch (e_6_1) {
|
|
595
|
-
e_6 = { error: e_6_1 };
|
|
596
|
-
}
|
|
597
|
-
finally {
|
|
598
|
-
try {
|
|
599
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
600
|
-
_a.call(_b);
|
|
601
|
-
}
|
|
602
|
-
finally {
|
|
603
|
-
if (e_6)
|
|
604
|
-
throw e_6.error;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
return summaryResults;
|
|
608
|
-
};
|
|
609
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.resolveSchema = function (finishAction, failureAction) {
|
|
610
|
-
var _this = this;
|
|
611
|
-
var success_ = function (res) {
|
|
612
|
-
var sp = new ODataSchemaProvider(res);
|
|
613
|
-
var schema = sp.getODataDataSourceSchema(_this._entitySet);
|
|
614
|
-
if (_this._schemaIncludedProperties != null) {
|
|
615
|
-
var propertyNames = [];
|
|
616
|
-
var propertyTypes = [];
|
|
617
|
-
for (var i = 0; i < schema.propertyNames.length; i++) {
|
|
618
|
-
if (!_this._schemaIncludedProperties.has(schema.propertyNames[i])) {
|
|
619
|
-
continue;
|
|
620
|
-
}
|
|
621
|
-
propertyNames.push(schema.propertyNames[i]);
|
|
622
|
-
propertyTypes.push(schema.propertyTypes[i]);
|
|
623
|
-
}
|
|
624
|
-
schema = new ODataDataSourceSchema(propertyNames, propertyTypes, schema.primaryKey);
|
|
625
|
-
}
|
|
626
|
-
finishAction(schema);
|
|
627
|
-
};
|
|
628
|
-
var failure_ = function () { return failureAction(); };
|
|
629
|
-
var baseUri_ = this._baseUri;
|
|
630
|
-
var request = new XMLHttpRequest();
|
|
631
|
-
request.onreadystatechange = function () {
|
|
632
|
-
if (request.readyState === 4) {
|
|
633
|
-
if (request.status === 200) {
|
|
634
|
-
success_(request.responseText);
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
failure_();
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
request.open('Get', baseUri_ + '/$metadata');
|
|
642
|
-
request.send();
|
|
643
|
-
;
|
|
644
|
-
};
|
|
645
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.makeTaskForRequest = function (request, retryDelay) {
|
|
646
|
-
var e_7, _a;
|
|
647
|
-
var actualPageSize = 0;
|
|
648
|
-
var sortDescriptions = null;
|
|
649
|
-
actualPageSize = this.actualPageSize;
|
|
650
|
-
sortDescriptions = this.sortDescriptions;
|
|
651
|
-
var requestUrl = this._baseUri;
|
|
652
|
-
requestUrl += "/" + this._entitySet;
|
|
653
|
-
var queryStarted = false;
|
|
654
|
-
this.updateFilterString();
|
|
655
|
-
if (this._filterString != null) {
|
|
656
|
-
if (!queryStarted) {
|
|
657
|
-
queryStarted = true;
|
|
658
|
-
requestUrl += "?";
|
|
659
|
-
}
|
|
660
|
-
else {
|
|
661
|
-
requestUrl += "&";
|
|
662
|
-
}
|
|
663
|
-
requestUrl += "$filter=" + this._filterString;
|
|
664
|
-
}
|
|
665
|
-
if (this.sortDescriptions != null) {
|
|
666
|
-
var sortString = null;
|
|
667
|
-
try {
|
|
668
|
-
for (var _b = __values(this.iter(this.sortDescriptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
669
|
-
var sort = _c.value;
|
|
670
|
-
if (sortString == null) {
|
|
671
|
-
sortString = "";
|
|
672
|
-
}
|
|
673
|
-
else {
|
|
674
|
-
sortString += ", ";
|
|
675
|
-
}
|
|
676
|
-
if (sort.direction == ListSortDirection.Descending) {
|
|
677
|
-
sortString += sort.propertyName + " desc";
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
sortString += sort.propertyName;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
catch (e_7_1) {
|
|
685
|
-
e_7 = { error: e_7_1 };
|
|
686
|
-
}
|
|
687
|
-
finally {
|
|
688
|
-
try {
|
|
689
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
690
|
-
_a.call(_b);
|
|
691
|
-
}
|
|
692
|
-
finally {
|
|
693
|
-
if (e_7)
|
|
694
|
-
throw e_7.error;
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
if (sortString != null) {
|
|
698
|
-
if (!queryStarted) {
|
|
699
|
-
queryStarted = true;
|
|
700
|
-
requestUrl += "?";
|
|
701
|
-
}
|
|
702
|
-
else {
|
|
703
|
-
requestUrl += "&";
|
|
704
|
-
}
|
|
705
|
-
requestUrl += "$orderby=" + sortString;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
if (this.desiredProperties != null && this.desiredProperties.length > 0) {
|
|
709
|
-
var selectString = "";
|
|
710
|
-
var first = true;
|
|
711
|
-
var $t = this.desiredProperties;
|
|
712
|
-
for (var i = 0; i < $t.length; i++) {
|
|
713
|
-
var select = $t[i];
|
|
714
|
-
if (first) {
|
|
715
|
-
first = false;
|
|
716
|
-
}
|
|
717
|
-
else {
|
|
718
|
-
selectString += ", ";
|
|
719
|
-
}
|
|
720
|
-
selectString += select;
|
|
721
|
-
}
|
|
722
|
-
if (!queryStarted) {
|
|
723
|
-
queryStarted = true;
|
|
724
|
-
requestUrl += "?";
|
|
725
|
-
}
|
|
726
|
-
else {
|
|
727
|
-
requestUrl += "&";
|
|
728
|
-
}
|
|
729
|
-
requestUrl += "$select=" + selectString;
|
|
730
|
-
}
|
|
731
|
-
var task = new AsyncVirtualDataTask();
|
|
732
|
-
if (request.index == ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex) {
|
|
733
|
-
this.executeRequest(requestUrl, queryStarted, 0, actualPageSize, task);
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
this.executeRequest(requestUrl, queryStarted, request.index * actualPageSize, actualPageSize, task);
|
|
737
|
-
}
|
|
738
|
-
request.taskHolder = new AsyncDataSourcePageTaskHolder();
|
|
739
|
-
request.taskHolder.task = task;
|
|
740
|
-
this.tasks.add(request);
|
|
741
|
-
};
|
|
742
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.updateFilterString = function () {
|
|
743
|
-
var e_8, _a;
|
|
744
|
-
if (this.filterExpressions != null && this.filterExpressions.size() > 0 && this._filterString == null) {
|
|
745
|
-
var sb = "";
|
|
746
|
-
var first = true;
|
|
747
|
-
try {
|
|
748
|
-
for (var _b = __values(this.iterFilter(this.filterExpressions)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
749
|
-
var expr = _c.value;
|
|
750
|
-
if (first) {
|
|
751
|
-
first = false;
|
|
752
|
-
}
|
|
753
|
-
else {
|
|
754
|
-
sb += " AND ";
|
|
755
|
-
}
|
|
756
|
-
var visitor = new ODataDataSourceFilterExpressionVisitor(0);
|
|
757
|
-
visitor.visit(expr);
|
|
758
|
-
var txt = visitor.toString();
|
|
759
|
-
if (this.filterExpressions.size() > 1) {
|
|
760
|
-
txt = "(" + txt + ")";
|
|
761
|
-
}
|
|
762
|
-
sb += (txt);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
catch (e_8_1) {
|
|
766
|
-
e_8 = { error: e_8_1 };
|
|
767
|
-
}
|
|
768
|
-
finally {
|
|
769
|
-
try {
|
|
770
|
-
if (_c && !_c.done && (_a = _b.return))
|
|
771
|
-
_a.call(_b);
|
|
772
|
-
}
|
|
773
|
-
finally {
|
|
774
|
-
if (e_8)
|
|
775
|
-
throw e_8.error;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
this._filterString = sb;
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.executeRequest = function (requestUrl, queryStarted, skip, top, task) {
|
|
782
|
-
var _this = this;
|
|
783
|
-
if (!queryStarted) {
|
|
784
|
-
queryStarted = true;
|
|
785
|
-
requestUrl += "?";
|
|
786
|
-
}
|
|
787
|
-
else {
|
|
788
|
-
requestUrl += "&";
|
|
789
|
-
}
|
|
790
|
-
requestUrl += "$skip=" + skip + "&$top=" + top + "&$count=true";
|
|
791
|
-
var requestUrl_ = requestUrl;
|
|
792
|
-
var self_ = this;
|
|
793
|
-
var success_ = function (data, response) { return _this.success(task, data, response); };
|
|
794
|
-
var failure_ = function (err) { return _this.error(task, err); };
|
|
795
|
-
var run_ = null;
|
|
796
|
-
var headers = { 'Content-Type': 'application/json', Accept: 'application/json' };
|
|
797
|
-
var request = {
|
|
798
|
-
requestUri: requestUrl_,
|
|
799
|
-
enableJsonpCallback: this._enableJsonp,
|
|
800
|
-
method: 'GET',
|
|
801
|
-
headers: headers,
|
|
802
|
-
data: null
|
|
803
|
-
};
|
|
804
|
-
run_ = function () {
|
|
805
|
-
odatajs.oData.request(request, success_, failure_);
|
|
806
|
-
};
|
|
807
|
-
task.run = run_;
|
|
808
|
-
};
|
|
809
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.success = function (t, data, response) {
|
|
810
|
-
t.result = data;
|
|
811
|
-
t.isCompleted = true;
|
|
812
|
-
};
|
|
813
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.error = function (t, result) {
|
|
814
|
-
t.isCompleted = true;
|
|
815
|
-
t.hasErrors = true;
|
|
816
|
-
};
|
|
817
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.createBatchRequest = function (changes) {
|
|
818
|
-
var requests = [];
|
|
819
|
-
for (var i = 0; i < changes.length; i++) {
|
|
820
|
-
var c = changes[i];
|
|
821
|
-
var headers = { "Content-Type": "application/json", "odata-version": "4.0" };
|
|
822
|
-
if (c.transactionType === TransactionType.Add) {
|
|
823
|
-
requests.push({
|
|
824
|
-
method: "POST",
|
|
825
|
-
id: "r".concat(i),
|
|
826
|
-
atomicityGroup: "g1",
|
|
827
|
-
url: "".concat(this._baseUri, "/").concat(this._entitySet),
|
|
828
|
-
headers: headers,
|
|
829
|
-
body: c.value,
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
else if (c.transactionType === TransactionType.Update) {
|
|
833
|
-
if (c.version) {
|
|
834
|
-
headers["If-Match"] = c.version;
|
|
835
|
-
}
|
|
836
|
-
requests.push({
|
|
837
|
-
method: "PATCH",
|
|
838
|
-
id: "r".concat(i),
|
|
839
|
-
atomicityGroup: "g1",
|
|
840
|
-
url: "".concat(this._baseUri, "/").concat(this.getRequestUriWithKey(c.id)),
|
|
841
|
-
headers: headers,
|
|
842
|
-
body: c.value,
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
else if (c.transactionType === TransactionType.Delete) {
|
|
846
|
-
if (c.version) {
|
|
847
|
-
headers["If-Match"] = c.version;
|
|
848
|
-
}
|
|
849
|
-
requests.push({
|
|
850
|
-
method: "DELETE",
|
|
851
|
-
id: "r".concat(i),
|
|
852
|
-
atomicityGroup: "g1",
|
|
853
|
-
url: "".concat(this._baseUri, "/").concat(this.getRequestUriWithKey(c.id)),
|
|
854
|
-
headers: headers,
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
var request = {
|
|
859
|
-
requestUri: "".concat(this._baseUri, "/$batch"),
|
|
860
|
-
method: "POST",
|
|
861
|
-
headers: { "Content-Type": "application/json" },
|
|
862
|
-
body: JSON.stringify({ requests: requests })
|
|
863
|
-
};
|
|
864
|
-
var self = this;
|
|
865
|
-
odatajs.oData.request(request, function (data) {
|
|
866
|
-
if (data && data.responses) {
|
|
867
|
-
if (data.responses.length > 0) {
|
|
868
|
-
var success = true;
|
|
869
|
-
var messages = [];
|
|
870
|
-
var _loop_1 = function (i) {
|
|
871
|
-
if (data.responses[i].status !== 200 &&
|
|
872
|
-
data.responses[i].status !== 204) {
|
|
873
|
-
success = false;
|
|
874
|
-
var failedRequest = requests.filter(function (r) { return r.id == data.responses[i].id; })[0];
|
|
875
|
-
if (failedRequest) {
|
|
876
|
-
var msg = "".concat(failedRequest.method, " request failed with code ").concat(data.responses[i].status);
|
|
877
|
-
messages.push(msg);
|
|
878
|
-
console.error(msg);
|
|
879
|
-
}
|
|
880
|
-
return "break";
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
for (var i = 0; i < data.responses.length; i++) {
|
|
884
|
-
var state_1 = _loop_1(i);
|
|
885
|
-
if (state_1 === "break")
|
|
886
|
-
break;
|
|
887
|
-
}
|
|
888
|
-
if (success) {
|
|
889
|
-
self.batchCompleted(true, true, null);
|
|
890
|
-
}
|
|
891
|
-
else {
|
|
892
|
-
self.batchCompleted(false, true, messages);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
self.batchCompleted(false, true, null);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}, function (error) {
|
|
900
|
-
var messages = [];
|
|
901
|
-
if (error && error.message) {
|
|
902
|
-
messages.push(error.message);
|
|
903
|
-
}
|
|
904
|
-
self.batchCompleted(false, true, messages);
|
|
905
|
-
});
|
|
906
|
-
};
|
|
907
|
-
ODataVirtualDataSourceDataProviderWorker.prototype.getRequestUriWithKey = function (key) {
|
|
908
|
-
var result = "";
|
|
909
|
-
var keys = Object.keys(key);
|
|
910
|
-
for (var i = 0; i < keys.length; i++) {
|
|
911
|
-
if (i > 0) {
|
|
912
|
-
result += ",";
|
|
913
|
-
}
|
|
914
|
-
result += "".concat(keys[i], "=").concat(key[keys[i]]);
|
|
915
|
-
}
|
|
916
|
-
return "".concat(this._entitySet, "(").concat(result, ")");
|
|
917
|
-
};
|
|
918
|
-
ODataVirtualDataSourceDataProviderWorker.schemaRequestIndex = -1;
|
|
919
|
-
return ODataVirtualDataSourceDataProviderWorker;
|
|
920
|
-
}(AsyncVirtualDataSourceProviderWorker));
|