Correct export of Delivery Unit EON_EMOBILITY_PROVIDER (37 files, replaces incomplete initial export)

This commit is contained in:
Thorsten Schmitz
2026-07-09 01:59:09 +02:00
parent 1baef99314
commit dce458f6c1
38 changed files with 6669 additions and 75 deletions
@@ -0,0 +1,971 @@
//var datetimelib = $.import("uniorg.libs", "datetime");
//var logginglib = $.import("uniorg.libs", "uologging");
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
var serviceName = "eon.emobility.provider.backend.getProviderData.xsjs";
var serviceVersion = '1.3';
var output = {};
var outMessages = [];
var outMsg = {};
var outStatus = "success";
var myDebug = {};
var debugLevel = 0;
switch ($.request.parameters.get("debug")) {
case "true":
case "yes":
case "1":
debugLevel = 1;
break;
case "full":
case "2":
debugLevel = 2;
break;
}
if (debugLevel > 0) {
output.requestParams = $.request.parameters;
}
function setOutputMessage() {
output.status = outStatus;
if (debugLevel > 0) {
output.debugInfos = myDebug;
}
output.messages = outMessages;
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify(output));
//$.response.status = $.net.http.OK;
}
function exceptionHandler(ex) {
outMsg = {};
outMsg.method = "exceptionHandler";
outMsg.status = "error";
outMsg.message = ex.toString();
if (debugLevel > 0) {
outMsg.exceptionInfo = {};
outMsg.exceptionInfo.name = ex.name;
outMsg.exceptionInfo.message = ex.message;
outMsg.exceptionInfo.fileName = ex.fileName;
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
outMsg.exceptionInfo.stack = ex.stack;
//outMsg.exceptionInfo.source = ex.toSource();
}
outMessages.push(outMsg);
outStatus = "error";
output.status = outStatus;
if (debugLevel > 0) {
output.debugInfos = myDebug;
}
output.messages = outMessages;
var errbody = JSON.stringify(output);
$.response.contentType = 'application/json';
$.response.setBody(errbody);
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
function checkAuthorization() {
var isAuthorized = true;
try {
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::ViewProviderData");
} catch (ex) {
isAuthorized = false;
outMsg = {};
outMsg.method = "checkAuthorization";
outMsg.status = "error";
outStatus = "error";
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
outMessages.push(outMsg);
$.response.status = $.net.http.FORBIDDEN;
}
// temporary test
/*var random_boolean = Math.random() < 0.5;
if (random_boolean) {
isAuthorized = false;
outMsg = {};
outMsg.method = "checkAuthorization";
outMsg.status = "error";
outStatus = "error";
outMsg.message = "Random test exception";
outMessages.push(outMsg);
$.response.status = $.net.http.UNAUTHORIZED;
}*/
//
return isAuthorized;
}
function checkParams() {
var isValid = true;
var missingParams = [];
try {
/*if (!$.request.parameters.get("billingrunid")) {
missingParams.push("billingrunid");
isValid = false;
}
if (!$.request.parameters.get("phase")) {
missingParams.push("phase");
isValid = false;
}*/
} catch (e) {
exceptionHandler(e);
isValid = false;
}
if (!isValid) {
outMsg = {};
outMsg.method = "checkParams";
outMsg.status = "error";
outStatus = "error";
outMsg.message = "missing mandatory parameters: " + missingParams.join();
outMessages.push(outMsg);
$.response.status = $.net.http.BAD_REQUEST;
}
return isValid;
}
function setScheduled(billingRunId) {
outMsg = {};
outMsg.method = "schedule";
outMsg.status = "failure";
try {
var conn = $.hdb.getConnection();
var query =
'update BRL set BRL."STATUS"=\'scheduled\' from \
"A19753_EON_P01"."UO_BILLINGRUN_LINE" BRL INNER JOIN "A19753_EON_P01"."UO_BILLINGRUN_HEAD" BRH ON BRH."ID"=BRL."BILLING_RUN_ID" \
where BRL."STATUS" = \'phase1\' and BRH."RUN_ID" = ?';
myDebug.updateStatement = query;
var rc = conn.executeUpdate(query, billingRunId);
outMsg.rowsAffected = rc;
if (rc > 0) {
outMsg.status = "success";
} else {
outStatus = "error";
outMsg.message = "No Billing Lines for Billing Run ID " + billingRunId + " were found";
$.response.status = $.net.http.NOT_FOUND;
}
conn.commit();
conn.close();
outMessages.push(outMsg);
} catch (ex) {
exceptionHandler(ex);
}
}
function setPhase(billingRunId, phase) {
outMsg = {};
outMsg.method = "update";
outMsg.status = "failure";
try {
var conn = $.hdb.getConnection();
var query =
'UPDATE "A19753_EON_P01"."UO_BILLINGRUN_HEAD" SET "PHASE" = ?, "UPDATE_TS" = CURRENT_TIMESTAMP, "USER_EXECUTE" = ? WHERE "RUN_ID" = ?';
myDebug.updateStatement = query;
var rc = conn.executeUpdate(query, phase, $.session.getUsername(), billingRunId);
outMsg.rowsAffected = rc;
if (rc > 0) {
outMsg.status = "success";
} else {
outStatus = "error";
outMsg.message = "Billing Run ID " + billingRunId + " was not found";
$.response.status = $.net.http.NOT_FOUND;
}
conn.commit();
conn.close();
outMessages.push(outMsg);
if (outMsg.status = "success" && phase === 'INVOICED') {
setScheduled(billingRunId);
}
} catch (ex) {
exceptionHandler(ex);
}
}
function getData() {
outMsg = {};
outMsg.method = "get";
outMsg.status = "success";
var rsMsg = {};
rsMsg.ReadOnly = !$.session.hasAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
try {
var conn = $.db.getConnection();
var pstmt;
var query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER" ORDER BY "Code"';
pstmt = conn.prepareStatement(query);
var rs = pstmt.executeQuery();
var rsmd = rs.getMetaData();
var colCount = rsmd.getColumnCount();
var rc = 0;
var providerRows = [];
while (rs.next()) {
var row = {};
rc++;
for (var c = 1; c <= colCount; c++) {
var colName = rsmd.getColumnLabel(c);
var colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
providerRows.push(row);
}
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_LINES" ORDER BY "Code", U_CODE DESC, U_FROM DESC, U_TYP, U_OPERATOR';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var lineRows = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
row.editable = false;
row.new = false;
row.pendingChanges = false;
row.highlight = 'None';
row.highlightText = '';
row.guid = $.util.createUuid();
lineRows.push(row);
}
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_PERIODS" ORDER BY "Code", U_FROM DESC';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var periodRows = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
periodRows.push(row);
}
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_NEXT_PERIOD" ORDER BY "Code", U_CODE DESC, U_FROM DESC, U_TYP, U_OPERATOR, U_SUBOPERATOR';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var nextPeriodRows = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
row.editable = false;
row.guid = $.util.createUuid();
row.highlight = 'None';
row.highlightText = '';
nextPeriodRows.push(row);
}
var provider = providerRows.map(function(p) {
var prov = {};
// copy all properties of provider head object
Object.keys(p).forEach(function(k) {
prov[k] = p[k];
});
prov.editable = false;
prov.new = false;
prov.pendingChanges = false;
prov.allowNewPeriod = $.session.hasAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
prov.Lines = lineRows.filter(function(lr) {
return lr.Code === p.Code;
});
prov.Periods = periodRows.filter(function(pr) {
return pr.Code === p.Code;
});
prov.NextPeriod = nextPeriodRows.filter(function(npr) {
return npr.Code === p.Code;
});
return prov;
});
rsMsg.Provider = provider;
query = 'SELECT T1."FldValue" AS "U_CODE" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'CODE\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var valuesCode = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
valuesCode.push(row);
}
query = 'SELECT T1."FldValue" AS "U_TYP" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'TYP\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var valuesType = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
valuesType.push(row);
}
query = 'SELECT T1."FldValue" AS "U_OPERATOR" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'OPERATOR\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var valuesOperator = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
valuesOperator.push(row);
}
query = 'select "CurrCode", "CurrName", "ChkName" from "A19753_EON_P01".OCRN ORDER BY "CurrCode"';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var currencies = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
currencies.push(row);
}
rsMsg.ValueHelp = {
Code: valuesCode,
Type: valuesType,
Operator: valuesOperator,
Currencies: currencies
};
query = 'SELECT "Code", "Name" FROM "A19753_EON_P01"."@EON_SUBOPERATOR" ORDER BY "Code"';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var subOperators = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
row.pendingChanges = false;
row.newEntry = false;
subOperators.push(row);
}
query = 'SELECT "Code", "LineId", "U_ORG_ID" FROM "A19753_EON_P01"."@EON_SUBOPERATOR_L" ORDER BY "Code", "U_ORG_ID"';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
rsmd = rs.getMetaData();
colCount = rsmd.getColumnCount();
rc = 0;
var organizations = [];
while (rs.next()) {
row = {};
rc++;
for (c = 1; c <= colCount; c++) {
colName = rsmd.getColumnLabel(c);
colType = rsmd.getColumnTypeName(c);
switch (colType) {
case 'TINYINT':
case 'SMALLINT':
case 'INT':
case 'INTEGER':
case 'BIGINT':
row[colName] = rs.getInteger(c);
break;
case 'DECIMAL':
row[colName] = rs.getDecimal(c);
break;
case 'REAL':
case 'DOUBLE':
case 'FLOAT':
row[colName] = rs.getDouble(c);
break;
case 'NVARCHAR':
case 'NCHAR':
case 'SHORTTEXT':
row[colName] = rs.getNString(c);
break;
case 'VARCHAR':
case 'CHAR':
row[colName] = rs.getString(c);
break;
case 'BINARY':
case 'VARBINARY':
row[colName] = rs.getBString(c);
break;
case 'DATE':
row[colName] = rs.getDate(c);
break;
case 'TIME':
row[colName] = rs.getTime(c);
break;
case 'TIMESTAMP':
row[colName] = rs.getTimestamp(c);
break;
case 'CLOB':
row[colName] = rs.getClob(c);
break;
case 'NCLOB':
case 'TEXT':
row[colName] = rs.getNClob(c);
break;
case 'BLOB':
row[colName] = rs.getBlob(c);
break;
case 'SECONDDATE':
row[colName] = rs.getSeconddate(c);
break;
}
//row[colName] = colType;
}
row.guid = $.util.createUuid();
row.highlight = 'None';
row.highlightText = '';
organizations.push(row);
}
subOperators.forEach(function(subOp) {
subOp.Organizations = organizations.filter(function(org) {return org.Code === subOp.Code;});
});
rsMsg.SubOperators = subOperators;
rs.close();
pstmt.close();
conn.close();
outMessages.push(outMsg);
} catch (ex) {
exceptionHandler(ex);
}
output.resultSet = rsMsg;
}
// main
var content = "";
if ($.request.body) {
content = $.request.body.asString();
}
if (checkParams() && checkAuthorization()) {
getData();
//setPhase($.request.parameters.get("billingrunid"), $.request.parameters.get("phase"));
}
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
setOutputMessage();