diff --git a/.liquibase/Data_alias/basic/_demoData/generatedData/duplicates/duplicatescanner.xml b/.liquibase/Data_alias/basic/_demoData/generatedData/duplicates/duplicatescanner.xml index e1c57fcd49efdb883e3bf6bf15b5ccf4f4b58877..c68b0f2baaa28d6c55c52996768f2260aecbb83b 100644 --- a/.liquibase/Data_alias/basic/_demoData/generatedData/duplicates/duplicatescanner.xml +++ b/.liquibase/Data_alias/basic/_demoData/generatedData/duplicates/duplicatescanner.xml @@ -8,7 +8,7 @@ <column name="FILTER_NAME" value="PersonDuplicates" /> <column name="EXTERNAL_SERVICE_USAGE_ALLOWED" valueNumeric="0" /> <column name="ID_FIELD_NAME" value="CONTACTID" /> - <column name="SCAN_PATTERN" value="firstname:({"entityfield": "FIRSTNAME"}) AND lastname:({"entityfield": "LASTNAME"})" /> + <column name="SCAN_PATTERN" value="{"entity":"Person_entity","provider":"indexP","filter":{"type":"group","operator":"AND","childs":[{"type":"row","name":"FIRSTNAME","operator":"ISNOTNULL","value":"","key":"","contenttype":"TEXT"},{"type":"row","name":"LASTNAME","operator":"ISNOTNULL","value":"","key":"","contenttype":"TEXT"}]}}" /> <column name="USER_NEW" value="Admin" /> <column name="DATE_NEW" valueDate="2020-06-26T00:00:00" /> <column name="USER_EDIT" value="Admin" /> @@ -20,7 +20,7 @@ <column name="FILTER_NAME" value="OrganisationDuplicates" /> <column name="EXTERNAL_SERVICE_USAGE_ALLOWED" valueNumeric="0" /> <column name="ID_FIELD_NAME" value="CONTACTID" /> - <column name="SCAN_PATTERN" value="name:({"entityfield": "NAME", "exclude": ["gmbh", "co", "kg", "ag", "bank", "deutsche", "van", "software", "medien", "print"] }) AND city:({"entityfield": "STANDARD_CITY"})" /> + <column name="SCAN_PATTERN" value="{"entity":"Organisation_entity","provider":"indexP","filter":{"type":"group","operator":"AND","childs":[{"type":"row","name":"NAME","operator":"CONTAINSNOT","value":"[\"gmbh\", \"co\", \"kg\", \"ag\", \"bank\", \"deutsche\", \"van\", \"software\", \"medien\", \"print\"]","key":"[\"gmbh\", \"co\", \"kg\", \"ag\", \"bank\", \"deutsche\", \"van\", \"software\", \"medien\", \"print\"]","contenttype":"LONG_TEXT"},{"type":"row","name":"STANDARD_CITY","operator":"ISNOTNULL","value":"","key":"","contenttype":"TEXT"}]}}" /> <column name="USER_NEW" value="Admin" /> <column name="DATE_NEW" valueDate="2020-06-26T00:00:00" /> <column name="USER_EDIT" value="Admin" /> diff --git a/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod b/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod index b7116402fb566724a159f7c003fde69a19901b96..655421fb7bca05d24cae4098039d6815a840d667 100644 --- a/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod +++ b/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod @@ -14,6 +14,7 @@ <entityField> <name>ENTITY_TO_SCAN_NAME</name> <title>Target Entity</title> + <stateProcess>%aditoprj%/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/stateProcess.js</stateProcess> </entityField> <entityField> <name>UID</name> @@ -64,7 +65,9 @@ <entityField> <name>SCAN_PATTERN</name> <title>Scan pattern</title> - <contentType>LONG_TEXT</contentType> + <contentType>FILTER_TREE</contentType> + <state>AUTO</state> + <stateProcess>%aditoprj%/entity/DuplicateScanner_entity/entityfields/scan_pattern/stateProcess.js</stateProcess> </entityField> <entityConsumer> <name>ScannerResultFieldsConfig_Consumer</name> @@ -100,6 +103,8 @@ <dbRecordContainer> <name>DBRecordContainer</name> <alias>Data_alias</alias> + <onDBInsert>%aditoprj%/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBInsert.js</onDBInsert> + <onDBUpdate>%aditoprj%/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBUpdate.js</onDBUpdate> <onDBDelete>%aditoprj%/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> diff --git a/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/stateProcess.js b/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..07c220ad58c1df3eb5e3f6e8b387045763d9ad1e --- /dev/null +++ b/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/stateProcess.js @@ -0,0 +1,9 @@ +import("system.neon"); +import("system.result"); +import("system.vars"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { + result.string(neon.COMPONENTSTATE_EDITABLE); +} else { + result.string(neon.COMPONENTSTATE_READONLY); +} \ No newline at end of file diff --git a/entity/DuplicateScanner_entity/entityfields/scan_pattern/stateProcess.js b/entity/DuplicateScanner_entity/entityfields/scan_pattern/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..256afd274dae777fb192e66457b19415f215a693 --- /dev/null +++ b/entity/DuplicateScanner_entity/entityfields/scan_pattern/stateProcess.js @@ -0,0 +1,9 @@ +import("system.neon"); +import("system.result"); +import("system.vars"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { + result.string(neon.COMPONENTSTATE_INVISIBLE); +} else { + result.string(neon.COMPONENTSTATE_EDITABLE); +} \ No newline at end of file diff --git a/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBInsert.js b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..3c29c7e6c1790f6f53dd7fbb272a21d62f24667d --- /dev/null +++ b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBInsert.js @@ -0,0 +1,8 @@ +import("Sql_lib"); +import("system.neon"); +import("system.vars"); + +var rowdata = vars.get("$local.rowdata"); + +newWhere("DUPLICATESCANNER.ID", rowdata["DUPLICATESCANNER.ID"]) +.updateFields({"DUPLICATESCANNER.SCAN_PATTERN" : JSON.stringify({entity: "" + rowdata["DUPLICATESCANNER.ENTITY_TO_SCAN_NAME"] + "", provider: "indexP", filter: {type: "group", operator: "AND", childs: []}})}, "DUPLICATESCANNER"); \ No newline at end of file diff --git a/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBUpdate.js b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBUpdate.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e53ac00d768ffab9c7f50553de8b2f3d327bed --- /dev/null +++ b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBUpdate.js @@ -0,0 +1,10 @@ +import("system.vars"); + +var rowdata = vars.get("$local.rowdata"); + +let scanPattern = JSON.parse(rowdata["DUPLICATESCANNER.SCAN_PATTERN"]); +if (scanPattern.provider == undefined) +{ + scanPattern.provider = "indexP"; + vars.set("$field.SCAN_PATTERN", JSON.stringify(scanPattern)); +} \ No newline at end of file diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 75a3286746e7c7dde4b390f59fc46d30a3c47fbc..9fe5066d15193284355ea0e53ab9d5efcaf29c40 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1114,6 +1114,10 @@ <parentField>COUNT</parentField> <title>Count</title> </entityAggregateField> + <entityProvider> + <name>indexP</name> + <recordContainer>index</recordContainer> + </entityProvider> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/PermissionDetail_entity/PermissionDetail_entity.aod b/entity/PermissionDetail_entity/PermissionDetail_entity.aod index 8b2a82d1248e5a526244505511c3a5150ea748fe..d6e9a449d7ea9ff95c656fe2f8f4aaa2da8aee12 100644 --- a/entity/PermissionDetail_entity/PermissionDetail_entity.aod +++ b/entity/PermissionDetail_entity/PermissionDetail_entity.aod @@ -131,11 +131,6 @@ <entityName>PermissionMetaData_entity</entityName> <fieldName>MetaData</fieldName> </dependency> - <children> - <entityParameter> - <name>EntityName_param</name> - </entityParameter> - </children> </entityConsumer> <entityParameter> <name>EntityTitle_param</name> diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 907d1408a4c2c5606ddcc61e47249d015939e3e3..a9282ecbdf9541343fa120c712cc703022a07fb9 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -1277,6 +1277,10 @@ <parentField>COUNT</parentField> <title>Count</title> </entityAggregateField> + <entityProvider> + <name>indexP</name> + <recordContainer>index</recordContainer> + </entityProvider> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/neonView/DuplicateScannerEdit_view/DuplicateScannerEdit_view.aod b/neonView/DuplicateScannerEdit_view/DuplicateScannerEdit_view.aod index 267ca200f71bfc159e6e25a565728e3548086719..684c65d5dc6ece746f72a21d0c72a255d3a84a08 100644 --- a/neonView/DuplicateScannerEdit_view/DuplicateScannerEdit_view.aod +++ b/neonView/DuplicateScannerEdit_view/DuplicateScannerEdit_view.aod @@ -23,7 +23,7 @@ <entityField>ENTITY_TO_SCAN_NAME</entityField> </entityFieldLink> <entityFieldLink> - <name>a0eefe38-cd65-432e-819b-e108f44db7f2</name> + <name>840dda8e-0a7a-4c09-80d1-f7cec15b49fc</name> <entityField>ID_FIELD_NAME</entityField> </entityFieldLink> <entityFieldLink> diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index ed3ef2cce6bc01136003468b6c39ac2781c38cd4..92dee1a9b0afef708545cc604351d10c4192a776 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -883,15 +883,49 @@ _DuplicateScannerUtils._buildUpdateResetStandardCommunications = function(pSourc */ _DuplicateScannerUtils._loadIndexPattern = function(pScannerName, pTargetEntity) { - let scanPattern = newSelect("SCAN_PATTERN") + let scanPattern = _DuplicateScannerUtils._filterToScanPattern( newSelect("SCAN_PATTERN") .from("DUPLICATESCANNER") .where("DUPLICATESCANNER.FILTER_NAME", pScannerName) .and("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) - .cell(); + .cell()); scanPattern = scanPattern.trim(); return scanPattern; } + +_DuplicateScannerUtils._filterToScanPattern = function(filterString) { + let filter = JSON.parse(filterString); + return _DuplicateScannerUtils._filterChildsToScanPattern(filter.filter.childs, filter.filter.operator); +} + +_DuplicateScannerUtils._filterChildsToScanPattern = function(childs, operator) { + let group = ""; + for (let i = 0; i < childs.length; i++) { + if (group != ""){ + group = group + " " + operator+ " "; + } + if (childs[i].type == "row"){ + group = group + _DuplicateScannerUtils._filterChildsRowToScanPattern(childs[i].name, childs[i].operator, childs[i].value); + } else if (childs[i].type == "group") { + group = group + "(" + _DuplicateScannerUtils._filterChildsToScanPattern(childs[i].childs, childs[i].operator) + ")"; + } + } + return group; +} + +_DuplicateScannerUtils._filterChildsRowToScanPattern = function (name, operator, value) { + let row = ""; + row = row + name.toLowerCase() + ':({"entityfield":"' + name + '"'; + switch (operator){ + case 'NOT_EQUAL': + row = row + ', "exclude":' + JSON.parse(value); + case 'ISNOTNULL': + row = row + ', "empty":' + false; + } + row = row + '})'; + return row; +} + _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern = function(indexPattern) { return indexPattern.match(/[^{}]+(?=\})/g);