diff --git a/entity/Pers_entity/conditionProcess.js b/entity/Pers_entity/conditionProcess.js index e3289362d982e85d7a10c4a5bed9bbed2b55fc1b..0459862542c09b13eb4436731ba245e057c52692 100644 --- a/entity/Pers_entity/conditionProcess.js +++ b/entity/Pers_entity/conditionProcess.js @@ -1,15 +1,27 @@ +import("system.db"); import("system.vars"); import("system.result"); -import("Pers_lib"); +import("Sql_lib"); -var orgId = vars.exists("$param.OrgId_param") && vars.get("$param.OrgId_param") - ? vars.get("$param.OrgId_param") - : null; - -var paramObject = { - "orgId":orgId -}; +var orgId, conditionStr, preparedValues + ,sqlHelper; +conditionStr = ""; +preparedValues = []; +sqlHelper = new SqlUtils(); -var generator = persWhereClauseGenerator(paramObject); +if (vars.exists("$param.OrgId_param") && (orgId = vars.getString("$param.OrgId_param"))){ + conditionStr += " and RELATION.ORG_ID = ? "; + preparedValues.push([orgId, sqlHelper.getSingleColumnType("RELATION.ORG_ID")]); + +} -result.string(generator.generate()); \ No newline at end of file +//TODO; add OBJECT_ID (probably another param) +//conditionStr += " and HISTORYLINK.OBJECT_ID = ? " +//preparedValues.push(["1", sqlHelper.getSingleColumnType("HISTORYLINK.OBJECT_ID")]); + +if (conditionStr){ + conditionStr = " 1 = 1 " + conditionStr; + result.string(db.translateCondition([conditionStr, preparedValues])); +} +else + result.string("1 = 1"); \ No newline at end of file diff --git a/entity/Pers_entity/fromClauseProcess.js b/entity/Pers_entity/fromClauseProcess.js index ca3088cbaeacb7eb6700553823eefd8892aab5b5..ea75988bad57d0e046471637898df98b4d4377d1 100644 --- a/entity/Pers_entity/fromClauseProcess.js +++ b/entity/Pers_entity/fromClauseProcess.js @@ -1,5 +1,4 @@ import("system.vars"); import("system.result"); -import("Pers_lib"); result.string("PERS join RELATION on (RELATION.PERS_ID = PERS.PERSID)"); \ No newline at end of file diff --git a/process/Pers_lib/Pers_lib.aod b/process/Pers_lib/Pers_lib.aod deleted file mode 100644 index f5a56c3037220318de82b6113cf88aecb165c438..0000000000000000000000000000000000000000 --- a/process/Pers_lib/Pers_lib.aod +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7"> - <name>Pers_lib</name> - <majorModelMode>DISTRIBUTED</majorModelMode> - <process>%aditoprj%/process/Pers_lib/process.js</process> -</process> diff --git a/process/Pers_lib/process.js b/process/Pers_lib/process.js deleted file mode 100644 index 91f9f28cd3868809177f6b0fcb50d629e82f3e26..0000000000000000000000000000000000000000 --- a/process/Pers_lib/process.js +++ /dev/null @@ -1,95 +0,0 @@ -import("system.logging"); -import("system.vars"); -import("system.result"); -/** - * Function for generating an object, which can generate the from clause of - * PERS_Entity - * - * @class persFromClauseGenerator - * @param {Object} pParamObject contains all neccessary params - */ -function persFromClauseGenerator(pParamObject) -{ - //from clause is empty for now - //TODO add join to relation here, when table exists - var fromClause = "PERS"; - - //generation function for the entity from clause - function _generate() - { - fromClause += " join RELATION on PERS.PERSID = RELATION.PERS_ID "; - if(pParamObject && pParamObject.orgId) - { - fromClause += " join ORG on ORG.ORGID = RELATION.ORG_ID"; - } - - return fromClause; - } - //return an object with the generate function as member - //the function it self and the values are not visible outside - //and therefor savely encapsulated - return { - /** - * - * Generates the from clause for PERS_Entity - * - * @method generate - * @return {String} - */ - "generate":_generate - } -} - - -/** - * Function for getting an object, which can generate the where clause of PERS_Entity - * @class persWhereClauseGenerator - * @param {Object} pParamObject contains all neccessary parameters - */ -function persWhereClauseGenerator(pParamObject) -{ - var whereClause = "" - , whereClauseArr = [] - , i - , len; - - function _generate() - { - if(pParamObject && pParamObject.orgId) - { - whereClauseArr.push("RELATION.ORG_ID = '" + pParamObject.orgId + "'"); - } - - //concating all clauses with and except the first one - len = whereClauseArr.length; - for(i = 0; i < len; i++) - { - whereClause += i ? "and " : "" + whereClauseArr[i] + " "; - } - - return whereClause; - } - - return { - /** - * - * Generates the where clause for PERS_Entity - * - * @method generate - * @return {String} - */ - "generate":_generate - } -} - -Person = function() -{ - this.say = function() - { - logging.log("I'm an Instance!"); - } - function say() - { - logging.log("I'm static!"); - } -} \ No newline at end of file