@manyos/smileconnect-api 1.63.4 → 1.64.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/app.js +11 -3
- package/conf/clients.json +8 -33
- package/controller/cmdbobjectController.js +2 -2
- package/controller/customFormController.js +1 -1
- package/controller/eventLogController.js +6 -8
- package/controller/orgdataController.js +1 -1
- package/controller/relatedObjectsController.js +3 -1
- package/controller/scriptController.js +2 -2
- package/controller/taskController.js +2 -2
- package/controller/templateController.js +1 -1
- package/controller/ticketCIRelationController.js +31 -22
- package/controller/ticketController.js +26 -22
- package/controller/ticketWorkLogController.js +1 -1
- package/docs/releases.md +7 -0
- package/package.json +1 -1
- package/routes/appConfigRoutes.js +13 -7
- package/routes/ciRelationRoutes.js +1 -1
- package/routes/cmdbObjectRoutes.js +1 -1
- package/routes/customFormRoutes.js +1 -1
- package/routes/organisationRoutes.js +1 -1
- package/routes/peopleRelationRoutes.js +1 -1
- package/routes/personRoutes.js +1 -1
- package/routes/scriptRoutes.js +1 -1
- package/routes/supportgroupRoutes.js +1 -1
- package/routes/taskRoutes.js +1 -1
- package/routes/templateRoutes.js +1 -1
- package/routes/ticketRoutes.js +16 -6
- package/routes/ticketWorkLogRoutes.js +1 -1
- package/test/changeTest.js +2 -2
- package/test/incidentTest.js +2 -2
- package/test/problemTest.js +2 -2
- package/test/workorderTest.js +2 -2
- package/util/arquery.js +16 -5
- package/util/auth.js +1 -1
- package/util/cache.service.js +1 -1
- package/util/config.js +1 -1
- package/util/eventLog.js +16 -0
- package/util/mappingUtil.js +11 -7
- package/util/paramHelper.js +1 -1
- package/util/relationUtil.js +1 -1
- package/util/responsehandler.js +11 -3
- package/util/searchUtil.js +1 -1
- package/util/ticketValidationUtil.js +1 -1
- package/screwdriver.yaml +0 -52
package/app.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const app = require('express')();
|
|
3
3
|
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const log = require('@manyos/logger').setupLog('
|
|
5
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
6
6
|
|
|
7
7
|
const passport = require('passport');
|
|
8
8
|
const JwtStrategy = require('passport-jwt').Strategy,
|
|
@@ -202,6 +202,12 @@ app.use(fileUpload({
|
|
|
202
202
|
debug: true
|
|
203
203
|
}));
|
|
204
204
|
|
|
205
|
+
//add initial logger
|
|
206
|
+
app.use(function (req, res, next) {
|
|
207
|
+
req.log = log.child({requestId: req.id});
|
|
208
|
+
next();
|
|
209
|
+
});
|
|
210
|
+
|
|
205
211
|
//global check for compatibility
|
|
206
212
|
app.use(function (req, res, next) {
|
|
207
213
|
if (req.query.include && req.query.includeObjects) {
|
|
@@ -268,9 +274,11 @@ app.use(function (req, res, next) {
|
|
|
268
274
|
app.use(function (req, res, next) {
|
|
269
275
|
req.globalScriptParams = {
|
|
270
276
|
query: req.query,
|
|
271
|
-
user: req.user
|
|
272
|
-
log: log.child({req_id: req.id, clientId:req.clientId}, true)
|
|
277
|
+
user: req.user
|
|
273
278
|
}
|
|
279
|
+
req.log = req.log.child({
|
|
280
|
+
clientId: req.clientId
|
|
281
|
+
});
|
|
274
282
|
// Für Scripte einen globalen parameter bereitstellen, der den org. Body enthält. Damit hat man auch noch in Post Scripten Zugriff auf customAttributes die beim Mapping entfernt werden.
|
|
275
283
|
if (req.body) {
|
|
276
284
|
try {
|
package/conf/clients.json
CHANGED
|
@@ -1989,7 +1989,6 @@
|
|
|
1989
1989
|
"clientLimit": 100000,
|
|
1990
1990
|
"impersonateUser": "rhannemann",
|
|
1991
1991
|
"allowDynamicImpersonate": true,
|
|
1992
|
-
"translateSelectionFieldsX": false,
|
|
1993
1992
|
"translateSelectionFields": true
|
|
1994
1993
|
},
|
|
1995
1994
|
"custom_Sample:Enrollments": {
|
|
@@ -2101,9 +2100,7 @@
|
|
|
2101
2100
|
},
|
|
2102
2101
|
"PUT": {
|
|
2103
2102
|
"preMapping": [],
|
|
2104
|
-
"postMapping": [
|
|
2105
|
-
"notfetchresult"
|
|
2106
|
-
]
|
|
2103
|
+
"postMapping": []
|
|
2107
2104
|
}
|
|
2108
2105
|
}
|
|
2109
2106
|
},
|
|
@@ -2299,9 +2296,7 @@
|
|
|
2299
2296
|
},
|
|
2300
2297
|
"PUT": {
|
|
2301
2298
|
"preMapping": [],
|
|
2302
|
-
"postMapping": [
|
|
2303
|
-
"notFetchResult"
|
|
2304
|
-
],
|
|
2299
|
+
"postMapping": [],
|
|
2305
2300
|
"afterExecution": []
|
|
2306
2301
|
},
|
|
2307
2302
|
"POST": {
|
|
@@ -2388,9 +2383,7 @@
|
|
|
2388
2383
|
"preMapping": [
|
|
2389
2384
|
"p2"
|
|
2390
2385
|
],
|
|
2391
|
-
"postMapping": [
|
|
2392
|
-
"notFetchResult"
|
|
2393
|
-
],
|
|
2386
|
+
"postMapping": [],
|
|
2394
2387
|
"afterExecution": [
|
|
2395
2388
|
"INC_CreateWorklog_OnCreate"
|
|
2396
2389
|
]
|
|
@@ -2437,10 +2430,6 @@
|
|
|
2437
2430
|
"name": "Urgency",
|
|
2438
2431
|
"value": "4000"
|
|
2439
2432
|
},
|
|
2440
|
-
{
|
|
2441
|
-
"name": "Status",
|
|
2442
|
-
"value": "0"
|
|
2443
|
-
},
|
|
2444
2433
|
{
|
|
2445
2434
|
"name": "Investigation Driver",
|
|
2446
2435
|
"value": "High Impact Incident"
|
|
@@ -2508,9 +2497,7 @@
|
|
|
2508
2497
|
"scripts": {
|
|
2509
2498
|
"POST": {
|
|
2510
2499
|
"preMapping": [],
|
|
2511
|
-
"postMapping": [
|
|
2512
|
-
"notFetchResult"
|
|
2513
|
-
],
|
|
2500
|
+
"postMapping": [],
|
|
2514
2501
|
"afterExecution": []
|
|
2515
2502
|
}
|
|
2516
2503
|
},
|
|
@@ -2578,25 +2565,17 @@
|
|
|
2578
2565
|
{
|
|
2579
2566
|
"name": "TaskType",
|
|
2580
2567
|
"value": "2000"
|
|
2581
|
-
},
|
|
2582
|
-
{
|
|
2583
|
-
"name": "Status",
|
|
2584
|
-
"value": "1000"
|
|
2585
2568
|
}
|
|
2586
2569
|
],
|
|
2587
2570
|
"scripts": {
|
|
2588
2571
|
"POST": {
|
|
2589
2572
|
"preMapping": [],
|
|
2590
|
-
"postMapping": [
|
|
2591
|
-
"notFetchResult"
|
|
2592
|
-
],
|
|
2573
|
+
"postMapping": [],
|
|
2593
2574
|
"afterExecution": []
|
|
2594
2575
|
},
|
|
2595
2576
|
"PUT": {
|
|
2596
2577
|
"preMapping": [],
|
|
2597
|
-
"postMapping": [
|
|
2598
|
-
"notFetchResult"
|
|
2599
|
-
],
|
|
2578
|
+
"postMapping": [],
|
|
2600
2579
|
"afterExecution": []
|
|
2601
2580
|
}
|
|
2602
2581
|
}
|
|
@@ -2625,16 +2604,12 @@
|
|
|
2625
2604
|
"scripts": {
|
|
2626
2605
|
"POST": {
|
|
2627
2606
|
"preMapping": [],
|
|
2628
|
-
"postMapping": [
|
|
2629
|
-
"notFetchResult"
|
|
2630
|
-
],
|
|
2607
|
+
"postMapping": [],
|
|
2631
2608
|
"afterExecution": []
|
|
2632
2609
|
},
|
|
2633
2610
|
"PUT": {
|
|
2634
2611
|
"preMapping": [],
|
|
2635
|
-
"postMapping": [
|
|
2636
|
-
"notFetchResult"
|
|
2637
|
-
],
|
|
2612
|
+
"postMapping": [],
|
|
2638
2613
|
"afterExecution": []
|
|
2639
2614
|
}
|
|
2640
2615
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -207,7 +207,7 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
207
207
|
cmdbObject.relations.ciRelations = relations;
|
|
208
208
|
}
|
|
209
209
|
if (includeArray.includes('ticketRelations')) {
|
|
210
|
-
const relations = await ticketCIRelationController.getCITicketRelations(cmdbObject.id);
|
|
210
|
+
const relations = await ticketCIRelationController.getCITicketRelations(cmdbObject.id, undefined, log);
|
|
211
211
|
cmdbObject.relations.ticketRelations = relations;
|
|
212
212
|
}
|
|
213
213
|
if (includeArray.includes('personRelations')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('SMILEconnect_' + path.basename(__filename));
|
|
4
2
|
const arquery = require('../util/arquery');
|
|
5
3
|
const eventForm = 'MYS:SMILEconnect_QueueData';
|
|
6
4
|
|
|
7
|
-
function createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, status, errorMsg, jsonData, ticketNumber2, ticketNumber3) {
|
|
5
|
+
function createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, status, errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
8
6
|
return new Promise((resolve, reject) => {
|
|
9
7
|
let enable = process.env.EVENTLOG_ENABLE;
|
|
10
8
|
if (enable != null && enable != undefined && enable.toLowerCase() == 'true') {
|
|
@@ -24,7 +22,7 @@ function createEventLog(smileId, client, ticketNumber, schemaName, eventName, ur
|
|
|
24
22
|
if (jsonData != null && jsonData != undefined) {
|
|
25
23
|
data['JsonValue'] = JSON.stringify(jsonData, null, 2);
|
|
26
24
|
}
|
|
27
|
-
arquery.createEntry(eventForm, data).then(function (result) {
|
|
25
|
+
arquery.createEntry(eventForm, data, undefined, eventLog).then(function (result) {
|
|
28
26
|
resolve(result);
|
|
29
27
|
}).catch(error => {
|
|
30
28
|
reject(error);
|
|
@@ -35,12 +33,12 @@ function createEventLog(smileId, client, ticketNumber, schemaName, eventName, ur
|
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
function createErrorLog(smileId, client, ticketNumber, schemaName, eventName, url, errorMsg, jsonData, ticketNumber2, ticketNumber3) {
|
|
39
|
-
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Error', errorMsg, jsonData, ticketNumber2, ticketNumber3);
|
|
36
|
+
function createErrorLog(smileId, client, ticketNumber, schemaName, eventName, url, errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
37
|
+
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Error', errorMsg, jsonData, ticketNumber2, ticketNumber3, eventLog);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
|
-
function createSuccessLog(smileId, client, ticketNumber, schemaName, eventName, url, jsonData, ticketNumber2, ticketNumber3) {
|
|
43
|
-
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Done', null, jsonData, ticketNumber2, ticketNumber3);
|
|
40
|
+
function createSuccessLog(smileId, client, ticketNumber, schemaName, eventName, url, jsonData, ticketNumber2, ticketNumber3, eventLog) {
|
|
41
|
+
return createEventLog(smileId, client, ticketNumber, schemaName, eventName, url, 'Done', null, jsonData, ticketNumber2, ticketNumber3, eventLog);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
/*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
3
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const orgdata = require('../controller/orgdataController');
|
|
5
5
|
const cmdbObjectController = require('../controller/cmdbobjectController');
|
|
6
6
|
const ticketCiRelation = require('./ticketCIRelationController');
|
|
7
7
|
const ticketController = require('./ticketController');
|
|
8
8
|
const config = require('../util/config');
|
|
9
|
+
const {getEventLog} = require("../util/eventLog");
|
|
9
10
|
|
|
10
11
|
async function getRelatedObjects(req, res, next) {
|
|
12
|
+
const log = getEventLog(req.log, path.basename(__filename));
|
|
11
13
|
log.debug('include Data', req.includeArray);
|
|
12
14
|
log.debug('include Objects', req.includeObjectsList);
|
|
13
15
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const log = require('@manyos/logger').setupLog('
|
|
2
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const adapterFoundation = require('@manyos/adapter-foundation');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const { v4 } = require('uuid');
|
|
@@ -86,7 +86,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
86
86
|
requestData,
|
|
87
87
|
params,
|
|
88
88
|
adapter,
|
|
89
|
-
log:
|
|
89
|
+
log: log.child({script: scriptId}, true),
|
|
90
90
|
clientId,
|
|
91
91
|
xmlParser,
|
|
92
92
|
script:executeScriptByScript,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -315,7 +315,7 @@ function queryTasks(clientConfig, query, globalScriptParams, includeString) {
|
|
|
315
315
|
element.relations = {};
|
|
316
316
|
if (includeArray.includes('ciRelations')) {
|
|
317
317
|
log.debug('Read relations for task', )
|
|
318
|
-
const relations = await ticketCIRelationController.getTicketCIRelations(element['InstanceId']);
|
|
318
|
+
const relations = await ticketCIRelationController.getTicketCIRelations(element['InstanceId'], log);
|
|
319
319
|
element.relations.ciRelations = relations;
|
|
320
320
|
}
|
|
321
321
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
2
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
3
3
|
const CONSTANTS = require('../util/constants');
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const {getLinkCI, applyMapping} = require('../util/paramHelper');
|
|
7
7
|
//const cmdbObjectController = require('./cmdbobjectController');
|
|
8
8
|
const {ticketConfig} = require ('../util/config');
|
|
9
|
+
const {getEventLog} = require("../util/eventLog");
|
|
9
10
|
|
|
10
11
|
const utilCache = new CacheService(process.env.CACHETTL_TICKETCIRELATIONS || 600); // Create a new cache service instance
|
|
11
12
|
|
|
@@ -27,8 +28,8 @@ function getSchemaName(lookupKeyword) {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
async function getTicketCIRelations(ticketId) {
|
|
31
|
-
const relations = await getCITicketRelations(null, ticketId);
|
|
31
|
+
async function getTicketCIRelations(ticketId, eventLog) {
|
|
32
|
+
const relations = await getCITicketRelations(null, ticketId, eventLog);
|
|
32
33
|
if (relations && Array.isArray(relations)) {
|
|
33
34
|
let x=0;
|
|
34
35
|
for (x=0;x<relations.length;x++) {
|
|
@@ -43,7 +44,8 @@ async function getTicketCIRelations(ticketId) {
|
|
|
43
44
|
return relations;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
47
|
+
async function getCITicketRelations(ciInstanceId, ticketId, eventLog) {
|
|
48
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
47
49
|
let ci2ticketOnly = false;
|
|
48
50
|
if (ticketId === null || ticketId === undefined) {
|
|
49
51
|
ci2ticketOnly = true;
|
|
@@ -64,7 +66,7 @@ async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
|
64
66
|
}
|
|
65
67
|
const form = CONSTANTS.FORM_ASSET_TICKET_ASSOC;
|
|
66
68
|
|
|
67
|
-
const result = await arquery.executeARQuery(form, null, query, ['Request ID02', 'Request ID01', 'Association Type01', 'Request Type01', 'Request Description01']);
|
|
69
|
+
const result = await arquery.executeARQuery(form, null, query, ['Request ID02', 'Request ID01', 'Association Type01', 'Request Type01', 'Request Description01'], undefined, log);
|
|
68
70
|
const relations = [];
|
|
69
71
|
for (const relationData of result.data) {
|
|
70
72
|
let relation = {};
|
|
@@ -76,7 +78,7 @@ async function getCITicketRelations(ciInstanceId, ticketId) {
|
|
|
76
78
|
relationType: relationData['Association Type01']
|
|
77
79
|
};
|
|
78
80
|
} else {
|
|
79
|
-
const ci = await getCiByReconId(relationData['Request ID02']);
|
|
81
|
+
const ci = await getCiByReconId(relationData['Request ID02'], log);
|
|
80
82
|
relation = {
|
|
81
83
|
ciId: ci['Instance Id'],
|
|
82
84
|
ciName: ci['Name'],
|
|
@@ -116,7 +118,8 @@ async function getAssocLookup(ticketForm, relationObject, assocType) {
|
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, assocType, ticketSummary) {
|
|
121
|
+
async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, assocType, ticketSummary, eventLog) {
|
|
122
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
120
123
|
if (ticketSummary === null || ticketSummary === undefined) {
|
|
121
124
|
ticketSummary = 'summary';
|
|
122
125
|
}
|
|
@@ -176,12 +179,13 @@ async function createTicketCIRelation(ticketConfig, ticketId, ciInstanceId, asso
|
|
|
176
179
|
|
|
177
180
|
log.debug('Create CI Ticket Relation', ticketRelationFormData);
|
|
178
181
|
//todo: implement impersonate
|
|
179
|
-
const ticketRelation = await arquery.createEntry(ticketRelationForm, ticketRelationFormData);
|
|
180
|
-
const assetRelation = await arquery.createEntry(CONSTANTS.FORM_ASSET_TICKET_ASSOC, assetRelationFormData);
|
|
182
|
+
const ticketRelation = await arquery.createEntry(ticketRelationForm, ticketRelationFormData, undefined, log);
|
|
183
|
+
const assetRelation = await arquery.createEntry(CONSTANTS.FORM_ASSET_TICKET_ASSOC, assetRelationFormData, undefined, log);
|
|
181
184
|
return {ticketRelation, assetRelation}
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig2, ticketId2, assocType, ticketSummary) {
|
|
187
|
+
async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig2, ticketId2, assocType, ticketSummary, eventLog) {
|
|
188
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
185
189
|
//todo fix request description
|
|
186
190
|
if (ticketSummary === null || ticketSummary === undefined) {
|
|
187
191
|
ticketSummary = 'summary';
|
|
@@ -216,13 +220,14 @@ async function createTicket2TicketRelation(ticketConfig, ticketId1, ticketConfig
|
|
|
216
220
|
|
|
217
221
|
//todo: implement impersonate
|
|
218
222
|
log.debug('Create Ticket 2 Ticket Relation', ticketRelationFormData1, ticketRelationFormData2);
|
|
219
|
-
const ticketRelation1 = await arquery.createEntry(ticketConfig.forms.assoc, ticketRelationFormData1);
|
|
220
|
-
const ticketRelation2 = await arquery.createEntry(ticketConfig2.forms.assoc, ticketRelationFormData2);
|
|
223
|
+
const ticketRelation1 = await arquery.createEntry(ticketConfig.forms.assoc, ticketRelationFormData1, undefined, log);
|
|
224
|
+
const ticketRelation2 = await arquery.createEntry(ticketConfig2.forms.assoc, ticketRelationFormData2, undefined, log);
|
|
221
225
|
return {ticketRelation1, ticketRelation2}
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
|
|
225
|
-
async function deleteTicketCIRelation(ticketConfig, ticketId, ciInstanceId) {
|
|
229
|
+
async function deleteTicketCIRelation(ticketConfig, ticketId, ciInstanceId, eventLog) {
|
|
230
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
226
231
|
const ticketRelationForm = ticketConfig.forms.assoc;
|
|
227
232
|
const ciData = await getCIData(ciInstanceId);
|
|
228
233
|
let ticketRelationQuery = `'Request ID02'= "${ticketId}" AND 'Request ID01' = "${ciData.ReconciliationIdentity}"`;
|
|
@@ -394,7 +399,8 @@ async function getOppositeAssocTypeByCode(assocCode) {
|
|
|
394
399
|
});
|
|
395
400
|
}
|
|
396
401
|
|
|
397
|
-
function doesCIRelationExists(ticketRelations, newRelation, keepCIs) {
|
|
402
|
+
function doesCIRelationExists(ticketRelations, newRelation, keepCIs, eventLog) {
|
|
403
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
398
404
|
log.debug('check for relation old', ticketRelations)
|
|
399
405
|
log.debug('check for relation new', newRelation)
|
|
400
406
|
const relationFound = ticketRelations.find(relation => {
|
|
@@ -431,7 +437,8 @@ function doesTicketRelationExists(ticketRelations, newRelation) {
|
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
439
|
|
|
434
|
-
async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
440
|
+
async function updateRelations(ticketConfig, userConfig, ticketId, relations, eventLog) {
|
|
441
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
435
442
|
// Wenn CIs vom Löschen ausgeschlossen werden sollen, dann kann unter relations.keepCIs ein Array mit Recon/InstanceId gesetzt werden.
|
|
436
443
|
log.debug('Checker', {ticketConfig, userConfig, ticketId, relations});
|
|
437
444
|
// Remove Ticket Relations if task
|
|
@@ -444,7 +451,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
444
451
|
|
|
445
452
|
//Check CI Relations
|
|
446
453
|
if (relations && relations.ciRelations && Array.isArray(relations.ciRelations)) {
|
|
447
|
-
const existingRelations = await getTicketCIRelations(ticketId);
|
|
454
|
+
const existingRelations = await getTicketCIRelations(ticketId, log);
|
|
448
455
|
log.debug('foundRelations', existingRelations);
|
|
449
456
|
let x=0;
|
|
450
457
|
//check for missiong relations
|
|
@@ -455,7 +462,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
455
462
|
log.debug('createRelation, already exists', relation, relationsExists);
|
|
456
463
|
if (!relationsExists) {
|
|
457
464
|
try {
|
|
458
|
-
await createTicketCIRelation(ticketConfig, ticketId, relation.ciId, relation.relationType);
|
|
465
|
+
await createTicketCIRelation(ticketConfig, ticketId, relation.ciId, relation.relationType, undefined, log);
|
|
459
466
|
} catch (e) {
|
|
460
467
|
errors.push(e);
|
|
461
468
|
}
|
|
@@ -466,11 +473,11 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
466
473
|
if (existingRelations && Array.isArray(existingRelations)) {
|
|
467
474
|
for (x=0; x<existingRelations.length; x++) {
|
|
468
475
|
const relation = existingRelations[x];
|
|
469
|
-
const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation, relations.keepCIs);
|
|
476
|
+
const shouldRelationsExists = doesCIRelationExists(relations.ciRelations, relation, relations.keepCIs, log);
|
|
470
477
|
log.debug('deleteRelation, already exists', relation, shouldRelationsExists);
|
|
471
478
|
if (shouldRelationsExists !== true) {
|
|
472
479
|
try {
|
|
473
|
-
await deleteTicketCIRelation(ticketConfig, ticketId, relation.ciId);
|
|
480
|
+
await deleteTicketCIRelation(ticketConfig, ticketId, relation.ciId, log);
|
|
474
481
|
} catch (e) {
|
|
475
482
|
errors.push(e);
|
|
476
483
|
}
|
|
@@ -494,7 +501,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
494
501
|
if (ticketConfig2 === null || ticketConfig2 === undefined) {
|
|
495
502
|
throw new Error(`TicketConfig for ${relation.ticketType} not found.`);
|
|
496
503
|
}
|
|
497
|
-
await createTicket2TicketRelation(ticketConfig, ticketId, ticketConfig2, relation.ticketId, relation.relationType);
|
|
504
|
+
await createTicket2TicketRelation(ticketConfig, ticketId, ticketConfig2, relation.ticketId, relation.relationType, undefined, log);
|
|
498
505
|
}
|
|
499
506
|
}
|
|
500
507
|
}
|
|
@@ -515,6 +522,7 @@ async function updateRelations(ticketConfig, userConfig, ticketId, relations) {
|
|
|
515
522
|
}
|
|
516
523
|
}
|
|
517
524
|
}
|
|
525
|
+
log.error('relationErrors', errors);
|
|
518
526
|
if (errors && errors.length > 0) {
|
|
519
527
|
errors = errors.map(item => item.message)
|
|
520
528
|
}
|
|
@@ -552,12 +560,13 @@ function getCIData(instanceId) {
|
|
|
552
560
|
});
|
|
553
561
|
}
|
|
554
562
|
|
|
555
|
-
async function getCiByReconId(reconId) {
|
|
563
|
+
async function getCiByReconId(reconId, eventLog) {
|
|
564
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
556
565
|
log.debug('Search for CI', reconId);
|
|
557
566
|
//get only CIs with recon
|
|
558
567
|
const query = `'Reconciliation Identity'="${reconId}" AND 'Data Set Id' = "BMC.ASSET"`;
|
|
559
568
|
const form = CONSTANTS.FORM_CMDB_AST_BASE;
|
|
560
|
-
const result = await arquery.executeARQuery(form, null, query, ['InstanceId', 'AssetLifecycleStatus', 'Name', 'Class Id', 'Instance Id']);
|
|
569
|
+
const result = await arquery.executeARQuery(form, null, query, ['InstanceId', 'AssetLifecycleStatus', 'Name', 'Class Id', 'Instance Id'], undefined, log);
|
|
561
570
|
if (result !== null && result !== undefined && result.data !== undefined) {
|
|
562
571
|
return result.data[0];
|
|
563
572
|
} else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
3
|
+
let log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|
|
@@ -11,15 +11,17 @@ const relationUtil = require('../util/relationUtil');
|
|
|
11
11
|
const ticketCIRelationController = require('./ticketCIRelationController');
|
|
12
12
|
const scriptController = require('./scriptController');
|
|
13
13
|
const mappingUtil = require('../util/mappingUtil');
|
|
14
|
+
const {getEventLog} = require("../util/eventLog");
|
|
14
15
|
|
|
15
16
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 0); // Create a new cache service instance
|
|
16
17
|
|
|
17
|
-
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams) {
|
|
18
|
+
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams, log) {
|
|
18
19
|
let query = '1=1';
|
|
19
|
-
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams);
|
|
20
|
+
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams, log);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
|
|
23
|
+
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams, eventLog) {
|
|
24
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
23
25
|
let relationErrors;
|
|
24
26
|
const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
|
|
25
27
|
const relations = data.relations || {}
|
|
@@ -36,19 +38,19 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
36
38
|
|
|
37
39
|
const fields = mappingUtil.getFieldsForCreate(config.getMapping(requestType), mapping, clientConfig[requestType].fields)
|
|
38
40
|
|
|
39
|
-
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig[ticketConfig.requestType].constants, fields);
|
|
41
|
+
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig[ticketConfig.requestType].constants, fields, log);
|
|
40
42
|
|
|
41
43
|
//run postScripts
|
|
42
44
|
if (scripts && scripts.postMapping) {
|
|
43
45
|
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options)
|
|
48
|
+
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options, log)
|
|
47
49
|
|
|
48
50
|
log.debug('TicketCreateResult', result);
|
|
49
51
|
const ticketCreateId = Object.values(result)[0];
|
|
50
52
|
//Find change id
|
|
51
|
-
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options)
|
|
53
|
+
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options, log)
|
|
52
54
|
if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length && resultInterfaceCreate.data[0][ticketConfig.ticketIdField]) {
|
|
53
55
|
const ticketId = resultInterfaceCreate.data[0][ticketConfig.ticketIdField];
|
|
54
56
|
globalScriptParams.id = ticketId
|
|
@@ -58,7 +60,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
58
60
|
if (data[ticketConfig.businessServiceReconIdField] && relations) {
|
|
59
61
|
relations.keepCIs = [data[ticketConfig.businessServiceReconIdField]]
|
|
60
62
|
}
|
|
61
|
-
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations);
|
|
63
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, ticketId, relations, log);
|
|
62
64
|
|
|
63
65
|
} else {
|
|
64
66
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
@@ -72,7 +74,8 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
72
74
|
return {createResult: resultInterfaceCreate, relationErrors};
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
77
|
+
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams, eventLog) {
|
|
78
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
76
79
|
log.debug('config', ticketConfig);
|
|
77
80
|
const includeArray = getIncludeArray(includeString);
|
|
78
81
|
log.debug('ticketConfig.requestType', ticketConfig.requestType);
|
|
@@ -99,7 +102,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
99
102
|
log.debug('mapping', mapping);
|
|
100
103
|
|
|
101
104
|
return ticketCache.get(key, async function () {
|
|
102
|
-
const result = await arquery.executeARQuery(ticketConfig.forms.regular, baseQuery || null, query, fields.toString() || '1', options);
|
|
105
|
+
const result = await arquery.executeARQuery(ticketConfig.forms.regular, baseQuery || null, query, fields.toString() || '1', options, log);
|
|
103
106
|
const globalRelationObjects = relationUtil.prepareGlobalRelationObject();
|
|
104
107
|
const tickets = [];
|
|
105
108
|
if (result && result.data && result.data.length) {
|
|
@@ -154,7 +157,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
154
157
|
|
|
155
158
|
ticket.relations = {};
|
|
156
159
|
if (includeArray.includes('ciRelations')) {
|
|
157
|
-
const relations = await ticketCIRelationController.getTicketCIRelations(ticket.id);
|
|
160
|
+
const relations = await ticketCIRelationController.getTicketCIRelations(ticket.id, log);
|
|
158
161
|
ticket.relations.ciRelations = relations;
|
|
159
162
|
}
|
|
160
163
|
if (includeArray.includes('ticketRelations')) {
|
|
@@ -267,7 +270,8 @@ function checkFieldsProblem(problem, globalRelationObjects) {
|
|
|
267
270
|
}
|
|
268
271
|
|
|
269
272
|
|
|
270
|
-
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams) {
|
|
273
|
+
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams, eventLog) {
|
|
274
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
271
275
|
let query = '1=2';
|
|
272
276
|
const requestType = ticketConfig.requestType;
|
|
273
277
|
if (requestType === 'incident') {
|
|
@@ -279,12 +283,13 @@ async function getTicket(ticketConfig, config, id, mapping, includeString, globa
|
|
|
279
283
|
} else if (requestType === 'workOrder') {
|
|
280
284
|
query = `'Work Order ID'=\"${id}\"`;
|
|
281
285
|
}
|
|
282
|
-
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams);
|
|
286
|
+
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams, log);
|
|
283
287
|
const ticket = returnValue.data[0];
|
|
284
288
|
return {data: ticket, included: returnValue.included};
|
|
285
289
|
}
|
|
286
290
|
|
|
287
|
-
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
291
|
+
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams, eventLog) {
|
|
292
|
+
log = getEventLog(eventLog, path.basename(__filename));
|
|
288
293
|
let relationErrors;
|
|
289
294
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
290
295
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
@@ -295,22 +300,21 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
295
300
|
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
296
301
|
}
|
|
297
302
|
|
|
298
|
-
log.debug(clientConfig[ticketConfig.requestType]);
|
|
303
|
+
log.debug('requestType', clientConfig[ticketConfig.requestType]);
|
|
299
304
|
const myClientConfig = {};
|
|
300
305
|
myClientConfig[ticketConfig.requestType] = {baseQuery: clientConfig[ticketConfig.requestType].baseQuery, fields: [1, ticketConfig.businessServiceReconIdField]};
|
|
301
306
|
const myMapping = [{"oldName":ticketConfig.requestIdField, "newName" : "internalId"}, {"oldName":ticketConfig.businessServiceReconIdField, "newName" : "serviceReconId"}];
|
|
302
307
|
|
|
303
308
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
304
|
-
|
|
305
309
|
//Constants work only on new.
|
|
306
|
-
ticketData = mappingUtil.applyMapping2Remedy(ticketData, mapping, undefined, fields);
|
|
310
|
+
ticketData = mappingUtil.applyMapping2Remedy(ticketData, mapping, undefined, fields, log);
|
|
307
311
|
|
|
308
312
|
//run postMapping
|
|
309
313
|
if (scripts && scripts.postMapping) {
|
|
310
314
|
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
311
315
|
}
|
|
312
316
|
|
|
313
|
-
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
|
|
317
|
+
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams, log);
|
|
314
318
|
log.debug('Ticket to Update', ticket);
|
|
315
319
|
//keep businessService CI Relation
|
|
316
320
|
if (ticket && ticket.data && ticket.data.serviceReconId && relations) {
|
|
@@ -321,8 +325,8 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
321
325
|
delete ticketData[ticketConfig.ticketIdField];
|
|
322
326
|
|
|
323
327
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
324
|
-
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options);
|
|
325
|
-
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations);
|
|
328
|
+
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData, clientConfig.options, log);
|
|
329
|
+
relationErrors = await ticketCIRelationController.updateRelations(ticketConfig, clientConfig, id, relations, log);
|
|
326
330
|
//run afterExecution
|
|
327
331
|
if (scripts && scripts.afterExecution) {
|
|
328
332
|
await scriptController.runScripts(scripts.afterExecution, ticketData, clientConfig.clientId, globalScriptParams);
|
|
@@ -330,12 +334,12 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalSc
|
|
|
330
334
|
return {updateResult: update, relationErrors};
|
|
331
335
|
}
|
|
332
336
|
|
|
333
|
-
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
337
|
+
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams, eventLog) {
|
|
334
338
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
335
339
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
336
340
|
const customFields = searchUtil.getCustomFields(clientConfig[ticketConfig.requestType].fields, mapping, fields);
|
|
337
341
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
338
|
-
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
342
|
+
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams, eventLog);
|
|
339
343
|
}
|
|
340
344
|
|
|
341
345
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('dotenv').config();
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const log = require('@manyos/logger').setupLog('
|
|
3
|
+
const log = require('@manyos/logger').setupLog('SMILEconnect', path.basename(__filename));
|
|
4
4
|
const arquery = require('../util/arquery');
|
|
5
5
|
const CacheService = require ('../util/cache.service');
|
|
6
6
|
const config = require('../util/config');
|