Skip to content
Snippets Groups Projects
Commit 49af5b2d authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

Comment DataPrivacy_lib

parent 7748c8b8
No related branches found
No related tags found
No related merge requests found
......@@ -86,10 +86,17 @@ DataPrivacyType.get = function(pKey)
/**
* Helper function to get personal data.
* It is used by some callback functions below
*
* @param {String} pContactId
* @param {String} pContactIdSaved
* @param {String} pFields the fields needed from the Contact (person)
*
* @return {Object} containing all rows
*/
function _selectPersonal(pContactId, pContactIdSaved, fields)
function _selectPersonal(pContactId, pContactIdSaved, pFields)
{
fields.push("CONTACTID");
pFields.push("CONTACTID");
if (pContactIdSaved)
pContactId = pContactIdSaved;
......@@ -98,10 +105,39 @@ DataPrivacyType.get = function(pKey)
.entity("Person_entity")
.provider("Contact")
.uid(pContactId)
.fields(fields);
.fields(pFields);
return entities.getRow(entityConfig);
}
/***********
* These functions are used as callback by DSGVO-functions.
* Parameters:
* - The first param is always the contactId of the contact the dataPrivacyInfo is needed for
* - The second param is the Id of the corresponding dataset.
* It is the ID saved in the DSGVO-table and is the ID returned by the these helper fuctions.
* (see Return below)
* Can be undefined, if all dataPrivacy Informations are fetched.
*
* Return:
* the callbacks should return an array of objects:
* [{
* value: names,
* id: persData.CONTACTID
* }, {
* ...
* }]
*
* !! If the Second param is NOT UNDEFINED, the array should only contain one element !!
***********/
/**
* Callback function to fetch the names
*
* @param {String} pContactId
* @param {String} [pContactIdSaved=undefined]
*
* @return {Object[]}
*/
function _getName(pContactId, pContactIdSaved)
{
// Use PersonId as ID, since the data comes from the person
......@@ -126,6 +162,14 @@ DataPrivacyType.get = function(pKey)
}]
}
/**
* Callback function to fetch the birthday of a person
*
* @param {String} pContactId
* @param {String} [pContactIdSaved=undefined]
*
* @return {Object[]}
*/
function _getBirthday(pContactId, pContactIdSaved)
{
// Todo Format or set content dsgvotype
......@@ -137,10 +181,17 @@ DataPrivacyType.get = function(pKey)
}]
}
/**
* Callback function to fetch the Addresses of a Person
*
* @param {String} pContactId
* @param {String} [pAddressId=undefined]
*
* @return {Object[]}
*/
function _getAddress(pContactId, pAddressId)
{
// TODO: update and fix Address_lib and use it (and remove format-functions in PostalAddress_lib)
var entityConfig = entities.createConfigForLoadingRows()
.entity("Address_entity")
.fields(["ADDRESSID", "ADDRESS", "ADDRESSADDITION", "ADDRIDENTIFIER", "BUILDINGNO", "ZIP", "CITY", "COUNTRY", "DISTRICT", "REGION", "PROVINCE"]);
......@@ -168,6 +219,14 @@ DataPrivacyType.get = function(pKey)
return addrData;
}
/**
* Callback function to fetch the Communication addresses of a Person
*
* @param {String} pContactId
* @param {String} [pCommunicationId=undefined]
*
* @return {Object[]}
*/
function _getCommunication(pContactId, pCommunicationId)
{
var entityConfig = entities.createConfigForLoadingRows()
......@@ -193,6 +252,14 @@ DataPrivacyType.get = function(pKey)
});
}
/**
* Callback function to fetch the Attributes of a Person
*
* @param {String} pContactId
* @param {String} [pAttributeId=undefined]
*
* @return {Object[]}
*/
function _getAttribute(pContactId, pAttributeId)
{
var attributeData = [];
......@@ -225,6 +292,14 @@ DataPrivacyType.get = function(pKey)
*/
function DataPrivacyUtils() {}
/**
* Selects the dsgvo-data from the DSGVO table. It already resolves the DSGVO-type display value
*
* @param {String} pContactId
* @param {SqlCondition} [pFilterCond=undefined] Sql condition object containing additional conditions
*
* @return {String[][]} the DSGVO data
*/
DataPrivacyUtils.getDSGVO = function(pContactId, pFilterCond)
{
var cond = SqlCondition.begin().andPrepare("DSGVO.CONTACT_ID", pContactId);
......@@ -250,14 +325,23 @@ DataPrivacyUtils.getDSGVO = function(pContactId, pFilterCond)
}
/**
* If filter conditin is provided, NO inserts are done
* collects all DSGVO-data of a person
*
* This function not only selects the data:
* - It deletes all no longer existing dsgvo-entries.
* - If NO FILTER is provided, it inserts all found data not already existing in DSGVO-table into the DSGVO-table.
*
* @param {String} pContactId
* @param {SqlCondition} [pFilterCond=undefined] Sql condition object containing additional conditions
*
* @return {String[][]} the collected dsgvo data
*/
DataPrivacyUtils.collectAll = function(pContactId, pFilterCond)
{
var contactDSGVO = DataPrivacyUtils.getDSGVO(pContactId, pFilterCond);
// copy data (with .slice()) as we iterate through it and we should not add values while doing this
// NOTE that the arrays inside of contactDSGVO still point to the same arrays as in returnDSGVOData
// NOTE that the arrays inside of contactDSGVO still point to the same arrays as in returnDSGVOData (ByRefference!)
//
// --> contactDSGVO[dat][4] = pRow.value; WILL CHANGE returnDSGVOData[dat][4] ALSO!
// (Yes I could also slice each array in contactDSGVO to returnDSGVOData but this would add overhead which is not needed :-)
......@@ -342,7 +426,11 @@ DataPrivacyUtils.collectAll = function(pContactId, pFilterCond)
}
/**
* Notify the user to update the data privacy informations
* Notify the user to update the data privacy informations.
* It is only displayed if it is a Person.
*
* @param {String} pContactId the current contactId
* @param {Boolean} pShowMessage if false: nothing happens
*/
DataPrivacyUtils.notifyNeedDataPrivacyUpdate = function(pContactId, pShowMessage)
{
......@@ -359,6 +447,36 @@ DataPrivacyUtils.notifyNeedDataPrivacyUpdate = function(pContactId, pShowMessage
}
}
/**
* Check if all data also contains the DSGVO-Informations
*
* Note: this function requires that all pFields in the DSGVO table are updated (via DataPrivacyUtils.collectAll())
* Otherwise there may be fields in DSGVO which do not exist anymore in the person or some are missing.
* @param {String} pContactId the current contactId
*
* @return {Boolean} true if everything is filled correctly
*/
DataPrivacyUtils.checkAllFilled = function(pContactId)
{
var countNotFilled = db.cell(SqlCondition.begin()
.andPrepare("DSGVO.CONTACT_ID", pContactId)
.andSqlCondition(SqlCondition.begin()
.or("STATUORITYSOURCE is null")
.or("PURPOSE is null")
.or("VALID_TO is null"))
.buildSql("select count(*) from DSGVO", "1=2"))
return countNotFilled == "0";
}
/**
* collects the data needed for export functions (e.g. reports, Excel exports, ...)
*
* @param {String} pContactId the current contactId for which the data is exported
* @param {String} pLocale the locale to translate to
*
* @return {String[][]} the data
*/
DataPrivacyUtils.dataForExport = function(pContactId, pLocale)
{
var entity = "DSGVO_entity";
......@@ -385,6 +503,12 @@ DataPrivacyUtils.dataForExport = function(pContactId, pLocale)
})];
}
/**
* generate a CSV and provide it as download
*
* @param {String} pContactId the current contactId for which the data is exported
* @param {String} pLocale the locale to translate to
*/
DataPrivacyUtils.downloadCSV = function(pContactId, pLocale)
{
var data = DataPrivacyUtils.dataForExport(pContactId, pLocale);
......@@ -398,27 +522,30 @@ DataPrivacyUtils.downloadCSV = function(pContactId, pLocale)
neon.download(util.encodeBase64String(csvTable), "data_pricacy.csv");
}
/**
* @return {String} the name of the DSGVO disclosure report
*/
DataPrivacyUtils.DisclosureReportName = function() {
return "DSGVO_Disclosure_report";
}
/**
* Note: this function requires that all fields in the DSGVO table are updated (via DataPrivacyUtils.collectAll())
* Otherwise there may be fields in DSGVO which do not exist anymore in the person or some are missing.
* Opens a DSGVO report
*
* @param {String} pContactId the current contactId for which the data is exported
* @param {String} pReportName the name of the report to load.
* @param {Object} pDSGVOInfo Additional data needed by the reports:
e.g. {
datasource: rowdata["DSGVOINFO.DATASOURCE"],
transmission: rowdata["DSGVOINFO.TRANSMISSION"],
recipient: rowdata["DSGVOINFO.RECIPIENT"],
garantees: rowdata["DSGVOINFO.GUARANTEE"],
requestDate: vars.get("$field.dateRequest"),
deadline: vars.get("$field.deadline"),
deadlineDate: vars.get("$field.dateDeadline")
}
* @param {String} pLocale the locale to translate to
*/
DataPrivacyUtils.checkAllFilled = function(pContactId)
{
var countNotFilled = db.cell(SqlCondition.begin()
.andPrepare("DSGVO.CONTACT_ID", pContactId)
.andSqlCondition(SqlCondition.begin()
.or("STATUORITYSOURCE is null")
.or("PURPOSE is null")
.or("VALID_TO is null"))
.buildSql("select count(*) from DSGVO", "1=2"))
return countNotFilled == "0";
}
DataPrivacyUtils.openReport = function(pContactId, pReportName, pDSGVOInfo, pLocale)
{
if (pLocale == undefined)
......@@ -528,13 +655,15 @@ Muster-Datenschutzberatung";
////////////////////////////////////////////////////////////////////////
// Deprecated functions:
// Deprecated functions: they need to be updated or rewritten to Adito 2019
// Currently not used
/**
* makes selected data from a private contact anonymous
*
* @param pPersId
* @param pContactId
* @param pContactId
* @deprecated
*/
DataPrivacyUtils.dsgvoMkDataAnonymous = function(pPersId, pContactId)
{
......@@ -683,6 +812,7 @@ DataPrivacyUtils.dsgvoMkDataAnonymous = function(pPersId, pContactId)
*
* @example DataPrivacyUtils.anonymizeText("Buchstabe")
* @exampleresult B*******e
* @deprecated
*/
DataPrivacyUtils.anonymizeText = function(pText)
{
......
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