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

[Projekt: Entwicklung - Neon][TicketNr.: 1027750][JDito - libray Standard ist...

[Projekt: Entwicklung - Neon][TicketNr.: 1027750][JDito - libray Standard ist komplett definiert und wird in allen libs verwendet]
refactor IndexSearch_lib
parent 35eb85b4
No related branches found
No related tags found
No related merge requests found
......@@ -2,12 +2,13 @@ import("system.db");
import("system.result");
import("system.vars");
import("IndexSearch_lib");
var indexHelper, infoContainer, onUpdFn, tableName, res;
import("Sql_lib");
var infoContainer, onUpdFn, tableName, res;
indexHelper = new IndexsearchUtils();
tableName = vars.get("$local.table");
idValue = vars.get("$local.idvalue");
infoContainer = indexHelper.createAffectedInfoContainer(idValue, null, vars.get("$local.action")
infoContainer = IndexsearchUtils.createAffectedInfoContainer(idValue, null, vars.get("$local.action")
,function (){return vars.get("$local.columns")}
,function (){return vars.get("$local.oldvalues")}
,function (){return vars.get("$local.values")});
......@@ -21,16 +22,16 @@ switch (tableName)
res = db.array(db.COLUMN, "select RELATION.RELATIONID from RELATION where RELATION.PERS_ID is null and RELATION.ORG_ID = '" + idValue + "'");
break;
case "ADDRESS":
res = indexHelper.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
res = IndexsearchUtils.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
return db.array(db.COLUMN, ["select ADDRESS.RELATION_ID from ADDRESS where ADDRESS.ADDRESSID = ?", [
[id, db.getColumnTypes("ADDRESS", ["ADDRESSID"])[0]]
[id, SqlUtils.getSingleColumnType("ADDRESS", ["ADDRESSID"])]
]]);
});
break;
case "COMM":
res = indexHelper.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
res = IndexsearchUtils.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
return db.array(db.COLUMN, ["select ADDRESS.RELATION_ID from COMM where COMMID = ?", [
[id, db.getColumnTypes("COMM", ["COMMID"])[0]]
[id, SqlUtils.getSingleColumnType("COMM", ["COMMID"])]
]]);
});
break;
......
......@@ -2,12 +2,13 @@ import("system.db");
import("system.result");
import("system.vars");
import("IndexSearch_lib");
var indexHelper, infoContainer, onUpdFn, tableName, res;
import("Sql_lib");
var infoContainer, onUpdFn, tableName, res;
indexHelper = new IndexsearchUtils();
tableName = vars.get("$local.table");
idValue = vars.get("$local.idvalue");
infoContainer = indexHelper.createAffectedInfoContainer(idValue, null, vars.get("$local.action")
infoContainer = IndexsearchUtils.createAffectedInfoContainer(idValue, null, vars.get("$local.action")
,function (){return vars.get("$local.columns")}
,function (){return vars.get("$local.oldvalues")}
,function (){return vars.get("$local.values")});
......@@ -24,16 +25,16 @@ switch (tableName)
res = db.array(db.COLUMN, "select RELATION.RELATIONID from RELATION where RELATION.PERS_ID is not null and RELATION.ORG_ID = '" + idValue + "'");
break;
case "ADDRESS":
res = indexHelper.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
res = IndexsearchUtils.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
return db.array(db.COLUMN, ["select ADDRESS.RELATION_ID from ADDRESS where ADDRESS.ADDRESSID = ?", [
[id, db.getColumnTypes("ADDRESS", ["ADDRESSID"])[0]]
[id, SqlUtils.getSingleColumnType("ADDRESS", ["ADDRESSID"])]
]]);
});
break;
case "COMM":
res = indexHelper.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
res = IndexsearchUtils.getAffectedIdValues("RELATION_ID", infoContainer, function (id){
return db.array(db.COLUMN, ["select ADDRESS.RELATION_ID from COMM where COMMID = ?", [
[id, db.getColumnTypes("COMM", ["COMMID"])[0]]
[id, SqlUtils.getSingleColumnType("COMM", ["COMMID"])]
]]);
});
break;
......
function IndexsearchUtils(){
this.getAffectedIdValues = function(fieldname, affectedInfoContainer, updateFn){
var affectedIds;
switch (affectedInfoContainer.action){
case "I":
affectedIds = [affectedInfoContainer.newValues[affectedInfoContainer.columns.indexOf(fieldname)]];
break;
case "U":
affectedIds = updateFn.call(null, affectedInfoContainer.id);
break;
case "D":
affectedIds = [affectedInfoContainer.oldValues[affectedInfoContainer.columns.indexOf(fieldname)]];
break;
}
return affectedIds || [];
}
this.createAffectedInfoContainer = function(changedIdValue, changedTable, action, columnsFn, oldValueFn, newValueFn){
var res, internalStorage;
internalStorage = {};
res = {
id: changedIdValue
,table: changedTable
,action: action
,columns: null //null for autocomplete in the ADITO-designer
,oldValues: null
,newValues: null
};
Object.defineProperty(res, "columns", {
get: function(){
if (internalStorage["columns"] == undefined)
internalStorage["columns"] = columnsFn.call(null);
return internalStorage["columns"];
}
,set: function (v){
internalStorage["columns"] = v;
}
});
Object.defineProperty(res, "oldValues", {
get: function(){
if (internalStorage["oldValues"] == undefined)
internalStorage["oldValues"] = oldValueFn.call(null);
return internalStorage["oldValues"];
}
,set: function (v){
internalStorage["oldValues"] = v;
}
});
Object.defineProperty(res, "newValues", {
get: function(){
if (internalStorage["newValues"] == undefined)
internalStorage["newValues"] = newValueFn.call(null);
return internalStorage["newValues"];
}
,set: function (v){
internalStorage["newValues"] = v;
}
});
return res;
}
/**
* provides static methods for special handling of entities in JDito-Processes
* do not create an instance of this
* @class
* @static
*/
function IndexsearchUtils(){
}
//todo: comment
IndexsearchUtils.getAffectedIdValues = function(fieldname, affectedInfoContainer, updateFn) {
var affectedIds;
switch (affectedInfoContainer.action){
case "I":
affectedIds = [affectedInfoContainer.newValues[affectedInfoContainer.columns.indexOf(fieldname)]];
break;
case "U":
affectedIds = updateFn.call(null, affectedInfoContainer.id);
break;
case "D":
affectedIds = [affectedInfoContainer.oldValues[affectedInfoContainer.columns.indexOf(fieldname)]];
break;
}
return affectedIds || [];
}
//todo: comment
IndexsearchUtils.createAffectedInfoContainer = function(changedIdValue, changedTable, action, columnsFn, oldValueFn, newValueFn) {
var res, internalStorage;
internalStorage = {};
res = {
id: changedIdValue
,table: changedTable
,action: action
,columns: null //null for autocomplete in the ADITO-designer
,oldValues: null
,newValues: null
};
Object.defineProperty(res, "columns", {
get: function(){
if (internalStorage["columns"] == undefined)
internalStorage["columns"] = columnsFn.call(null);
return internalStorage["columns"];
}
,set: function (v){
internalStorage["columns"] = v;
}
});
Object.defineProperty(res, "oldValues", {
get: function(){
if (internalStorage["oldValues"] == undefined)
internalStorage["oldValues"] = oldValueFn.call(null);
return internalStorage["oldValues"];
}
,set: function (v){
internalStorage["oldValues"] = v;
}
});
Object.defineProperty(res, "newValues", {
get: function(){
if (internalStorage["newValues"] == undefined)
internalStorage["newValues"] = newValueFn.call(null);
return internalStorage["newValues"];
}
,set: function (v){
internalStorage["newValues"] = v;
}
});
return res;
}
\ 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