@sap/xsodata 8.3.0 → 8.3.1
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/CHANGELOG.md +4 -0
- package/index.js +2 -2
- package/lib/configuration.js +1 -1
- package/lib/db/connect.js +1 -1
- package/lib/db/dbSegment.js +68 -123
- package/lib/db/dbVersionChecks.js +2 -8
- package/lib/handlerConfiguration.js +2 -2
- package/lib/http/conditionalHttpHandler.js +27 -34
- package/lib/http/simpleHttpRequest.js +14 -18
- package/lib/http/simpleHttpResponse.js +4 -4
- package/lib/http/uriParser.js +9 -9
- package/lib/http/validator/httpRequestValidator.js +9 -9
- package/lib/model/annotationFactory.js +11 -11
- package/lib/model/association.js +3 -3
- package/lib/model/entityType.js +33 -67
- package/lib/model/metadataReader.js +31 -52
- package/lib/model/model.js +0 -1
- package/lib/model/validator/xsoDataConcurrencyTokenValidator.js +6 -6
- package/lib/model/xsodataReader.js +36 -28
- package/lib/processor/authorizationProcessor.js +22 -33
- package/lib/processor/batchProcessor.js +22 -33
- package/lib/processor/errorProcessor.js +4 -4
- package/lib/processor/exitProcessor.js +19 -19
- package/lib/processor/processor.js +9 -9
- package/lib/processor/resourceProcessor.js +31 -61
- package/lib/processor/resourceProcessorDelete.js +16 -16
- package/lib/processor/resourceProcessorDeleteLinks.js +25 -25
- package/lib/processor/resourceProcessorGet.js +5 -5
- package/lib/processor/resourceProcessorPost.js +43 -45
- package/lib/processor/resourceProcessorPut.js +35 -39
- package/lib/processor/resourceProcessorPutPostLinks.js +38 -39
- package/lib/security/securityContext.js +5 -5
- package/lib/serializer/atomSerializer.js +54 -55
- package/lib/serializer/atomXmlToJsonSerializer.js +32 -44
- package/lib/serializer/content.js +5 -5
- package/lib/serializer/json.js +31 -33
- package/lib/serializer/jsonSerializer.js +4 -4
- package/lib/serializer/metadataSerializer.js +32 -35
- package/lib/serializer/serializer.js +29 -43
- package/lib/serializer/serviceSerializer.js +19 -24
- package/lib/serializer/value.js +1 -2
- package/lib/serializer/xmlToJsonSerializer.js +18 -18
- package/lib/sql/createDeleteLinksStatements.js +10 -10
- package/lib/sql/createDeleteStatements.js +12 -12
- package/lib/sql/createGetStatements.js +49 -107
- package/lib/sql/createLinksSQLStatements_1_n.js +27 -27
- package/lib/sql/createPutPostLinksStatements.js +9 -9
- package/lib/sql/createPutStatements.js +0 -1
- package/lib/sql/dataCollectorDelete.js +9 -9
- package/lib/sql/dataCollectorDeleteLinks.js +3 -3
- package/lib/sql/dataCollectorGet.js +9 -17
- package/lib/sql/dataCollectorLinks.js +23 -27
- package/lib/sql/dataCollectorPost.js +20 -20
- package/lib/sql/dataCollectorPut.js +36 -36
- package/lib/sql/dataCollectorPutPostLinks.js +3 -3
- package/lib/sql/sqlStatement.js +81 -128
- package/lib/sql/sqlTools.js +3 -7
- package/lib/sql/statementProcessor.js +7 -14
- package/lib/uri/applyChecks.js +3 -3
- package/lib/uri/checks/checkAllowedMethod.js +3 -3
- package/lib/uri/checks/checkAllowedMethodForBatch.js +2 -2
- package/lib/uri/checks/checkAllowedMethodsForResourcePath.js +3 -3
- package/lib/uri/checks/checkFilterOnAggregatedColumn.js +5 -5
- package/lib/uri/checks/checkFilterOrderByOnGenKeyColumn.js +6 -6
- package/lib/uri/checks/checkGenKeyRestrictions.js +2 -2
- package/lib/uri/checks/checkModificationForbidden.js +3 -3
- package/lib/uri/checks/checkPostPutDeleteChecks.js +5 -5
- package/lib/uri/checks/checkSystemQueryOptions.js +10 -10
- package/lib/uri/checks.js +15 -15
- package/lib/uri/expandSelectTreeBuilder.js +12 -16
- package/lib/uri/oDataUriParser.js +20 -20
- package/lib/uri/queryParameterParser.js +25 -33
- package/lib/uri/resourcePathParser.js +47 -62
- package/lib/uri/uriType.js +4 -4
- package/lib/utils/associations.js +4 -4
- package/lib/utils/batch/batchExecutor.js +49 -51
- package/lib/utils/batch/batchObjects.js +10 -10
- package/lib/utils/batch/batchParser.js +27 -28
- package/lib/utils/batch/batchWriter.js +1 -1
- package/lib/utils/checkContentType.js +34 -39
- package/lib/utils/debugView.js +35 -36
- package/lib/utils/errors/applicationError.js +2 -2
- package/lib/utils/errors/debugInfo.js +2 -2
- package/lib/utils/errors/http/badRequest.js +2 -2
- package/lib/utils/errors/http/forbidden.js +2 -2
- package/lib/utils/errors/http/methodNotAllowed.js +2 -2
- package/lib/utils/errors/http/notAcceptable.js +2 -2
- package/lib/utils/errors/http/notFound.js +2 -2
- package/lib/utils/errors/http/notImplemented.js +2 -2
- package/lib/utils/errors/http/notModified.js +2 -2
- package/lib/utils/errors/http/notSupported.js +2 -2
- package/lib/utils/errors/http/preconditionFailed.js +2 -2
- package/lib/utils/errors/http/preconditionRequired.js +2 -2
- package/lib/utils/errors/http/unauthorized.js +2 -2
- package/lib/utils/errors/http/unsupportedMediaType.js +2 -2
- package/lib/utils/errors/httpError.js +2 -2
- package/lib/utils/errors/internalError.js +2 -2
- package/lib/utils/errors/modelFileError.js +2 -2
- package/lib/utils/errors/sqlError.js +2 -2
- package/lib/utils/errors/testError.js +2 -2
- package/lib/utils/errors/typeError.js +5 -5
- package/lib/utils/errors/xsODataError.js +1 -1
- package/lib/utils/logger.js +21 -32
- package/lib/utils/measurement.js +14 -13
- package/lib/utils/requestContext.js +2 -2
- package/lib/utils/stateMaschine.js +6 -6
- package/lib/utils/tableCleanup.js +3 -3
- package/lib/utils/typeConverter.js +21 -21
- package/lib/utils/typeConverters/converterTools.js +25 -331
- package/lib/utils/typeConverters/dbToJson.js +3 -3
- package/lib/utils/typeConverters/dbToUri.js +7 -7
- package/lib/utils/typeConverters/dbToXml.js +9 -9
- package/lib/utils/typeConverters/jsonToDb.js +20 -27
- package/lib/utils/typeConverters/uriToDb.js +45 -92
- package/lib/utils/typeConverters/xmlValueToJson.js +9 -13
- package/lib/utils/typedObjects.js +11 -79
- package/lib/utils/utils.js +20 -23
- package/lib/xsodata.js +37 -47
- package/package.json +3 -5
- package/.npmignore +0 -40
package/lib/model/entityType.js
CHANGED
|
@@ -16,15 +16,15 @@ EntityType.entityKind = {
|
|
|
16
16
|
module.exports = EntityType;
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const utils = require('./../utils/utils');
|
|
20
|
+
const generatedKey = require('../utils/keyGenerator');
|
|
21
|
+
const typeConverter = require('./../utils/typeConverter');
|
|
22
|
+
const concurrencyTokenValidator = require('./../model/validator/xsoDataConcurrencyTokenValidator');
|
|
23
|
+
const annotationFactory = require('./annotationFactory');
|
|
24
|
+
const util = require('util');
|
|
25
25
|
|
|
26
26
|
// see https://help.sap.com/viewer/88fe5f56472e40cca6ef3c3dcab4855b/2.0.05/en-US/d336ea064c0948ffa3ef84dd516d69af.html
|
|
27
|
-
|
|
27
|
+
const CV_AGGREGATE_FUNCTIONS = {
|
|
28
28
|
1: "sum",
|
|
29
29
|
2: "count", // was avg before that was a bug
|
|
30
30
|
3: "min",
|
|
@@ -141,21 +141,7 @@ function prepareAdmindata(settingsAdmindata, entityTypeAdmindata) {
|
|
|
141
141
|
return ret;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
/*
|
|
145
|
-
EntityType.prototype.getName = function () {
|
|
146
|
-
return this.name;
|
|
147
|
-
};*/
|
|
148
|
-
|
|
149
144
|
EntityType.prototype.getUriName = function () {
|
|
150
|
-
/*
|
|
151
|
-
if (this._entityType.parameters) {
|
|
152
|
-
if (this._entityType.parameters.entity) {
|
|
153
|
-
return this._entityType.parameters.entity;
|
|
154
|
-
} else {
|
|
155
|
-
return this.name + 'Parameters';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
}*/
|
|
159
145
|
return this.name;
|
|
160
146
|
};
|
|
161
147
|
|
|
@@ -229,7 +215,7 @@ EntityType.prototype.getNavigation = function (propertyName) {
|
|
|
229
215
|
};
|
|
230
216
|
|
|
231
217
|
function determineKeys(entityType) {
|
|
232
|
-
|
|
218
|
+
const keys = {
|
|
233
219
|
names: entityType.keys || []
|
|
234
220
|
};
|
|
235
221
|
|
|
@@ -267,8 +253,7 @@ EntityType.prototype.calcKeyNamesOrdered = function () {
|
|
|
267
253
|
return;
|
|
268
254
|
}
|
|
269
255
|
|
|
270
|
-
for (
|
|
271
|
-
var propertyName = this.propertyNames[i];
|
|
256
|
+
for (const propertyName of this.propertyNames) {
|
|
272
257
|
if (this.keys.names.indexOf(propertyName) > -1) {
|
|
273
258
|
this.keyNamesOrdered.push(propertyName);
|
|
274
259
|
}
|
|
@@ -284,7 +269,7 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
|
|
|
284
269
|
this.kind = kind;
|
|
285
270
|
|
|
286
271
|
this.isInitialised = true;
|
|
287
|
-
|
|
272
|
+
let i;
|
|
288
273
|
|
|
289
274
|
/**
|
|
290
275
|
* List of this entities property names (according to with and without filter)
|
|
@@ -324,11 +309,11 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
|
|
|
324
309
|
this.converterMapToXMLPayload = {};
|
|
325
310
|
|
|
326
311
|
|
|
327
|
-
|
|
312
|
+
let dbColumns;
|
|
328
313
|
|
|
329
314
|
//fill propertyNames
|
|
330
|
-
|
|
331
|
-
|
|
315
|
+
let propertyName;
|
|
316
|
+
const withh = this._entityType.properties.with;
|
|
332
317
|
if (withh) {
|
|
333
318
|
dbColumns = this.__metadata.getColumnsMap();
|
|
334
319
|
for (i = 0; i < withh.length; i++) {
|
|
@@ -339,15 +324,15 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
|
|
|
339
324
|
this.propertiesMap[propertyName] = dbColumns[propertyName];
|
|
340
325
|
} else {
|
|
341
326
|
logger.error('Unknown property: ' + propertyName);
|
|
342
|
-
throw('Unknown property');
|
|
327
|
+
throw(new Error('Unknown property'));
|
|
343
328
|
}
|
|
344
329
|
}
|
|
345
330
|
} else {
|
|
346
331
|
dbColumns = this.__metadata.getColumns();
|
|
347
|
-
|
|
332
|
+
const without = this._entityType.properties.without;
|
|
348
333
|
//Loop over all existing columns
|
|
349
334
|
for (i = 0; i < dbColumns.length; i++) {
|
|
350
|
-
|
|
335
|
+
const column = dbColumns[i];
|
|
351
336
|
|
|
352
337
|
if (without && without.indexOf(column.COLUMN_NAME) > -1) {
|
|
353
338
|
continue;
|
|
@@ -363,8 +348,8 @@ EntityType.prototype.init = function (metadata, kind, tableStoreType, logger) {
|
|
|
363
348
|
this.resolveAggregates();
|
|
364
349
|
|
|
365
350
|
//
|
|
366
|
-
|
|
367
|
-
for (
|
|
351
|
+
const navigates = this._entityType.navigates;
|
|
352
|
+
for (const navName in navigates) {
|
|
368
353
|
if (navigates.hasOwnProperty(navName)) {
|
|
369
354
|
this.navPropertyNames.push(navName);
|
|
370
355
|
this.navProperties.push(navigates[navName]);
|
|
@@ -394,7 +379,7 @@ EntityType.prototype.addProperty = function (colProperty, isKey) {
|
|
|
394
379
|
this.propertiesMap[colProperty.COLUMN_NAME] = colProperty;
|
|
395
380
|
this._addConverter(colProperty);
|
|
396
381
|
if (isKey) {
|
|
397
|
-
|
|
382
|
+
const keys = this.keys || {};
|
|
398
383
|
keys.names.unshift(colProperty.COLUMN_NAME);
|
|
399
384
|
this.calcKeyNamesOrdered();
|
|
400
385
|
}
|
|
@@ -403,7 +388,7 @@ EntityType.prototype.addProperty = function (colProperty, isKey) {
|
|
|
403
388
|
EntityType.prototype.resolveAggregates = function () {
|
|
404
389
|
this._aggregates = this._entityType.aggregates;
|
|
405
390
|
if (this._aggregates && !Array.isArray(this._aggregates)) {
|
|
406
|
-
|
|
391
|
+
const _aggr_props = this.properties.filter(function (p) {
|
|
407
392
|
return !!p.aggregate;
|
|
408
393
|
});
|
|
409
394
|
this._aggregates = _aggr_props.map(function (p) {
|
|
@@ -421,16 +406,15 @@ EntityType.prototype.setCalculationViewDimensionData = function (rows, calcView,
|
|
|
421
406
|
|
|
422
407
|
this.calcView = calcView;
|
|
423
408
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
var new_propertiesMap = {};
|
|
409
|
+
const cv_propertiesMap = {};
|
|
410
|
+
const new_propertiesMap = {};
|
|
427
411
|
|
|
428
412
|
rows.forEach(function (row) {
|
|
429
413
|
cv_propertiesMap[row.COLUMN_NAME] = row;
|
|
430
414
|
});
|
|
431
415
|
|
|
432
416
|
this.properties.forEach(function (p) {
|
|
433
|
-
|
|
417
|
+
const cvp = cv_propertiesMap[p.COLUMN_NAME];
|
|
434
418
|
|
|
435
419
|
p.KIND = EntityType.entityKind.calculationView;
|
|
436
420
|
new_propertiesMap[p.COLUMN_NAME] = p;
|
|
@@ -447,19 +431,6 @@ EntityType.prototype.setCalculationViewDimensionData = function (rows, calcView,
|
|
|
447
431
|
}
|
|
448
432
|
});
|
|
449
433
|
|
|
450
|
-
/*
|
|
451
|
-
rows.forEach(function (row) {
|
|
452
|
-
var property = self.propertiesMap[row.COLUMN_NAME];
|
|
453
|
-
if (!property) {
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
property.aggregate = row.MEASURE_AGGREGATOR ? CV_AGGREGATE_FUNCTIONS[row.MEASURE_AGGREGATOR] : null;
|
|
457
|
-
property.KIND = EntityType.entityKind.calculationView;
|
|
458
|
-
cv_properties.push(property);
|
|
459
|
-
cv_propertiesMap[row.COLUMN_NAME] = property;
|
|
460
|
-
});
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
434
|
this.propertiesMap = new_propertiesMap;
|
|
464
435
|
};
|
|
465
436
|
|
|
@@ -471,20 +442,15 @@ EntityType.prototype.getParameters = function () {
|
|
|
471
442
|
return this._entityType.parameters;
|
|
472
443
|
};
|
|
473
444
|
|
|
474
|
-
/*
|
|
475
|
-
EntityType.prototype.getPropertyNames = function () {
|
|
476
|
-
return this.propertyNames;
|
|
477
|
-
};*/
|
|
478
|
-
|
|
479
445
|
EntityType.prototype._addGenKeyConverter = function () {
|
|
480
|
-
|
|
446
|
+
const genKey = this.keys.generatedKey;
|
|
481
447
|
if (genKey) {
|
|
482
448
|
this._addConverter(generatedKey.createGenKeyProperty(genKey));
|
|
483
449
|
}
|
|
484
450
|
};
|
|
485
451
|
|
|
486
452
|
EntityType.prototype.getKeysOrGenKey = function () {
|
|
487
|
-
|
|
453
|
+
const genKey = this.keys.generatedKey;
|
|
488
454
|
if (genKey) {
|
|
489
455
|
return [genKey];
|
|
490
456
|
}
|
|
@@ -493,8 +459,8 @@ EntityType.prototype.getKeysOrGenKey = function () {
|
|
|
493
459
|
};
|
|
494
460
|
|
|
495
461
|
EntityType.prototype.getPropertiesWithGenKey = function getPropertiesWithGenKey() {
|
|
496
|
-
|
|
497
|
-
|
|
462
|
+
const genKey = this.keys.generatedKey;
|
|
463
|
+
let properties = this.properties;
|
|
498
464
|
|
|
499
465
|
if (genKey) {
|
|
500
466
|
properties = [generatedKey.createGenKeyProperty(genKey)].concat(properties);
|
|
@@ -553,7 +519,7 @@ EntityType.prototype.getEntitySetAnnotations = function getEntitySetAnnotations(
|
|
|
553
519
|
* }
|
|
554
520
|
*/
|
|
555
521
|
EntityType.prototype.getPropertyAnnotations = function getPropertyAnnotations(propertyName) {
|
|
556
|
-
|
|
522
|
+
const property = this.getProperty(propertyName);
|
|
557
523
|
|
|
558
524
|
if (!property._annotations) {
|
|
559
525
|
property._annotations = annotationFactory.createPropertyAnnotations(this, property);
|
|
@@ -574,7 +540,7 @@ EntityType.prototype.getPropertyAnnotations = function getPropertyAnnotations(pr
|
|
|
574
540
|
* }
|
|
575
541
|
*/
|
|
576
542
|
EntityType.prototype.getNavigationPropertyAnnotations = function getNavigationPropertyAnnotations(navPropertyName) {
|
|
577
|
-
|
|
543
|
+
const navProperty = this.getNavigation(navPropertyName);
|
|
578
544
|
|
|
579
545
|
if (!navProperty._annotations) {
|
|
580
546
|
navProperty._annotations = annotationFactory.createNavigationPropertyAnnotations();
|
|
@@ -607,7 +573,7 @@ EntityType.prototype.getNavigationPropertyAnnotations = function getNavigationPr
|
|
|
607
573
|
* @throws {Error} if propertyName is empty or there is no property with the specified name in the entity type
|
|
608
574
|
*/
|
|
609
575
|
EntityType.prototype.getProperty = function getProperty(propertyName) {
|
|
610
|
-
|
|
576
|
+
let property;
|
|
611
577
|
|
|
612
578
|
if (!propertyName) {
|
|
613
579
|
throw new Error("Property name must be specified");
|
|
@@ -635,7 +601,7 @@ EntityType.prototype.getProperty = function getProperty(propertyName) {
|
|
|
635
601
|
* @returns {boolean} If the property has attr. DIMENSION_TYPE with is set if there is an entry in BIMC_DIMENSION_VIEW
|
|
636
602
|
*/
|
|
637
603
|
EntityType.prototype.isInBimcDimensionView = function isInBimcDimensionView(propertyName) {
|
|
638
|
-
|
|
604
|
+
const property = this.getProperty(propertyName);
|
|
639
605
|
if (!property) {
|
|
640
606
|
return false;
|
|
641
607
|
}
|
|
@@ -651,7 +617,7 @@ EntityType.prototype.isInBimcDimensionView = function isInBimcDimensionView(prop
|
|
|
651
617
|
* @returns {boolean} <code>true<code/> if the property is an aggregate property; otherwise - <code>false<code/>.
|
|
652
618
|
*/
|
|
653
619
|
EntityType.prototype.isAggregateProperty = function isAggregateProperty(propertyName) {
|
|
654
|
-
|
|
620
|
+
let property = this.getProperty(propertyName),
|
|
655
621
|
aggregates,
|
|
656
622
|
aggregate,
|
|
657
623
|
i;
|
|
@@ -692,7 +658,7 @@ function isMeasureProperty(property) {
|
|
|
692
658
|
* @returns {boolean} <code>true<code/> if the entity type has measure properties; otherwise - <code>false<code/>.
|
|
693
659
|
*/
|
|
694
660
|
EntityType.prototype.hasMeasureProperties = function hasMeasureProperties() {
|
|
695
|
-
|
|
661
|
+
let i,
|
|
696
662
|
property;
|
|
697
663
|
|
|
698
664
|
// only calculation views can have measure properties
|
|
@@ -25,7 +25,7 @@ const dataCollector2 = require('./../sql/dataCollector2');
|
|
|
25
25
|
function loadKeysForTable(context, entityType, cb) {
|
|
26
26
|
context.logger.silly('model', 'loadKeysForTable for entity ' + entityType.name);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
const processRows = function (err, rows) {
|
|
29
29
|
if (logMetadata) {
|
|
30
30
|
context.logger.silly('model', 'rows\n' + JSON.stringify(rows, null, 4));
|
|
31
31
|
}
|
|
@@ -60,7 +60,7 @@ function loadKeysForTable(context, entityType, cb) {
|
|
|
60
60
|
function loadTableInfo(context, entityType, tableStoreType, cb) {
|
|
61
61
|
context.logger.silly("model", "loadTableInfo");
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const processRows = function (err, rows) {
|
|
64
64
|
try {
|
|
65
65
|
if (logMetadata) {
|
|
66
66
|
context.logger.silly('model', 'rows\n' + JSON.stringify(rows, null, 4));
|
|
@@ -83,15 +83,15 @@ function loadTableInfo(context, entityType, tableStoreType, cb) {
|
|
|
83
83
|
return loadKeysForTable(context, entityType, cb);
|
|
84
84
|
}
|
|
85
85
|
} else {
|
|
86
|
-
|
|
86
|
+
const genKey = entityType.keys.generatedKey;
|
|
87
87
|
if (!genKey && entityType.keys.names.length === 0) {
|
|
88
88
|
return cb(new InternalError("Missing specification of keys for view.", context, null), context);
|
|
89
89
|
} else {
|
|
90
90
|
if (genKey) {
|
|
91
|
-
|
|
91
|
+
const overwrittenColumn = entityType.propertiesMap[entityType.keys.generatedKey];
|
|
92
92
|
if (!!overwrittenColumn) {
|
|
93
93
|
// Provided generated key overwrites an existing column
|
|
94
|
-
|
|
94
|
+
let msg = "Invalid generated key property '" + genKey + "'";
|
|
95
95
|
msg += " in definition '" + overwrittenColumn.TABLE_NAME + "'.";
|
|
96
96
|
msg += " The generated key would overwrite an existing property";
|
|
97
97
|
return cb(
|
|
@@ -179,7 +179,7 @@ function loadCalcViewInfo(context, entityType, cb) {
|
|
|
179
179
|
"where SCHEMA_NAME = ? AND QUALIFIED_NAME = ? " +
|
|
180
180
|
'order by "ORDER"';
|
|
181
181
|
|
|
182
|
-
function
|
|
182
|
+
const processRows = function (err, rows) {
|
|
183
183
|
if (logMetadata) {
|
|
184
184
|
context.logger.silly('metadataReader', 'rows\n' + JSON.stringify(rows, null, 4));
|
|
185
185
|
}
|
|
@@ -192,7 +192,7 @@ function loadCalcViewInfo(context, entityType, cb) {
|
|
|
192
192
|
return cb(null, null);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
const cubeName = rows[0].CUBE_NAME;
|
|
196
196
|
|
|
197
197
|
entityType.setCalculationViewDimensionData(rows, { cube: cubeName }, context.logger); // e.g. sap:label is fill with calculation view dimension data
|
|
198
198
|
entityType.resolveAggregates();
|
|
@@ -202,16 +202,16 @@ function loadCalcViewInfo(context, entityType, cb) {
|
|
|
202
202
|
// suppressing annotation "sap:aggregation-role" depends on xsodata-file "setting"
|
|
203
203
|
if (entityType._settings.noDimensionAnnoOnTextProperty && entityType._settings.noDimensionAnnoOnTextProperty === 'true') {
|
|
204
204
|
if (property.DESC_NAME && property.DESC_NAME !== property.COLUMN_NAME) {
|
|
205
|
-
for (
|
|
206
|
-
if (
|
|
207
|
-
|
|
205
|
+
for (const entityProperty of entityType.properties) {
|
|
206
|
+
if (entityProperty.COLUMN_NAME === property.DESC_NAME) {
|
|
207
|
+
entityProperty.suppressAnnotationDimension = true;
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
const parameters = entityType.getParameters();
|
|
215
215
|
if (!parameters) {
|
|
216
216
|
// entity not exposed as calcview
|
|
217
217
|
return cb(null, entityType);
|
|
@@ -225,8 +225,7 @@ function loadCalcViewInfo(context, entityType, cb) {
|
|
|
225
225
|
}
|
|
226
226
|
return cb(null, entityType);
|
|
227
227
|
});
|
|
228
|
-
|
|
229
|
-
}
|
|
228
|
+
};
|
|
230
229
|
|
|
231
230
|
/*
|
|
232
231
|
Example mapping :
|
|
@@ -296,10 +295,10 @@ function loadInputParameters(parameters, entityType, context, cb) {
|
|
|
296
295
|
});
|
|
297
296
|
|
|
298
297
|
try {
|
|
299
|
-
|
|
298
|
+
const paramEntityType = loadInputParametersEntity(parameters, entityType, context, rows);
|
|
300
299
|
if (parameters.viaKey) {
|
|
301
300
|
/*this is called */
|
|
302
|
-
loadInputParametersViaKey(entityType, paramEntityType
|
|
301
|
+
loadInputParametersViaKey(entityType, paramEntityType);
|
|
303
302
|
}
|
|
304
303
|
} catch (err_process) {
|
|
305
304
|
err = err_process;
|
|
@@ -312,7 +311,7 @@ function loadInputParameters(parameters, entityType, context, cb) {
|
|
|
312
311
|
|
|
313
312
|
|
|
314
313
|
function _getLength(columnSqlType) {
|
|
315
|
-
const n = columnSqlType.match(/^\w+\((
|
|
314
|
+
const n = columnSqlType.match(/^\w+\((\d+)\)$/);
|
|
316
315
|
if (n) {
|
|
317
316
|
return Number.parseInt(n[1]);
|
|
318
317
|
}
|
|
@@ -338,37 +337,17 @@ function _getType(type, defaultType = null) {
|
|
|
338
337
|
|
|
339
338
|
exports._getType = _getType;
|
|
340
339
|
|
|
341
|
-
/*
|
|
342
|
-
function _getTypeLengthScale(type, defaultType = null) {
|
|
343
|
-
if (type) {
|
|
344
|
-
const n = type.match(/^(\w+)(\(([0-9]+)(,([0-9]+))?\))?$/);
|
|
345
|
-
if (n) {
|
|
346
|
-
return {
|
|
347
|
-
type: n[1],
|
|
348
|
-
length: Number.parseInt(n[3]) || null,
|
|
349
|
-
scale : Number.parseInt(n[5]) || null
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
type: defaultType|| 'NVARCHAR',
|
|
355
|
-
length: null,
|
|
356
|
-
scale: null
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
*/
|
|
360
|
-
|
|
361
340
|
function loadInputParametersEntity(parameters, entityType, context, rows) {
|
|
362
|
-
|
|
341
|
+
let paramEntityName = parameters.entity;
|
|
363
342
|
if (!paramEntityName || paramEntityName.trim() === '') {
|
|
364
343
|
//No name, use default naming
|
|
365
344
|
paramEntityName = entityType.name + 'Parameters';
|
|
366
345
|
}
|
|
367
346
|
|
|
368
|
-
|
|
369
|
-
|
|
347
|
+
const resultsProp = parameters.resultProperty || 'Results';
|
|
348
|
+
let assocName = paramEntityName + '_to_' + entityType.name;
|
|
370
349
|
|
|
371
|
-
|
|
350
|
+
const _et = {
|
|
372
351
|
name: paramEntityName,
|
|
373
352
|
properties: {},
|
|
374
353
|
navigates: {},
|
|
@@ -385,10 +364,9 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
|
|
|
385
364
|
}
|
|
386
365
|
};
|
|
387
366
|
|
|
388
|
-
|
|
367
|
+
const paramEntityType = new EntityType(_et);
|
|
389
368
|
|
|
390
|
-
|
|
391
|
-
//const typeLengthScale = _getTypeLengthScale(row.COLUMN_SQL_TYPE, row.COLUMN_TYPE_D );
|
|
369
|
+
const mrows = rows.map(function (row) {
|
|
392
370
|
const type = _getType(row.COLUMN_SQL_TYPE, row.COLUMN_TYPE_D);
|
|
393
371
|
const metadata = {
|
|
394
372
|
KIND: model.entityKind.inputParameters,
|
|
@@ -410,7 +388,7 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
|
|
|
410
388
|
});
|
|
411
389
|
|
|
412
390
|
assocName = paramEntityName + '_to_' + entityType.name;
|
|
413
|
-
|
|
391
|
+
const association = new Association({
|
|
414
392
|
name: assocName,
|
|
415
393
|
principal: {
|
|
416
394
|
type: paramEntityName,
|
|
@@ -434,7 +412,7 @@ function loadInputParametersEntity(parameters, entityType, context, rows) {
|
|
|
434
412
|
|
|
435
413
|
|
|
436
414
|
function loadInputParametersViaKey(entityType, paramEntityType) {
|
|
437
|
-
|
|
415
|
+
const pvalues = _.values(paramEntityType.propertiesMap);
|
|
438
416
|
pvalues.forEach(function (pv) {
|
|
439
417
|
entityType.addProperty(pv, true);
|
|
440
418
|
});
|
|
@@ -611,7 +589,7 @@ function processSynonymTableType(context, entityType, tableName, callback) {
|
|
|
611
589
|
* @param {Function} callback - callback function, which is called when the operation is completed.
|
|
612
590
|
*/
|
|
613
591
|
function processTableType(error, dbRows, context, tableName, callback) {
|
|
614
|
-
|
|
592
|
+
let isColumnStoreType,
|
|
615
593
|
tableStoreType;
|
|
616
594
|
|
|
617
595
|
if (error) {
|
|
@@ -642,7 +620,7 @@ function createLockeEntityID(context, entityType) {
|
|
|
642
620
|
|
|
643
621
|
|
|
644
622
|
function loadEntityTypeOnce(context, entityType, cbErr) {
|
|
645
|
-
|
|
623
|
+
const lockEntityID = createLockeEntityID(context, entityType);
|
|
646
624
|
|
|
647
625
|
if (entityType.isInitialised) {
|
|
648
626
|
//access to __metadata is writelooked, so __metadata is definitively filled here
|
|
@@ -660,7 +638,7 @@ function loadEntityTypeOnce(context, entityType, cbErr) {
|
|
|
660
638
|
return cbErr();
|
|
661
639
|
}
|
|
662
640
|
|
|
663
|
-
|
|
641
|
+
const load = function (err, context) {
|
|
664
642
|
if (err) {
|
|
665
643
|
release();
|
|
666
644
|
return cbErr(err);
|
|
@@ -673,7 +651,7 @@ function loadEntityTypeOnce(context, entityType, cbErr) {
|
|
|
673
651
|
};
|
|
674
652
|
try {
|
|
675
653
|
if (Measurement.isActive()) {
|
|
676
|
-
|
|
654
|
+
const callConnect = utils.tryAndMeasure(db.connect, 'dbConnect');
|
|
677
655
|
return callConnect(context, load);
|
|
678
656
|
} else {
|
|
679
657
|
return db.connect(context, load);
|
|
@@ -689,16 +667,17 @@ exports.loadModelMetadata = function (context, asyncDone) {
|
|
|
689
667
|
|
|
690
668
|
context.logger.silly('model', 'load metadata');
|
|
691
669
|
|
|
692
|
-
|
|
670
|
+
const entityTypes = context.gModel.getEntityTypes();
|
|
671
|
+
let parent;
|
|
693
672
|
|
|
694
673
|
if (Measurement.isActive()) { // perform an explicit measurement
|
|
695
|
-
|
|
674
|
+
parent = Measurement.getRunningMeasurement();
|
|
696
675
|
}
|
|
697
676
|
|
|
698
677
|
async.mapSeries(
|
|
699
678
|
entityTypes,
|
|
700
679
|
function (entityType, cbMapLimit) {
|
|
701
|
-
|
|
680
|
+
let child;
|
|
702
681
|
try {
|
|
703
682
|
if (Measurement.isActive() && !context.batchContext) {
|
|
704
683
|
child = parent.newChild(entityType.name);
|
package/lib/model/model.js
CHANGED
|
@@ -36,7 +36,6 @@ let Model = function Model(xsodata) {
|
|
|
36
36
|
this._entityTypesMap = {};
|
|
37
37
|
this._entityTypesMapUriId = {};
|
|
38
38
|
|
|
39
|
-
//var entityTypeName = '';
|
|
40
39
|
for (property in this._service.entityTypes) {
|
|
41
40
|
if (this._service.entityTypes.hasOwnProperty(property)) {
|
|
42
41
|
let entityType = new EntityType(this._service.entityTypes[property], this._settings);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const lodash = require('lodash');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Exports the api
|
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
|
21
21
|
*/
|
|
22
22
|
function validate(context, callback) {
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const entityTypes = context.gModel._entityTypesMap;
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
27
|
validateDefaults(entityTypes);
|
|
@@ -88,7 +88,7 @@ function validateHasNotKeyPropertyTokenKey(entityTypes) {
|
|
|
88
88
|
|
|
89
89
|
findConcurrencyTokenConflicts(entityTypes, "keys.names", function (entityType, intersection) {
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
const isInvalidKey = entityType.hasConcurrentProperties() &&
|
|
92
92
|
entityType.isConcurrentProperty(entityType.keys.generatedKey);
|
|
93
93
|
|
|
94
94
|
if (isInvalidKey) {
|
|
@@ -120,9 +120,9 @@ function findConcurrencyTokenConflicts(entityTypes, comparableChildPropertyPath,
|
|
|
120
120
|
|
|
121
121
|
return lodash.chain(entityTypes)
|
|
122
122
|
.reduce(function (result, entityType) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
let comparableKeys;
|
|
124
|
+
let intersection;
|
|
125
|
+
let tokenKeys;
|
|
126
126
|
|
|
127
127
|
comparableKeys = lodash.chain(entityType).get(comparableChildPropertyPath).value();
|
|
128
128
|
if (comparableKeys && !Array.isArray(comparableKeys)) {
|