From 877d745e321a19f7f1b7fb52e4580b4f35c44367 Mon Sep 17 00:00:00 2001 From: "s.pongratz" <s.pongratz@adito.de> Date: Tue, 30 Jun 2020 16:24:03 +0200 Subject: [PATCH] #1058737-DublettenKonfiguration scan_pattern change type to FILTER_TREE --- .../DuplicateScanner_entity.aod | 5 ++- .../entity_to_scan_name/onValueChange.js | 7 ++++ .../entityfields/scan_pattern/stateProcess.js | 9 +++++ .../Organisation_entity.aod | 4 +++ entity/Person_entity/Person_entity.aod | 4 +++ .../DuplicateScannerEdit_view.aod | 2 +- process/DuplicateScanner_lib/process.js | 35 +++++++++++++++++-- 7 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/onValueChange.js create mode 100644 entity/DuplicateScanner_entity/entityfields/scan_pattern/stateProcess.js diff --git a/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod b/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod index b7116402fb..3334ff8a07 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> + <onValueChange>%aditoprj%/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/onValueChange.js</onValueChange> </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> diff --git a/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/onValueChange.js b/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/onValueChange.js new file mode 100644 index 0000000000..b696837f0f --- /dev/null +++ b/entity/DuplicateScanner_entity/entityfields/entity_to_scan_name/onValueChange.js @@ -0,0 +1,7 @@ +import("system.neon"); +import("system.vars"); + +if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) { + var entity = vars.get("$this.value"); + vars.set("$field.SCAN_PATTERN", JSON.stringify({entity: "" + entity + "", provider: "indexP", filter: {type: "group", operator: "AND", childs: []}})); +} \ 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 0000000000..256afd274d --- /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/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 875ad026d6..6f12a862c9 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1102,6 +1102,10 @@ <onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/openlocation/onActionProcess.js</onActionProcess> <iconId>NEON:TACKED</iconId> </entityActionField> + <entityProvider> + <name>indexP</name> + <recordContainer>index</recordContainer> + </entityProvider> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 446f310d7b..1a797dcd49 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -1266,6 +1266,10 @@ </entityParameter> </children> </entityProvider> + <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 267ca200f7..684c65d5dc 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 ed3ef2cce6..dfa1552a09 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -883,15 +883,46 @@ _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 + '"'; + if (operator == "NOT_EQUAL") { + row = row + '"exclude":' + JSON.parse(value); + } + row = row + '})'; + return row; +} + _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern = function(indexPattern) { return indexPattern.match(/[^{}]+(?=\})/g); -- GitLab