Skip to content

Commit f7e70d6

Browse files
author
VarmaSANJAY
committed
Resolved conflict
2 parents 029722d + ebbf727 commit f7e70d6

8 files changed

Lines changed: 456 additions & 231 deletions

File tree

client/cat3/package-lock.json

Lines changed: 92 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/app/engine/bots/lambdaExecutor.js

Whitespace-only changes.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Copyright [2016] [Relevance Lab]
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
const logger = require('_pr/logger')(module);
18+
const mongoose = require('mongoose');
19+
const Schema = mongoose.Schema;
20+
21+
const botHistoryAuditTrailSchema = new Schema ({
22+
botId: {
23+
type: String
24+
},
25+
actionLogId: {
26+
type: String,
27+
required: true
28+
},
29+
botRunId: {
30+
type: String,
31+
required: true
32+
},
33+
botExecutorName: {
34+
type: String
35+
},
36+
input: {
37+
type : Schema.Types.Mixed,
38+
default : null
39+
},
40+
output: {
41+
type : Schema.Types.Mixed,
42+
default : null
43+
},
44+
createdOn: {
45+
type: Number,
46+
required: true,
47+
default: Date.now()
48+
},
49+
lastUpdateOn: {
50+
type: Number,
51+
required: true,
52+
default: Date.now()
53+
}
54+
})
55+
56+
botHistoryAuditTrailSchema.index({ actionLogId: 1, createdOn:1 }, { unique: true });
57+
58+
botHistoryAuditTrailSchema.statics.addBotHistoryAudit = function (auditObj, callback) {
59+
let audit = new this(auditObj);
60+
audit.save(callback);
61+
};
62+
63+
botHistoryAuditTrailSchema.statics.insertBotHistoryAudit = function (auditList, callback) {
64+
let auditListDB = auditList.map((auditObj) => {
65+
let audit = new this(auditObj);
66+
audit.createdOn = Date.now();
67+
audit.lastUpdateOn = Date.now();
68+
return audit;
69+
});
70+
this.insertMany(auditListDB, callback);
71+
};
72+
73+
botHistoryAuditTrailSchema.statics.findByQuery = function (query, project, options, callback) {
74+
return this.find(query, project, options, callback);
75+
};
76+
77+
botHistoryAuditTrailSchema.statics.findOneByQuery = function (query, project, options, callback) {
78+
return this.findOne(query, project, options, callback);
79+
};
80+
81+
const botHistoryAuditTrail = mongoose.model('botHistoryAuditTrail', botHistoryAuditTrailSchema);
82+
module.exports = botHistoryAuditTrail;

server/app/routes/v1.0/routes_bot.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports.setRoutes = function(app, sessionVerificationFunc) {
2424
*/
2525
app.get('/bot/all',function(req,res) {
2626
var loggedUser = req.session.user.cn;
27-
27+
2828
botService.getAllBotsList(req.query, loggedUser,function(err,data) {
2929
if (err) {
3030
return res.status(500).send(err);
@@ -34,6 +34,41 @@ module.exports.setRoutes = function(app, sessionVerificationFunc) {
3434
});
3535
});
3636

37+
app.get('/bot/history/:actionLogId',function(req,res) {
38+
const actionLogId = req.params.actionLogId;
39+
botService.getBotHistoryAudit(actionLogId, function(err, data) {
40+
if (err) {
41+
return res.status(500).send(err);
42+
} else {
43+
return res.status(200).send(data);
44+
}
45+
});
46+
});
47+
48+
app.post('/bot/history',function(req,res) {
49+
const loggedUser = req.session.user.cn;
50+
const rqObj = req.body;
51+
botService.addBotHistoryAudit(rqObj, loggedUser, function(err, data) {
52+
if (err) {
53+
return res.status(500).send(err);
54+
} else {
55+
return res.status(200).send(data);
56+
}
57+
});
58+
});
59+
60+
app.post('/bot/historyList',function(req,res) {
61+
const loggedUser = req.session.user.cn;
62+
const rqObjList = req.body;
63+
botService.insertBotHistoryAudit(rqObjList, loggedUser, function(err,data) {
64+
if (err) {
65+
return res.status(500).send(err);
66+
} else {
67+
return res.status(200).send(data);
68+
}
69+
});
70+
});
71+
3772
app.get('/bot',function(req,res) {
3873
var actionStatus = null,serviceNowCheck =null;
3974
var loggedUser = req.session.user.cn;

server/app/services/botService.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ var azurecloudProvider = require('_pr/model/classes/masters/cloudprovider/azureC
5252
var vmwareProvider = require('_pr/model/classes/masters/cloudprovider/vmwareCloudProvider.js');
5353
var botAuditTrailSummary = require('_pr/model/audit-trail/bot-audit-trail-summary');
5454

55+
const botHistoryAuditTrail = require('_pr/model/audit-trail/bot-history-audit-trail');
56+
5557
var appConfig = require('_pr/config');
5658
var botService = module.exports = {};
5759

@@ -451,6 +453,8 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
451453

452454
}
453455

456+
} else if(bots[0].type === 'lambda') {
457+
454458
} else {
455459
var error = new Error();
456460
logger.error("task_id"+taskId+" There is no record available in DB against BOT :"+botsId)
@@ -1514,3 +1518,33 @@ botService.getAllBotsList = function getAllBotsList(botsQuery, userName, callbac
15141518
return;
15151519
});
15161520
}
1521+
1522+
botService.addBotHistoryAudit = function addBotHistoryAudit(obj, userName, callback) {
1523+
botHistoryAuditTrail.addBotHistoryAudit(obj, (err, status) => {
1524+
if(err) {
1525+
callback(err, null);
1526+
} else {
1527+
callback(null, status);
1528+
};
1529+
});
1530+
};
1531+
1532+
botService.insertBotHistoryAudit = function insertBotHistoryAudit(objList, userName, callback) {
1533+
botHistoryAuditTrail.insertBotHistoryAudit(objList, (err, status) => {
1534+
if(err) {
1535+
callback(err, null);
1536+
} else {
1537+
callback(null, status);
1538+
};
1539+
});
1540+
};
1541+
1542+
botService.getBotHistoryAudit = function getBotHistoryAudit(actionLogId, callback) {
1543+
botHistoryAuditTrail.findOneByQuery({ actionLogId : actionLogId }, {}, {}, (err, status) => {
1544+
if(err) {
1545+
callback(err, null);
1546+
} else {
1547+
callback(null, status);
1548+
};
1549+
});
1550+
};

0 commit comments

Comments
 (0)