Skip to content
Snippets Groups Projects
Commit 279c958e authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1048244][Importer: Timeout zum Holen...

[Projekt: Entwicklung - Neon][TicketNr.: 1048244][Importer: Timeout zum Holen von Daten soll angegeben werden können]
parent c8c4df25
No related branches found
No related tags found
No related merge requests found
...@@ -13,10 +13,12 @@ import("Importer_lib"); ...@@ -13,10 +13,12 @@ import("Importer_lib");
// TODO: use SqlBuilder // TODO: use SqlBuilder
///////////////////////////////////////////////////////////////////// /*
/// toolkit methods for the import handler /// ┌───────────────────────────────────────────────────────────────┐
/// DO NOT TOUCH - use lib_importerCustomMappingFunctions /// │ toolkit methods for the import handler │
/////////////////////////////////////////////////////////////////// │ DO NOT TOUCH - use lib_importerCustomMappingFunctions │
└───────────────────────────────────────────────────────────────┘
*/
/* /*
* Values of the mapping line: * Values of the mapping line:
...@@ -51,7 +53,8 @@ function iKeyword(pObject) { ...@@ -51,7 +53,8 @@ function iKeyword(pObject) {
values = [id, util.getNewUUID(), container, keyword, sort, "1", "0"]; values = [id, util.getNewUUID(), container, keyword, sort, "1", "0"];
this.insertData(this.getTableCase("ab_keyword_entry"), columns, null, values, this.Config.AliasTo); this.insertData(this.getTableCase("ab_keyword_entry"), columns, null, values, this.Config.AliasTo);
} }
this.setOutput(pObject, id); if (pObject.Target) // no target specified? just try to create a new keyword entry if necessary
this.setOutput(pObject, id);
return true; return true;
} }
...@@ -256,10 +259,7 @@ function iKeywordAttribute(pObject) { ...@@ -256,10 +259,7 @@ function iKeywordAttribute(pObject) {
this.updateData(this.getTableCase("ab_keyword_attributerelation"), [valueColumn], null, [value], cond, this.Config.AliasTo); this.updateData(this.getTableCase("ab_keyword_attributerelation"), [valueColumn], null, [value], cond, this.Config.AliasTo);
} }
} }
this.setOutput(pObject, id); }
} else {
this.setOutput(pObject, aid);
}
return true; return true;
} }
...@@ -290,12 +290,12 @@ function iComm(pObject) { ...@@ -290,12 +290,12 @@ function iComm(pObject) {
var sql = "select " + this.getColumnCase("communicationid") + " from " + this.getTableCase("communication") var sql = "select " + this.getColumnCase("communicationid") + " from " + this.getTableCase("communication")
+" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium_id") + " = ? and " +" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium_id") + " = ? and "
+ this.getColumnCase("standard") + " = ? and " + this.getColumnCase("addr") + " = ?" + this.getColumnCase("isstandard") + " = ? and " + this.getColumnCase("addr") + " = ?"
var id = db.cell([sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR], //TODO: define types dynamically and not hardcoded var id = db.cell([sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR], //TODO: define types dynamically and not hardcoded
[standard, SQLTYPES.SMALLINT], [address, SQLTYPES.VARCHAR]]], this.Config.AliasTo); [standard, SQLTYPES.SMALLINT], [address, SQLTYPES.VARCHAR]]], this.Config.AliasTo);
if (id == "" || id == null) { if (id == "" || id == null) {
var columns = [this.getColumnCase("communicationid"), this.getColumnCase("addr"), var columns = [this.getColumnCase("communicationid"), this.getColumnCase("addr"),
this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("standard")]; this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("isstandard")];
this.insertData(this.getTableCase("communication"), columns, null, [util.getNewUUID(), address, medium, contact, standard], this.Config.AliasTo); this.insertData(this.getTableCase("communication"), columns, null, [util.getNewUUID(), address, medium, contact, standard], this.Config.AliasTo);
} }
return true; return true;
......
import("system.question"); import("system.logging");
import("system.text"); import("system.text");
import("system.db"); import("system.db");
import("Importer_lib"); import("Importer_lib");
...@@ -61,12 +61,12 @@ function ImporterTest() { ...@@ -61,12 +61,12 @@ function ImporterTest() {
var testResult = testCase.fn.call(testCase, cbFn); var testResult = testCase.fn.call(testCase, cbFn);
if (testResult instanceof Importer) { if (testResult instanceof Importer) {
testResult = testResult.process(); testResult = testResult.process();
question.showMessage("Successful: " + testCase.name +"\n" + JSON.stringify(testResult, null, " ")) logging.log("[ImporterTest_lib]Successful: " + testCase.name +"\n" + JSON.stringify(testResult, null, " "))
} else { } else {
question.showMessage("Successful\nResult:\n\n" + testResult) logging.log("[ImporterTest_lib]Successful\nResult:\n\n" + testResult)
} }
} else { } else {
question.showMessage("No test function defined!", question.WARNING) logging.log("[ImporterTest_lib]No test function defined!")
} }
return true; return true;
} }
......
...@@ -11,12 +11,12 @@ import("ImporterCustomMappingFunctions_lib"); ...@@ -11,12 +11,12 @@ import("ImporterCustomMappingFunctions_lib");
import("ImporterMappingFunctions_lib"); import("ImporterMappingFunctions_lib");
// TODO: use SqlBuilder // TODO: use SqlBuilder
/* /*
┌─────────────────────────────────────────────────────────────┐ ┌───────────────────────────────────────────────────────────────
│ importer module constructor function │ importer module constructor function │
│ DO NOT TOUCH - use lib_importerCustomMappingFunctions │ DO NOT TOUCH - use lib_importerCustomMappingFunctions │
└─────────────────────────────────────────────────────────────┘ └───────────────────────────────────────────────────────────────
Frequently asked questions: Frequently asked questions:
...@@ -34,7 +34,7 @@ A: There is a @version-tag in the documentation of the Importer-function (const ...@@ -34,7 +34,7 @@ A: There is a @version-tag in the documentation of the Importer-function (const
* the importer class, main object * the importer class, main object
* @param {String []} pConfig req ( Name, FunktionsArt, Details ) * @param {String []} pConfig req ( Name, FunktionsArt, Details )
* *
* @version 2.1 * @version 2.2
* *
* *
* @return {void} * @return {void}
...@@ -99,11 +99,12 @@ function Importer(pConfig) ...@@ -99,11 +99,12 @@ function Importer(pConfig)
this.ErrorLog = ""; this.ErrorLog = "";
this.DataType = null; this.DataType = null;
this.KeyColumn = new Object(); // contains key info as in KeyColumn["tbl.col"] = "I" | "U" | "I+U" this.KeyColumn = new Object(); // contains key info as in KeyColumn["tbl.col"] = "I" | "U" | "I+U"
this.UseAOType = true; //default true, so that AOType will be uses (for older systems) this.UseAOType = true; //default true, so that AOType will be uses (for legacy systems)
this.UseUUID = true; //default false, so that db.getNewID() instead of util.getNewUUID() would be uses this.UseUUID = true; //default true, so that util.getNewUUID() is used since this is what you want most time
this.TableCase = this.Cases.Upper; //default is uppercase this.TableCase = this.Cases.Upper; //default is uppercase
this.ColumnCase = this.Cases.Upper; //default is uppercase this.ColumnCase = this.Cases.Upper; //default is uppercase
this.skipEmptyValue = true; this.skipEmptyValue = true;
this._dbTimeoutGeneral = null;//timeout for all purposes, should be set via the setTimeout function and retrieved via the getTimeout function
this.AttributeCache = undefined; this.AttributeCache = undefined;
this.useAttributeCache = false; this.useAttributeCache = false;
...@@ -634,7 +635,7 @@ function Importer(pConfig) ...@@ -634,7 +635,7 @@ function Importer(pConfig)
{ {
insertSuccessfull = false; insertSuccessfull = false;
var startInsert = datetime.date(); var startInsert = datetime.date();
db.inserts(this.insertArray, this.Config.AliasTo); db.inserts(this.insertArray, this.Config.AliasTo, this.getConfiguredTimeout(Importer.TIMEOUT.INSERT));
exectimer.dbInsertTime += datetime.date() - startInsert; exectimer.dbInsertTime += datetime.date() - startInsert;
this.recordCounts.insert++; this.recordCounts.insert++;
insertSuccessfull = true; insertSuccessfull = true;
...@@ -649,7 +650,7 @@ function Importer(pConfig) ...@@ -649,7 +650,7 @@ function Importer(pConfig)
{ {
updateSuccessfull = false; updateSuccessfull = false;
var startUpdate = datetime.date(); var startUpdate = datetime.date();
db.updates(this.updateArray, this.Config.AliasTo); db.updates(this.updateArray, this.Config.AliasTo, this.getConfiguredTimeout(Importer.TIMEOUT.UPDATE));
exectimer.dbUpdateTime += datetime.date() - startUpdate; exectimer.dbUpdateTime += datetime.date() - startUpdate;
this.recordCounts.update++; this.recordCounts.update++;
updateSuccessfull = true; updateSuccessfull = true;
...@@ -874,7 +875,7 @@ function Importer(pConfig) ...@@ -874,7 +875,7 @@ function Importer(pConfig)
if(this.Config.IdQuery == undefined || this.Config.IdColumn == undefined) if(this.Config.IdQuery == undefined || this.Config.IdColumn == undefined)
{ {
//new method for batch-processsing (paging) //new method for batch-processsing (paging)
daten = db.tablePage(this.Config.DataQuery, this.Config.AliasFrom, batchStart, bs); daten = db.tablePage(this.Config.DataQuery, this.Config.AliasFrom, batchStart, bs, this.getConfiguredTimeout(Importer.TIMEOUT.QUERY_DATA));
batchStart += bs; batchStart += bs;
//this happens when all-records % pBlockSize == 0 //this happens when all-records % pBlockSize == 0
...@@ -898,7 +899,7 @@ function Importer(pConfig) ...@@ -898,7 +899,7 @@ function Importer(pConfig)
// get data of the next batch // get data of the next batch
var sql = this.Config.DataQuery.replace(/\$\$id/i, idcolumn + " in ('" + batchList.join("','") + "')" ); var sql = this.Config.DataQuery.replace(/\$\$id/i, idcolumn + " in ('" + batchList.join("','") + "')" );
daten = db.table(sql, this.Config.AliasFrom); daten = db.table(sql, this.Config.AliasFrom, db.DB_EOF, this.getConfiguredTimeout(Importer.TIMEOUT.QUERY_DATA));
} }
else else
{ {
...@@ -913,7 +914,7 @@ function Importer(pConfig) ...@@ -913,7 +914,7 @@ function Importer(pConfig)
if(batchNum > 1) if(batchNum > 1)
daten = null; daten = null;
else else
daten = db.table(this.Config.DataQuery, this.Config.AliasFrom); daten = db.table(this.Config.DataQuery, this.Config.AliasFrom, db.DB_EOF, this.getConfiguredTimeout(Importer.TIMEOUT.QUERY_DATA));
} }
tt = datetime.date() - tt; tt = datetime.date() - tt;
exectimer["getdata"] += tt; exectimer["getdata"] += tt;
...@@ -935,7 +936,7 @@ function Importer(pConfig) ...@@ -935,7 +936,7 @@ function Importer(pConfig)
importtype = "M"; importtype = "M";
// get the list of primary keys // get the list of primary keys
resIDList = db.array(db.COLUMN, pConfig.IdQuery, pConfig.AliasFrom); resIDList = db.array(db.COLUMN, pConfig.IdQuery, pConfig.AliasFrom, db.DB_EOF, this.getConfiguredTimeout(Importer.TIMEOUT.QUERY_DATA));
tt = datetime.date() - tt; tt = datetime.date() - tt;
exectimer["getdata"] += tt; exectimer["getdata"] += tt;
} }
...@@ -1377,9 +1378,8 @@ function Importer(pConfig) ...@@ -1377,9 +1378,8 @@ function Importer(pConfig)
} }
catch(ex) catch(ex)
{ {
this.writeLog(this.LogLevels.Error, "Property <Target> not set for mapping object!"); logging.log(ex["rhinoException"] != undefined ? ex["rhinoException"] : ex);
logging.log(ex); this.writeLog(this.LogLevels.Error, "Property <Target> not set for mapping object:pObject=" + JSON.stringify(pObject));
logging.log("[IMPORTER] Property <Target> not set for mapping object!");
} }
} }
// get the content of the output record buffer according to "Action" performed // get the content of the output record buffer according to "Action" performed
...@@ -1511,6 +1511,62 @@ function Importer(pConfig) ...@@ -1511,6 +1511,62 @@ function Importer(pConfig)
} }
} }
Importer.TIMEOUT = {
/**
* timeout for simple queries, that may run iterative and *normally* for a shorter execution time
*/
//QUERY_ORDINARY: "query_ordinray",//currently disabled because of: #1049095
/**
* timeout for more complex queries, that may often return lots of records
*/
QUERY_DATA: "query_data",
/**
* timeout for insert statements
*/
INSERT: "insert",
/**
* timeout for update statements
*/
UPDATE: "update"
};
/**
* returns the configured timeout value for a specific timeouttpye
*
* @param pTimeoutType possible values are Importer.TIMEOUT.****
*
* @return {Number} timeout that is configured, if none is configured 0 is returned
*/
Importer.prototype.getConfiguredTimeout = function(pTimeoutType)
{
if (pTimeoutType && this.Config.dbTimeout && this.Config.dbTimeout[pTimeoutType] != null)
return this.Config.dbTimeout[pTimeoutType];
else if (this._dbTimeoutGeneral != null)
return this._dbTimeoutGeneral;
else
return 0;
};
/**
* sets the timeout time for a specific type or if no type was given a general timeouttime for the importer
*
* @param {Number} pTimeout timeout time for the given time in milliseconds
* @param {String} [pTimeoutType] possible values are Importer.TIMEOUT.****; if this is empty a general timeouttime is set
*
*
* @return {Number} timeout that is configured, if none is configured 0 is returned
*/
Importer.prototype.setTimeout = function(pTimeout, pTimeoutType)
{
if (pTimeout != undefined)
{
if (pTimeoutType)
this.Config.dbTimeout[pTimeoutType] = pTimeout;
else
this._dbTimeoutGeneral = pTimeout;
}
};
/** /**
* Data handler for csv paging * Data handler for csv paging
* *
...@@ -1573,6 +1629,4 @@ function batchCsvLoad(pCurrentBatchNum, pBatchSize) ...@@ -1573,6 +1629,4 @@ function batchCsvLoad(pCurrentBatchNum, pBatchSize)
} }
while(dataStr != null); while(dataStr != null);
return null; return null;
} }
\ No newline at end of file
= _test_importer = _test_importer
Executeable Process for testing the importer. This process also provides an example for using the importer module. Executeable Process for testing the importer. This process also provides an example for using the importer module, however it may be more complex
\ No newline at end of file than an actual importprocess should look like.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment