From dad4b5816ecc90213accaccadef0e12244e53487 Mon Sep 17 00:00:00 2001
From: Andre Loreth <a.loreth@adito.de>
Date: Wed, 19 Feb 2020 09:58:09 +0100
Subject: [PATCH] #1051579: Implement DSGVOReport context

---
 .../DSGVOReport_entity/DSGVOReport_entity.aod | 47 +++++++++++++++++++
 .../entityfields/report_data/valueProcess.js  |  6 +++
 .../recordcontainer/contentProcess.js         |  3 ++
 .../openinforeport/onActionProcess.js         |  4 +-
 neonContext/DSGVOReport/DSGVOReport.aod       | 12 +++++
 .../DSGVOReport_view/DSGVOReport_view.aod     | 17 +++++++
 process/DataPrivacy_lib/process.js            | 15 +++++-
 7 files changed, 101 insertions(+), 3 deletions(-)
 create mode 100644 entity/DSGVOReport_entity/DSGVOReport_entity.aod
 create mode 100644 entity/DSGVOReport_entity/entityfields/report_data/valueProcess.js
 create mode 100644 entity/DSGVOReport_entity/recordcontainers/recordcontainer/contentProcess.js
 create mode 100644 neonContext/DSGVOReport/DSGVOReport.aod
 create mode 100644 neonView/DSGVOReport_view/DSGVOReport_view.aod

diff --git a/entity/DSGVOReport_entity/DSGVOReport_entity.aod b/entity/DSGVOReport_entity/DSGVOReport_entity.aod
new file mode 100644
index 00000000000..c69e9f115cc
--- /dev/null
+++ b/entity/DSGVOReport_entity/DSGVOReport_entity.aod
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.13" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.13">
+  <name>DSGVOReport_entity</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <recordContainer>recordContainer</recordContainer>
+  <entityFields>
+    <entityProvider>
+      <name>#PROVIDER</name>
+    </entityProvider>
+    <entityParameter>
+      <name>ContactID_param</name>
+      <expose v="true" />
+      <mandatory v="false" />
+    </entityParameter>
+    <entityParameter>
+      <name>ReportName_param</name>
+      <expose v="true" />
+      <mandatory v="false" />
+    </entityParameter>
+    <entityParameter>
+      <name>DSGVOInfo_param</name>
+      <title></title>
+      <expose v="true" />
+      <mandatory v="false" />
+      <description></description>
+    </entityParameter>
+    <entityField>
+      <name>REPORT_DATA</name>
+      <valueProcess>%aditoprj%/entity/DSGVOReport_entity/entityfields/report_data/valueProcess.js</valueProcess>
+    </entityField>
+    <entityField>
+      <name>UID</name>
+    </entityField>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>recordContainer</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/DSGVOReport_entity/recordcontainers/recordcontainer/contentProcess.js</contentProcess>
+      <recordFieldMappings>
+        <jDitoRecordFieldMapping>
+          <name>UID.value</name>
+        </jDitoRecordFieldMapping>
+      </recordFieldMappings>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/DSGVOReport_entity/entityfields/report_data/valueProcess.js b/entity/DSGVOReport_entity/entityfields/report_data/valueProcess.js
new file mode 100644
index 00000000000..2e61138143c
--- /dev/null
+++ b/entity/DSGVOReport_entity/entityfields/report_data/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.result");
+import("system.vars");
+import("system.logging");
+import("DataPrivacy_lib")
+
+result.string(DataPrivacyUtils.buildReport(vars.get("$param.ContactID_param"), vars.get("$param.ReportName_param"), JSON.parse(vars.get("$param.DSGVOInfo_param"))));
\ No newline at end of file
diff --git a/entity/DSGVOReport_entity/recordcontainers/recordcontainer/contentProcess.js b/entity/DSGVOReport_entity/recordcontainers/recordcontainer/contentProcess.js
new file mode 100644
index 00000000000..8a2abf765ba
--- /dev/null
+++ b/entity/DSGVOReport_entity/recordcontainers/recordcontainer/contentProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.object([["1"]]);
\ No newline at end of file
diff --git a/entity/DSGVO_entity/entityfields/reports/children/openinforeport/onActionProcess.js b/entity/DSGVO_entity/entityfields/reports/children/openinforeport/onActionProcess.js
index 23afc7e82ee..1ea74f266d1 100644
--- a/entity/DSGVO_entity/entityfields/reports/children/openinforeport/onActionProcess.js
+++ b/entity/DSGVO_entity/entityfields/reports/children/openinforeport/onActionProcess.js
@@ -16,6 +16,6 @@ if (entities.getRowCount(conf) > 0)
 
 neon.openContext("DSGVOInfo", "DSGVOInfoEdit_view", null, mode, 
                     {
-                        ContactId_param: vars.get("$field.CONTACT_ID"),
-                        ReportType_param: "DSGVO_Information_report"
+                        "param.ContactId_param": vars.get("$field.CONTACT_ID"),
+                        "param.ReportType_param": "DSGVO_Information_report"
                     });
\ No newline at end of file
diff --git a/neonContext/DSGVOReport/DSGVOReport.aod b/neonContext/DSGVOReport/DSGVOReport.aod
new file mode 100644
index 00000000000..db8e5d9e15e
--- /dev/null
+++ b/neonContext/DSGVOReport/DSGVOReport.aod
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1">
+  <name>DSGVOReport</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entity>DSGVOReport_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>20227ee7-acc3-442b-a89a-5512179c0cdf</name>
+      <view>DSGVOReport_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonView/DSGVOReport_view/DSGVOReport_view.aod b/neonView/DSGVOReport_view/DSGVOReport_view.aod
new file mode 100644
index 00000000000..7359d66a899
--- /dev/null
+++ b/neonView/DSGVOReport_view/DSGVOReport_view.aod
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.4" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.4">
+  <name>DSGVOReport_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <reportViewTemplate>
+      <name>Report</name>
+      <reportData>REPORT_DATA</reportData>
+      <entityField>#ENTITY</entityField>
+    </reportViewTemplate>
+  </children>
+</neonView>
diff --git a/process/DataPrivacy_lib/process.js b/process/DataPrivacy_lib/process.js
index f1bda31c814..2978c36efa5 100644
--- a/process/DataPrivacy_lib/process.js
+++ b/process/DataPrivacy_lib/process.js
@@ -557,6 +557,18 @@ DataPrivacyUtils.DisclosureReportName = function() {
  * @param {String} pLocale the locale to translate to
  */
 DataPrivacyUtils.openReport = function(pContactId, pReportName, pDSGVOInfo, pLocale)
+{
+    neon.openContext("DSGVOReport", "DSGVOReport_view", [], neon.OPERATINGSTATE_VIEW, {
+        "param.ReportName_param": pReportName,
+        "param.ContactID_param": pContactId,
+        "param.DSGVOInfo_param": JSON.stringify(pDSGVOInfo)
+    });
+}
+
+/**
+ * Will build the DSGVO disclosure report.
+ */
+DataPrivacyUtils.buildReport = function (pContactId, pReportName, pDSGVOInfo, pLocale)
 {
     if (pLocale == undefined)
         pLocale = vars.get("$sys.clientlocale");
@@ -659,7 +671,8 @@ Muster-Datenschutzberatung";
     DSGVOReport.setReportData(ReportData.begin(dsgvoData[0]).add(dsgvoData[1]));
     DSGVOReport.addImage("myLogo", imgData[1]);
     DSGVOReport.addReportParams(params);
-    DSGVOReport.openReport();
+    
+    return DSGVOReport.exportReport();
 }
 
 
-- 
GitLab