diff --git a/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod b/entity/DuplicateScanner_entity/DuplicateScanner_entity.aod index b7116402fb566724a159f7c003fde69a19901b96..3334ff8a07571c4b57185c6f70bd6a6a3911ef2a 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 0000000000000000000000000000000000000000..b696837f0fe2c1cd999ad33d69b291e71e358ca6 --- /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 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/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 875ad026d6d26f22daffee578b7e83c580b1639e..6f12a862c9a7c86dbe285a8d7e4a966c6c553e77 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 446f310d7bc96179cfbcae4721156500e1110b61..1a797dcd49df9199336a1e1fca159c213f08ff9f 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 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..dfa1552a09d84d5dac90a8973885cbe8fed0ba88 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);