From a8f24d7f0ed950c2d0f440ce5e55e84fc75a4ef6 Mon Sep 17 00:00:00 2001 From: Maria Hofmann <m.hofmann@adito.de> Date: Wed, 19 Jun 2019 16:22:07 +0200 Subject: [PATCH] collect Data for table, etc --- entity/DSGVO_entity/DSGVO_entity.aod | 11 +- .../entityfields/value/dropDownProcess.js | 40 ++++ .../entityfields/value/valueProcess.js | 0 .../medium.value/expression.js | 4 + .../value.value/expression.js | 4 + .../entityfields/dsgvoentries/stateProcess.js | 3 +- process/DSGVO_lib/process.js | 203 ++++++++++++++---- 7 files changed, 225 insertions(+), 40 deletions(-) create mode 100644 entity/DSGVO_entity/entityfields/value/dropDownProcess.js create mode 100644 entity/DSGVO_entity/entityfields/value/valueProcess.js create mode 100644 entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/medium.value/expression.js diff --git a/entity/DSGVO_entity/DSGVO_entity.aod b/entity/DSGVO_entity/DSGVO_entity.aod index bda48297ab..56fc5b7998 100644 --- a/entity/DSGVO_entity/DSGVO_entity.aod +++ b/entity/DSGVO_entity/DSGVO_entity.aod @@ -167,7 +167,7 @@ <onActionProcess>%aditoprj%/entity/DSGVO_entity/entityfields/dsgvoactions/children/anonymperson/onActionProcess.js</onActionProcess> <actionOrder v="0" /> <isSelectionAction v="true" /> - <iconId>VAADIN:MEH_O</iconId> + <iconId>VAADIN:ASTERISK</iconId> <stateProcess>%aditoprj%/entity/DSGVO_entity/entityfields/dsgvoactions/children/anonymperson/stateProcess.js</stateProcess> </entityActionField> </children> @@ -177,6 +177,7 @@ <title>Value</title> <mandatory v="true" /> <dropDownProcess>%aditoprj%/entity/DSGVO_entity/entityfields/value/dropDownProcess.js</dropDownProcess> + <valueProcess>%aditoprj%/entity/DSGVO_entity/entityfields/value/valueProcess.js</valueProcess> </entityField> <entityConsumer> <name>KeywordTablename</name> @@ -265,6 +266,14 @@ <name>PURPOSE.value</name> <recordfield>DSGVO.PURPOSE</recordfield> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>VALUE.value</name> + <expression>%aditoprj%/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/value.value/expression.js</expression> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>MEDIUM.value</name> + <expression>%aditoprj%/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/medium.value/expression.js</expression> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> </recordContainers> diff --git a/entity/DSGVO_entity/entityfields/value/dropDownProcess.js b/entity/DSGVO_entity/entityfields/value/dropDownProcess.js new file mode 100644 index 0000000000..4cd9231de6 --- /dev/null +++ b/entity/DSGVO_entity/entityfields/value/dropDownProcess.js @@ -0,0 +1,40 @@ +import("system.logging"); +import("system.result"); +import("system.vars"); +import("Sql_lib"); +import("system.db"); +import("DSGVO_lib"); + +/*var addr = db.table(SqlCondition.begin() + .andPrepare("CONTACT.PERSON_ID", vars.get("$param.currentPerson_param")) + .buildSql("select ADDRESS, ADDRESSADDITION, ADDRIDENTIFIER, BUILDINGNO, CITY, COUNTRY, DISTRICT, REGION, STATE, ZIP from ADDRESS join CONTACT on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID", "1 = 1")); + +var comm = db.table(SqlCondition.begin() + //.andPrepare("COMMUNICATION.CONTACT_ID", vars.get("$field.CONTACT_ID")) + .andPrepare("CONTACT.PERSON_ID", vars.get("$param.currentPerson_param")) + .buildSql("select ADDR, MEDIUM_ID from COMMUNICATION join CONTACT on COMMUNICATION.CONTACT_ID = CONTACTID", "1 = 1")); +//var sql3 = db.table(SqlCondition.begin().andPrepare("AB_ATTRIBUTE.CONTACT_ID", vars.get("$field.CONTACT_ID")).buildSql("select * from AB_ATTRIBUTE", "1 = 1")); +var pers = db.table(SqlCondition.begin() + .andPrepare("PERSON.PERSONID", vars.get("$param.currentPerson_param")) + .buildSql("select DATEOFBIRTH, FIRSTNAME, MIDDLENAME, LASTNAME, GENDER, SALUTATION, TITLE, TITLESUFFIX, PICTURE from PERSON", "1 = 1")); + +var data = new Array(); + +for(i = 0; i < addr.length; i++) +{ + data.push(["Address-" + i, addr[i][4]]); +} + +for(i = 0; i < comm.length; i++) +{ + data.push(["Comm-"+i, comm[i][0]]); +} + +for(i = 0; i < pers.length; i++) +{ + data.push(["Personal-"+i, pers[i][3]]); +} + +result.object(data);*/ + +result.object(getDSGVOTable(vars.get("$param.currentPerson_param"), "combo")); \ No newline at end of file diff --git a/entity/DSGVO_entity/entityfields/value/valueProcess.js b/entity/DSGVO_entity/entityfields/value/valueProcess.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/medium.value/expression.js b/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/medium.value/expression.js new file mode 100644 index 0000000000..ede49d26ae --- /dev/null +++ b/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/medium.value/expression.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("DSGVO_lib"); + +//getDSGVOTable(vars.get("$param.currentPerson_param"), "medium"); \ No newline at end of file diff --git a/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/value.value/expression.js b/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/value.value/expression.js index e69de29bb2..95250baeba 100644 --- a/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/value.value/expression.js +++ b/entity/DSGVO_entity/recordcontainers/db/recordfieldmappings/value.value/expression.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("DSGVO_lib"); + +//getDSGVOTable(vars.get("$param.currentPerson_param"), "value"); diff --git a/entity/Person_entity/entityfields/dsgvoentries/stateProcess.js b/entity/Person_entity/entityfields/dsgvoentries/stateProcess.js index 6803ced6de..447260b2aa 100644 --- a/entity/Person_entity/entityfields/dsgvoentries/stateProcess.js +++ b/entity/Person_entity/entityfields/dsgvoentries/stateProcess.js @@ -1,10 +1,9 @@ -import("system.logging"); import("system.result"); import("system.project"); import("system.neon"); var isActive = project.getPreferenceValue("custom.dsgvo.active"); -logging.log(isActive); + if(isActive) { result.string(neon.COMPONENTSTATE_EDITABLE); diff --git a/process/DSGVO_lib/process.js b/process/DSGVO_lib/process.js index 969e47f86c..b461e37581 100644 --- a/process/DSGVO_lib/process.js +++ b/process/DSGVO_lib/process.js @@ -1,3 +1,5 @@ +import("system.logging"); +import("Keyword_lib"); import("system.translate"); import("Sql_lib"); import("system.util"); @@ -5,54 +7,181 @@ import("system.vars"); import("system.db"); import("system.neon"); import("system.result"); +import("KeywordRegistry_basic"); -function newDSGVOEntry(pContactId) +function getDSGVOTable (pPerson, pType) { - var contact = vars.get("$field.CONTACT_ID"); - var res = new Object(); + var addr = db.table(SqlCondition.begin() + .andPrepare("CONTACT.PERSON_ID", pPerson) + .buildSql("select ADDRESS, ADDRESSADDITION, ADDRIDENTIFIER, BUILDINGNO, CITY, COUNTRY, DISTRICT, REGION, STATE, ZIP from ADDRESS join CONTACT on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID", "1 = 1")); - var addrData = db.table(SqlCondition.begin() - .andPrepare("ADDRESS.CONTACT_ID", vars.get("$field.CONTACT_ID")) - .buildSql("select ADDRESSID, ADDRESS, ADDRESSADDITION, ADDRINTENTIFIER, BUILDINGNO, " - + "CITY, COUNTRY, DISTRICT, REGION, STATE, ZIP, CONTACT_ID from ADDRESS", "1 = 1")); + var comm = db.table(SqlCondition.begin() + //.andPrepare("COMMUNICATION.CONTACT_ID", vars.get("$field.CONTACT_ID")) + .andPrepare("CONTACT.PERSON_ID", pPerson) + .buildSql("select ADDR, MEDIUM_ID from COMMUNICATION join CONTACT on COMMUNICATION.CONTACT_ID = CONTACTID", "1 = 1")); + //var sql3 = db.table(SqlCondition.begin().andPrepare("AB_ATTRIBUTE.CONTACT_ID", vars.get("$field.CONTACT_ID")).buildSql("select * from AB_ATTRIBUTE", "1 = 1")); + var pers = db.table(SqlCondition.begin() + .andPrepare("PERSON.PERSONID", pPerson) + .buildSql("select DATEOFBIRTH, FIRSTNAME, MIDDLENAME, LASTNAME, GENDER, SALUTATION, TITLE, TITLESUFFIX, PICTURE from PERSON", "1 = 1")); - var persData = db.table(SqlCondition.begin() - .andPrepare("PERSON.PERSONID", vars.get("$field.CONTACT_ID")) - .buildSql("select PERSONID, DATEOFBIRTH, FIRSTNAME, MIDDLENAME, LASTNAME, GENDER, " - + "SALUTATION, TITLE, TITLESUFFIX, PICTURE from PERSON", "1 = 1")); - - var commData = db.table(SqlCondition.begin() - .andPrepare("COMMUNICATION.CONTACT_ID", vars.get("$field.CONTACT_ID")) - .buildSql("select COMMUNICATIONID, MEDIUM_ID, ADDR from COMMUNICATION", "1 = 1")); - - - // ATTR : ?? + // var data = new Array(); + var mediumData = new Array(); + var valueData = new Array(); + var allData = new Array(); - res[""] = ""; - - + for(i = 0; i < addr.length; i++) + { + var entry = null; + if(addr[i][0] != null) + { + mediumData.push("Street-" + i); + valueData.push(addr[i][0]); + } + if(addr[i][1] != null) + { + mediumData.push("Addressaddition-" + i); + valueData.push(addr[i][1]); + } + if(addr[i][2] != null) + { + mediumData.push("Addressident-" + i); + valueData.push(addr[i][2]); + } + if(addr[i][3] != null) + { + mediumData.push("Buildingno-" + i); + valueData.push(addr[i][3]); + } + if(addr[i][4] != null) + { + mediumData.push("City-" + i); + valueData.push(addr[i][4]); + entry = addr[i][4]; + } + if(addr[i][5] != null) + { + mediumData.push("Country-" + i); + valueData.push(addr[i][5]); + } + if(addr[i][6] != null) + { + mediumData.push("District-" + i); + valueData.push(addr[i][6]); + if(entry == null) + entry = addr[i][6]; + } + if(addr[i][7] != null) + { + mediumData.push("Region-" + i); + valueData.push(addr[i][7]); + if(entry == null) + entry = addr[i][7]; + } + if(addr[i][8] != null) + { + mediumData.push("State-" + i); + valueData.push(addr[i][8]); + } + if(addr[i][9] != null) + { + mediumData.push("ZIP-" + i); + valueData.push(addr[i][9]); + if(entry == null) + entry = addr[i][9]; + } + if(entry != null) + allData.push(["Address-" + i , entry]); + } + for(i = 0; i < comm.length; i++) + { + // TODO .... funktioniert nicht, findet gar keine Comms mehr + if(comm[i][0] && comm[i][1]) + { + var medium = KeywordUtils.getViewValue($KeywordRegistry.communicationMedium(), comm[i][1]); + if(medium != null) + { + mediumData.push(medium) + logging.log(medium); + valueData.push(comm[i][0]); + allData.push(["Communication-" + (allData.length + i), medium]) + } + } + } -// for each entry -// insert into DSGVO (DSGVOID, USER_NEW, DATE_NEW, USER_EDIT, DATE_EDIT, ROW_ID, RIGHT, USE, TABLENAME, VALID_TO, CONTACT_ID) -// DSGVOID if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) result.string(util.getNewUUID()); -// USER_NEW if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) result.string(vars.get("$sys.user")); -// DATE_NEW if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) result.string(vars.get("$sys.date")); -// USER_EDIT null -// DATE_EDIT null -// ROW_ID -entspr. Tablename&ID raussuchen -// RIGHT -Auswahl -// USE -Auswahl -// TABLENAME -von Auswahl schließen -// VALID_TO -Auswahl -// CONTACT_ID pContactId + for(i = 0; i < pers.length; i++) + { + var entry = null; + if(pers[i][0] != null) + { + mediumData.push("Date of Birth-" + i); + valueData.push(pers[i][0]); + } + if(pers[i][1] != null) + { + mediumData.push("Firstname-" + i); + valueData.push(pers[i][1]); + } + if(pers[i][2] != null) + { + mediumData.push("Middlename-" + i); + valueData.push(pers[i][2]); + } + if(pers[i][3] != null) + { + mediumData.push("Lastname-" + i); + valueData.push(pers[i][3]); + entry = pers[i][3]; + } + if(pers[i][4] != null) + { + mediumData.push("Gender-" + i); + valueData.push(pers[i][4]); + } + if(pers[i][5] != null) + { + mediumData.push("Salutation-" + i); + valueData.push(pers[i][5]); + } + if(pers[i][6] != null) + { + mediumData.push("Title-" + i); + valueData.push(pers[i][6]); + } + if(pers[i][7] != null) + { + mediumData.push("Title suffix-" + i); + valueData.push(pers[i][7]); + } + if(pers[i][8] != null) { + mediumData.push("Picture-" + i); + valueData.push(pers[i][8]); + if(entry == null) + entry = pers[i][8]; + } + + if(entry != null) + allData.push(["Personal-" + allData.length + i, entry]); + } + //logging.log(mediumData.length); + //logging.log(valueData.length); + logging.log(allData.length); + allData.forEach(function (entry) + { + logging.log(entry); + }) + + if(pType == "medium") + result.object(mediumData); + else if(pType == "value") + result.object(valueData); + else if(pType == "combo") + result.object(allData); +} - -} - function insertUpdatePrivacyData(pTableData, pPersRelId){ var relid = pPersRelId; var insertData = []; -- GitLab