Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 8c0cb1c

Browse files
committed
added request to configuration java bridge
1 parent 770ad51 commit 8c0cb1c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

initializers/dataAccess.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ var fs = require("fs");
3434
var async = require("async");
3535
var java = require('java');
3636
var Jdbc = require('informix-wrapper');
37+
var req = require('request');
3738
var helper;
3839

40+
var javaReadBridge = process.env.JAVA_READ_BRIDGE || "http://localhost:5555/bridge";
41+
3942
/**
4043
* Regex for sql paramters e.g @param_name@
4144
*/
@@ -110,7 +113,7 @@ function parameterizeQuery(query, params, callback) {
110113
});
111114
}
112115

113-
function executePreparedStatement(api, sql, parameters, connection, next) {
116+
function executePreparedStatement(api, sql, parameters, connection, next, db) {
114117
async.waterfall([
115118
function (cb) {
116119
parameterizeQuery(sql, parameters, cb);
@@ -119,8 +122,19 @@ function executePreparedStatement(api, sql, parameters, connection, next) {
119122

120123
if (api.helper.readTransaction) {
121124
api.log("CALLING SANTTOSH'S MAGIC");
122-
api.log(new Buffer(sql).toString('base64'));
123-
cb(null, []); // necessary?
125+
126+
var body = {
127+
"sql": new Buffer(sql).toString('base64'),
128+
"db": db
129+
};
130+
131+
api.log(body);
132+
133+
req({ url: javaReadBridge, body: body, json: true }, function(response) {
134+
api.log(response);
135+
});
136+
137+
cb(null, []);
124138
} else {
125139
api.log("Database connected", 'debug');
126140
// the connection might have been closed due to other errors, so this check must be done
@@ -294,7 +308,7 @@ exports.dataAccess = function (api, next) {
294308
return;
295309
}
296310

297-
executePreparedStatement(api, sql, parameters, connection, next);
311+
executePreparedStatement(api, sql, parameters, connection, next, queries[queryName].db);
298312
},
299313

300314
/**
@@ -337,7 +351,7 @@ exports.dataAccess = function (api, next) {
337351
return;
338352
}
339353

340-
executePreparedStatement(api, sql, parameters, connection, next);
354+
executePreparedStatement(api, sql, parameters, connection, next, dbName);
341355
}
342356
};
343357
next();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"moment-timezone": "0.0.x",
3838
"nodemailer": "0.5.x",
3939
"redis": "0.10.x",
40-
"request": "~2.33.0",
40+
"request": "^2.33.0",
4141
"soap": "~0.3.2",
4242
"ssha": "*",
4343
"string": "1.6.x",

0 commit comments

Comments
 (0)