@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
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const jsonBuilder = require('./../serializer/json');
|
|
3
|
+
const contentTypeTools = require('./../utils/checkContentType');
|
|
4
|
+
const InternalError = require('./../utils/errors/internalError');
|
|
5
|
+
const AtomSerializer = require('./../serializer/atomSerializer');
|
|
6
|
+
const NotImplemented = require('./../utils/errors/http/notImplemented');
|
|
7
|
+
const odataUriType = require('../uri/uriType');
|
|
8
8
|
|
|
9
9
|
// Name of the URL parameter, which indicates that the service response should be in Atom format.
|
|
10
10
|
// This is a temporary solution, which is used until the OData content type negotiation is not implemented.
|
|
11
|
-
|
|
11
|
+
const CUSTOM_FORMAT_PARAMETER = "format";
|
|
12
12
|
|
|
13
13
|
// Value of the custom 'format' parameter, which indicates that the service response should be in Atom format.
|
|
14
|
-
|
|
14
|
+
const CUSTOM_ATOM_FORMAT_NAME = "atomXml";
|
|
15
15
|
|
|
16
16
|
exports.serializeNoContent = function (context, asyncDone) {
|
|
17
|
-
|
|
17
|
+
const responseHeaders = {};
|
|
18
18
|
|
|
19
19
|
addETagHeader(context, responseHeaders);
|
|
20
20
|
context.response.writeHead(204, responseHeaders);
|
|
@@ -25,13 +25,13 @@ exports.serializeNoContent = function (context, asyncDone) {
|
|
|
25
25
|
//Code
|
|
26
26
|
exports.serializeData = function (context, asyncDone) {
|
|
27
27
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const uriType = odataUriType.determineUriType(context);
|
|
29
|
+
const requestedType = getRequestedType(context);
|
|
30
|
+
const responseContentType = getResponseContentType(requestedType, context, uriType);
|
|
31
|
+
const serializer = getSerializer(requestedType, context);
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const responseBody = createResponseBody(context, uriType, serializer);
|
|
34
|
+
const responseHeaders = createResponseHeaders(context, responseContentType);
|
|
35
35
|
|
|
36
36
|
writeResponse(context, responseBody, responseHeaders);
|
|
37
37
|
return asyncDone(null, context);
|
|
@@ -41,11 +41,11 @@ exports.serializeData = function (context, asyncDone) {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
function createResponseHeaders(context, responseContentType) {
|
|
44
|
-
|
|
44
|
+
const headers = {
|
|
45
45
|
"Content-Type": responseContentType
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const cacheControl = getCacheControlHeader(context);
|
|
49
49
|
if (cacheControl) {
|
|
50
50
|
headers["cache-control"] = cacheControl;
|
|
51
51
|
}
|
|
@@ -56,7 +56,7 @@ function createResponseHeaders(context, responseContentType) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function addETagHeader(context, headers) {
|
|
59
|
-
|
|
59
|
+
const dbSegment = context.oData.dbSegmentLast;
|
|
60
60
|
|
|
61
61
|
if (dbSegment.etagHeader) {
|
|
62
62
|
headers.ETag = 'W/"' + dbSegment.etagHeader + '"';
|
|
@@ -76,9 +76,9 @@ function writeResponse(context, responseBody, responseHeaders) {
|
|
|
76
76
|
|
|
77
77
|
function getInlineCount(context) {
|
|
78
78
|
if (context.oData.systemQueryParameters.inlinecount === true) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const dbSegment = context.oData.dbSegmentLast;
|
|
80
|
+
const rows = dbSegment.getRowsWithGenKey();
|
|
81
|
+
const count = rows[0] && rows[0]['0count'] || dbSegment.sql.countRows[0] && dbSegment.sql.countRows[0]['c'];
|
|
82
82
|
return String(count);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -89,7 +89,7 @@ function getInlineCount(context) {
|
|
|
89
89
|
* @returns HTTP response body containing the serialized data.
|
|
90
90
|
*/
|
|
91
91
|
function createResponseBody(context, uriType, serializer) {
|
|
92
|
-
|
|
92
|
+
const dbSegment = context.oData.dbSegmentLast;
|
|
93
93
|
switch (uriType) {
|
|
94
94
|
case odataUriType.URI1:
|
|
95
95
|
case odataUriType.URI6B:
|
|
@@ -122,7 +122,7 @@ function getSerializer(contentType, context) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function getRequestedType(context) {
|
|
125
|
-
|
|
125
|
+
const customFormat = getCustomFormat(context);
|
|
126
126
|
if (customFormat && customFormat === CUSTOM_ATOM_FORMAT_NAME) {
|
|
127
127
|
return CUSTOM_ATOM_FORMAT_NAME;
|
|
128
128
|
}
|
|
@@ -131,9 +131,10 @@ function getRequestedType(context) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
function getResponseContentType(requestedType, context, uriType) {
|
|
134
|
-
|
|
134
|
+
let contentType;
|
|
135
135
|
switch (uriType) {
|
|
136
136
|
case odataUriType.URI1:
|
|
137
|
+
case odataUriType.URI7B:
|
|
137
138
|
case odataUriType.URI6B:
|
|
138
139
|
// custom 'format' parameter takes precedence over the $format option and the Accept header.
|
|
139
140
|
if (requestedType === CUSTOM_ATOM_FORMAT_NAME) {
|
|
@@ -143,6 +144,7 @@ function getResponseContentType(requestedType, context, uriType) {
|
|
|
143
144
|
}
|
|
144
145
|
break;
|
|
145
146
|
case odataUriType.URI2:
|
|
147
|
+
case odataUriType.URI7A:
|
|
146
148
|
case odataUriType.URI6A:
|
|
147
149
|
// custom 'format' parameter takes precedence over the $format option and the Accept header.
|
|
148
150
|
if (requestedType === CUSTOM_ATOM_FORMAT_NAME) {
|
|
@@ -157,22 +159,6 @@ function getResponseContentType(requestedType, context, uriType) {
|
|
|
157
159
|
case odataUriType.URI5B:
|
|
158
160
|
contentType = contentTypeTools.checkValue(context.request, requestedType);
|
|
159
161
|
break;
|
|
160
|
-
case odataUriType.URI7A:
|
|
161
|
-
// custom 'format' parameter takes precedence over the $format option and the Accept header.
|
|
162
|
-
if (requestedType === CUSTOM_ATOM_FORMAT_NAME) {
|
|
163
|
-
contentType = contentTypeTools.cTypes.ctAtomEntry;
|
|
164
|
-
} else {
|
|
165
|
-
contentType = contentTypeTools.checkEntry(context.request, requestedType);
|
|
166
|
-
}
|
|
167
|
-
break;
|
|
168
|
-
case odataUriType.URI7B:
|
|
169
|
-
// custom 'format' parameter takes precedence over the $format option and the Accept header.
|
|
170
|
-
if (requestedType === CUSTOM_ATOM_FORMAT_NAME) {
|
|
171
|
-
contentType = contentTypeTools.cTypes.ctAtomFeed;
|
|
172
|
-
} else {
|
|
173
|
-
contentType = contentTypeTools.checkFeed(context.request, requestedType);
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
162
|
case odataUriType.URI15:
|
|
177
163
|
case odataUriType.URI16:
|
|
178
164
|
contentType = contentTypeTools.checkCount(context.request, requestedType);
|
|
@@ -188,7 +174,7 @@ function getResponseContentType(requestedType, context, uriType) {
|
|
|
188
174
|
* Returns value of the custom 'format' URL parameter.
|
|
189
175
|
*/
|
|
190
176
|
function getCustomFormat(context) {
|
|
191
|
-
|
|
177
|
+
const queryParameters = context.uriTree.queryParameters;
|
|
192
178
|
if (queryParameters) {
|
|
193
179
|
return queryParameters[CUSTOM_FORMAT_PARAMETER];
|
|
194
180
|
}
|
|
@@ -198,8 +184,8 @@ function serializePropertyValue(dbSeg) {
|
|
|
198
184
|
if (dbSeg.sql.rows.length > 1) {
|
|
199
185
|
throw new InternalError('To many rows for serializing a property');
|
|
200
186
|
}
|
|
201
|
-
|
|
202
|
-
|
|
187
|
+
const property = dbSeg.singleProperty;
|
|
188
|
+
let converter;
|
|
203
189
|
|
|
204
190
|
converter = dbSeg.entityType.__metadata.converterMapToXMLPayload[property];
|
|
205
191
|
return converter(dbSeg.sql.rows[0][property]);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const XMLWriter = require('xml-writer');
|
|
4
|
+
const jsonSerializer = require('./../serializer/jsonSerializer');
|
|
5
|
+
const types = require('./../utils/checkContentType');
|
|
6
|
+
const contentTypeTools = require('./../utils/checkContentType');
|
|
7
|
+
const NotAcceptable = require('./../utils/errors/http/notAcceptable');
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const Measurement = require('./../utils/measurement');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
function writeXML(request, response, context) {
|
|
13
|
-
|
|
13
|
+
const writer = function writer(string) {
|
|
14
14
|
response.write(string);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const xw = new XMLWriter(true, writer);//change to false for unformatted output
|
|
18
18
|
xw.startDocument('1.0', 'utf-8', true);
|
|
19
19
|
xw.startElement('service');
|
|
20
20
|
|
|
@@ -28,10 +28,10 @@ function writeXML(request, response, context) {
|
|
|
28
28
|
xw.text('Default');
|
|
29
29
|
xw.endElement();
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
for (
|
|
31
|
+
const entityTypes = context.gModel.getEntityTypes();
|
|
32
|
+
for (const name in entityTypes) {
|
|
33
33
|
if (entityTypes.hasOwnProperty(name)) {
|
|
34
|
-
|
|
34
|
+
const entityType = entityTypes[name];
|
|
35
35
|
xw.startElement('collection');
|
|
36
36
|
xw.writeAttribute('href', entityType.name);
|
|
37
37
|
xw.startElement('atom:title');
|
|
@@ -46,14 +46,14 @@ function writeXML(request, response, context) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function writeJSON(request, response, context) {
|
|
49
|
-
|
|
49
|
+
const serializer = new jsonSerializer.JsonSerializer(context, 65536);
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const entityTypes = context.gModel.getEntityTypes();
|
|
52
|
+
const d = {'EntitySets': []};
|
|
53
53
|
|
|
54
|
-
for (
|
|
54
|
+
for (const name in entityTypes) {
|
|
55
55
|
if (entityTypes.hasOwnProperty(name)) {
|
|
56
|
-
|
|
56
|
+
const entityType = entityTypes[name];
|
|
57
57
|
d.EntitySets.push(entityType.name);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -63,14 +63,9 @@ function writeJSON(request, response, context) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
exports.process = function (context, asyncDone) {
|
|
66
|
-
|
|
66
|
+
const method = context.request.method;
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
case "HEAD":
|
|
70
|
-
return processHEAD(context, asyncDone);
|
|
71
|
-
default:
|
|
72
|
-
return processGET(context, asyncDone);
|
|
73
|
-
}
|
|
68
|
+
return method === "HEAD" ? processHEAD(context, asyncDone) : processGET(context, asyncDone);
|
|
74
69
|
};
|
|
75
70
|
|
|
76
71
|
function processHEAD(context, asyncDone) {
|
|
@@ -81,7 +76,7 @@ function processHEAD(context, asyncDone) {
|
|
|
81
76
|
|
|
82
77
|
|
|
83
78
|
function processGET(context, asyncDone) {
|
|
84
|
-
|
|
79
|
+
let request, response, format;
|
|
85
80
|
context.logger.silly('serviceprocessor', 'process');
|
|
86
81
|
|
|
87
82
|
request = context.request;
|
package/lib/serializer/value.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports.ValueSerializer = ValueSerializer;
|
|
4
4
|
|
|
5
5
|
function ValueSerializer(context, bufferSize) {
|
|
6
|
-
|
|
6
|
+
const self = this;
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -13,7 +13,6 @@ function ValueSerializer(context, bufferSize) {
|
|
|
13
13
|
self.bufferSize = bufferSize;
|
|
14
14
|
self.buffer = '';
|
|
15
15
|
|
|
16
|
-
//self.response.writeHead(200, {'Content-Type': 'text/plain;charset=utf-8'});
|
|
17
16
|
self.response.writeHead(200, {'Content-Type': context.payloadType + ';charset=utf-8'});
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* const xmlStringData = getXmlStringSomeHow().toString('utf-8');
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* const serializer = new XmlToJsonSerializer(xmlStringData, {
|
|
13
13
|
* logger:logger
|
|
14
14
|
* });
|
|
15
15
|
*
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const lodash = require('lodash');
|
|
25
|
+
const async = require('async');
|
|
26
|
+
const utils = require('./../utils/utils');
|
|
27
|
+
const parser = require('./../parsers/xml2JsonParser');
|
|
28
28
|
|
|
29
29
|
module.exports = XmlToJsonSerializer;
|
|
30
30
|
|
|
@@ -112,12 +112,12 @@ XmlToJsonSerializer.prototype.after = function after(fn) {
|
|
|
112
112
|
*/
|
|
113
113
|
XmlToJsonSerializer.prototype.serialize = function serialize(done) {
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
const source = this._input;
|
|
116
|
+
const before = this._middlewares.before;
|
|
117
|
+
const after = this._middlewares.after;
|
|
118
|
+
const context = buildInnerContext(source);
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
const tasks = [utils.injectContext(context)]
|
|
121
121
|
.concat(before)
|
|
122
122
|
.concat([utils.try(parseContextSource)])
|
|
123
123
|
.concat(after);
|
|
@@ -156,7 +156,7 @@ function buildInnerContext(source) {
|
|
|
156
156
|
*/
|
|
157
157
|
function parseContextSource(context, asyncDone) {
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
const source = context.source;
|
|
160
160
|
|
|
161
161
|
try {
|
|
162
162
|
context.result = parser.parse(source);
|
|
@@ -220,8 +220,8 @@ function map(sourcePath, targetPath, options) {
|
|
|
220
220
|
|
|
221
221
|
return function _mapFn(context, asyncDone) {
|
|
222
222
|
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
let source = context.result;
|
|
224
|
+
let target = context.result;
|
|
225
225
|
|
|
226
226
|
// Source object can be provided from outside
|
|
227
227
|
if (options && typeof options.source === "function") {
|
|
@@ -240,7 +240,7 @@ function map(sourcePath, targetPath, options) {
|
|
|
240
240
|
projectProperty(source, sourcePath, targetPath, target);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
if (options && typeof options.overwrite === true) {
|
|
243
|
+
if (options && typeof options.overwrite === "boolean" && options.overwrite === true) {
|
|
244
244
|
context.result = target;
|
|
245
245
|
}
|
|
246
246
|
|
|
@@ -265,7 +265,7 @@ function map(sourcePath, targetPath, options) {
|
|
|
265
265
|
*/
|
|
266
266
|
XmlToJsonSerializer.prototype.mapBefore = function mapBefore(sourcePath, targetPath, options) {
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
const mapFn = map(sourcePath, targetPath, options);
|
|
269
269
|
return this.before(mapFn);
|
|
270
270
|
|
|
271
271
|
};
|
|
@@ -286,7 +286,7 @@ XmlToJsonSerializer.prototype.mapBefore = function mapBefore(sourcePath, targetP
|
|
|
286
286
|
*/
|
|
287
287
|
XmlToJsonSerializer.prototype.mapAfter = function mapAfter(sourcePath, targetPath, options) {
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
const mapFn = map(sourcePath, targetPath, options);
|
|
290
290
|
return this.after(mapFn);
|
|
291
291
|
|
|
292
292
|
};
|
|
@@ -302,7 +302,7 @@ XmlToJsonSerializer.prototype.mapAfter = function mapAfter(sourcePath, targetPat
|
|
|
302
302
|
*/
|
|
303
303
|
function projectProperty(source, sourcePath, targetPath, target) {
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
const sourceValue = lodash.get(source, sourcePath);
|
|
306
306
|
lodash.set(target, targetPath, sourceValue);
|
|
307
307
|
|
|
308
308
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const linksSQL = require ('./createLinksSQLStatements_1_n');
|
|
4
|
+
const sql = require('./sqlStatement');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
exports.createDeleteLinksStatementsCreateTmpTables = function (context, asyncDone) {
|
|
@@ -16,7 +16,7 @@ exports.createDeleteLinksStatementsInsert = function (context, asyncDone) {
|
|
|
16
16
|
/******************** MxN relationships ***********************/
|
|
17
17
|
|
|
18
18
|
exports.createDeleteLinksMNStatementsCreateTmpTables = function (context, asyncDone) {
|
|
19
|
-
|
|
19
|
+
const dbSegLast = context.oData.dbSegmentLast,
|
|
20
20
|
sqlContext = linksSQL.createMNSQLContext(context, dbSegLast);
|
|
21
21
|
|
|
22
22
|
context.sql = sqlContext;
|
|
@@ -44,7 +44,7 @@ function createMNDeleteStatementContainerCreateTmpTables(sqlContext) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function createMNDeleteStatementContainerInsert(sqlContext) {
|
|
47
|
-
|
|
47
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
48
48
|
|
|
49
49
|
linksSQL.createMNStatementContainerInsert(sqlContext);
|
|
50
50
|
|
|
@@ -52,19 +52,19 @@ function createMNDeleteStatementContainerInsert(sqlContext) {
|
|
|
52
52
|
dbSeg.sql.stmContainer.insertTmp = masterMNTableInsertToDel(sqlContext, dbSeg.sql.rId);
|
|
53
53
|
|
|
54
54
|
//create insert statement for master table
|
|
55
|
-
dbSeg.sql.stmContainer.delete = masterMNTableDelete(sqlContext
|
|
55
|
+
dbSeg.sql.stmContainer.delete = masterMNTableDelete(sqlContext);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function masterMNTableInsertToDel(sqlContext, rId) {
|
|
59
59
|
sqlContext.context.logger.debug('createDeleteLinksStatements', 'masterMNTableInsertToDel');
|
|
60
|
-
|
|
60
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
const subSelect = new sql.Select();
|
|
63
63
|
subSelect.addSelects(dbSeg.getSelectFragmentsForOverProperties(''));
|
|
64
64
|
subSelect.setFrom( {table: dbSeg.getOver().object} );
|
|
65
65
|
subSelect.addWhereKeyValuePairs(dbSeg.getOverPropertiesWithValues());
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
const stm = new sql.Insert();
|
|
68
68
|
stm.setTableName({table: rId});
|
|
69
69
|
stm.setSubSelect(subSelect);
|
|
70
70
|
|
|
@@ -73,9 +73,9 @@ function masterMNTableInsertToDel(sqlContext, rId) {
|
|
|
73
73
|
|
|
74
74
|
function masterMNTableDelete(sqlContext) {
|
|
75
75
|
sqlContext.context.logger.debug('createDeleteLinksStatements', 'masterMNTableDelete');
|
|
76
|
-
|
|
76
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
const deleteStmt = new sql.Delete();
|
|
79
79
|
deleteStmt.setFrom( {table: dbSeg.getOver().object} );
|
|
80
80
|
|
|
81
81
|
deleteStmt.addWhereKeyValuePairs(dbSeg.getOverPropertiesWithValues());
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const sql = require('./sqlStatement');
|
|
4
|
+
const sqlTools = require('./sqlTools');
|
|
5
5
|
|
|
6
6
|
exports.createDeleteStatementsForCreateTmpTables = function (context, asyncDone) {
|
|
7
|
-
|
|
7
|
+
const dbSegLast = context.oData.dbSegmentLast;
|
|
8
8
|
|
|
9
9
|
context.logger.silly('createDeleteStatements', 'createDeleteStatementsForCreateTmpTables');
|
|
10
10
|
|
|
@@ -39,7 +39,7 @@ exports.createDeleteStatementsForDelete = function (context, asyncDone) {
|
|
|
39
39
|
* @param sqlContext
|
|
40
40
|
*/
|
|
41
41
|
function startDeleteMasterDbSegForCreate(sqlContext) {
|
|
42
|
-
|
|
42
|
+
const dbSeg = sqlContext.dbSegLast,
|
|
43
43
|
stmtContainer = dbSeg.sql.stmContainer;
|
|
44
44
|
|
|
45
45
|
sqlContext.context.sql.container = stmtContainer;
|
|
@@ -62,7 +62,7 @@ function startDeleteMasterDbSegForCreate(sqlContext) {
|
|
|
62
62
|
* @param sqlContext
|
|
63
63
|
*/
|
|
64
64
|
function startDeleteMasterDbSegForDelete(sqlContext) {
|
|
65
|
-
|
|
65
|
+
const dbSeg = sqlContext.dbSegLast,
|
|
66
66
|
stmtContainer = dbSeg.sql.stmContainer;
|
|
67
67
|
|
|
68
68
|
sqlContext.context.sql.container = stmtContainer;
|
|
@@ -93,8 +93,8 @@ function startDeleteMasterDbSegForDelete(sqlContext) {
|
|
|
93
93
|
|
|
94
94
|
function masterTableCreate(sqlContext, rId) {
|
|
95
95
|
sqlContext.context.logger.debug('createPostStatements', 'masterTableCreate (ordered selects)');
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
97
|
+
const stmCreate = new sql.Create();
|
|
98
98
|
stmCreate.setModifiers(['local', 'temporary', dbSeg.entityType.tableStoreType]);
|
|
99
99
|
stmCreate.setTableName(rId);
|
|
100
100
|
|
|
@@ -109,9 +109,9 @@ function masterTableCreate(sqlContext, rId) {
|
|
|
109
109
|
|
|
110
110
|
function masterTableInsertToDel(sqlContext, rIdOld) {
|
|
111
111
|
sqlContext.context.logger.debug('createDeleteStatements', 'masterTableInsertToDel (ordered selects)');
|
|
112
|
-
|
|
112
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
const subSelect = new sql.Select();
|
|
115
115
|
|
|
116
116
|
if (dbSeg.entityType.kind === 3 && dbSeg.entityType._entityType.parameters && dbSeg.entityType._entityType.parameters.viaKey === true) {
|
|
117
117
|
subSelect.addSelects(dbSeg.getPropertiesForSelect());
|
|
@@ -127,7 +127,7 @@ function masterTableInsertToDel(sqlContext, rIdOld) {
|
|
|
127
127
|
subSelect.addWhereKeyValuePairs(dbSeg.getQKeyWithValuesDB());
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
const stm = new sql.Insert();
|
|
131
131
|
stm.setTableName({ table: rIdOld });
|
|
132
132
|
stm.setSubSelect(subSelect);
|
|
133
133
|
|
|
@@ -142,9 +142,9 @@ function masterTableInsertToDel(sqlContext, rIdOld) {
|
|
|
142
142
|
*/
|
|
143
143
|
function masterTableDelete(sqlContext) {
|
|
144
144
|
sqlContext.context.logger.debug('createDeleteStatements', 'masterTableDelete');
|
|
145
|
-
|
|
145
|
+
const dbSeg = sqlContext.dbSegLast;
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
const delete1 = new sql.Delete();
|
|
148
148
|
delete1.setFrom(dbSeg.getAliasedTableName());
|
|
149
149
|
delete1.addWhereKeyValuePairs(dbSeg.getQKeyWithValues());
|
|
150
150
|
|