diff --git a/entity/Organisation_entity/recordcontainers/index/affectedIds.js b/entity/Organisation_entity/recordcontainers/index/affectedIds.js index a8b02566f9728cbe5a6c53033c884d780b6a71b8..1145e27816705e214afe62af17257c94b6effe3c 100644 --- a/entity/Organisation_entity/recordcontainers/index/affectedIds.js +++ b/entity/Organisation_entity/recordcontainers/index/affectedIds.js @@ -4,47 +4,52 @@ import("system.vars"); import("IndexSearch_lib"); import("Sql_lib"); -var infoContainer, onUpdFn, tableName, res; +var infoContainer, onUpdFn, tableName, res, action; tableName = vars.get("$local.table"); idValue = vars.get("$local.idvalue"); -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")}); +action = vars.get("$local.action"); -switch (tableName) +if(action == "D") + result.object([idValue]); +else { - case "CONTACT": - res = [idValue]; - break; - case "ORGANISATION": - res = newSelect("CONTACT.CONTACTID") - .from("CONTACT") - .where("CONTACT.PERSON_ID is null") - .and("CONTACT.ORGANISATION_ID", idValue) - .arrayColumn(); - break; - case "ADDRESS": - res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ - return newSelect("ADDRESS.CONTACT_ID") - .from("ADDRESS") - .where("ADDRESS.ADDRESSID", id) - .arrayColumn(); - }); - break; - case "COMMUNICATION": - res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ - return newSelect("COMMUNICATION.CONTACT_ID") - .from("COMMUNICATION") - .where("COMMUNICATION.COMMUNICATIONID", id) - .arrayColumn(); - }); - break; - default: - res = []; //needed, because the Index is being rebuilt if nothing gets returned -} + 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")}); - result.object(res); - + switch (tableName) + { + case "CONTACT": + res = [idValue]; + break; + case "ORGANISATION": + res = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.PERSON_ID is null") + .and("CONTACT.ORGANISATION_ID", idValue) + .arrayColumn(); + break; + case "ADDRESS": + res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ + return newSelect("ADDRESS.CONTACT_ID") + .from("ADDRESS") + .where("ADDRESS.ADDRESSID", id) + .arrayColumn(); + }); + break; + case "COMMUNICATION": + res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ + return newSelect("COMMUNICATION.CONTACT_ID") + .from("COMMUNICATION") + .where("COMMUNICATION.COMMUNICATIONID", id) + .arrayColumn(); + }); + break; + default: + res = []; //needed, because the Index is being rebuilt if nothing gets returned + } + result.object(res); +} \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/index/affectedIds.js b/entity/Person_entity/recordcontainers/index/affectedIds.js index 1cbcfeeb6850a41a4d13165adc198e5e10eb94c8..9388ac445694f7f073d86de5b79daba7422da4f8 100644 --- a/entity/Person_entity/recordcontainers/index/affectedIds.js +++ b/entity/Person_entity/recordcontainers/index/affectedIds.js @@ -4,52 +4,57 @@ import("system.vars"); import("IndexSearch_lib"); import("Sql_lib"); -var infoContainer, onUpdFn, tableName, res; +var infoContainer, onUpdFn, tableName, res, action; tableName = vars.get("$local.table"); idValue = vars.get("$local.idvalue"); -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")}); - -switch (tableName) +action = vars.get("$local.action"); +if (action == "D") + result.object([idValue]); +else { - case "CONTACT": - res = [idValue]; - break; - case "PERSON": - res = newSelect("CONTACT.CONTACTID") - .from("CONTACT") - .where("CONTACT.PERSON_ID", idValue) - .arrayColumn(); - break; - case "ORGANISATION": - res = newSelect("CONTACT.CONTACTID") - .from("CONTACT") - .where("CONTACT.ORGANISATION_ID", idValue) - .and("CONTACT.PERSON_ID is not null") - .arrayColumn(); - break; - case "ADDRESS": - res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ - return newSelect("ADDRESS.CONTACT_ID") - .from("ADDRESS") - .where("ADDRESS.ADDRESSID", id) - .arrayColumn(); - }); - break; - case "COMMUNICATION": - res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ - return newSelect("COMMUNICATION.CONTACT_ID") - .from("COMMUNICATION") - .where("COMMUNICATION.COMMUNICATIONID", id) - .arrayColumn(); - }); - break; - default: - res = []; //needed, because the Index is being rebuilt if nothing gets returned - break; -} + 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")}); + + switch (tableName) + { + case "CONTACT": + res = [idValue]; + break; + case "PERSON": + res = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.PERSON_ID", idValue) + .arrayColumn(); + break; + case "ORGANISATION": + res = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.ORGANISATION_ID", idValue) + .and("CONTACT.PERSON_ID is not null") + .arrayColumn(); + break; + case "ADDRESS": + res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ + return newSelect("ADDRESS.CONTACT_ID") + .from("ADDRESS") + .where("ADDRESS.ADDRESSID", id) + .arrayColumn(); + }); + break; + case "COMMUNICATION": + res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){ + return newSelect("COMMUNICATION.CONTACT_ID") + .from("COMMUNICATION") + .where("COMMUNICATION.COMMUNICATIONID", id) + .arrayColumn(); + }); + break; + default: + res = []; //needed, because the Index is being rebuilt if nothing gets returned + } - result.object(res); \ No newline at end of file + result.object(res); +} \ No newline at end of file