diff --git a/entity/DuplicateScan_entity/DuplicateScan_entity.aod b/entity/DuplicateScan_entity/DuplicateScan_entity.aod index 5794d0e0864cd56c4a5b2427727bd8c954bfbf56..3ff1efe86f8cad89e4313db4c5008998a996c64c 100644 --- a/entity/DuplicateScan_entity/DuplicateScan_entity.aod +++ b/entity/DuplicateScan_entity/DuplicateScan_entity.aod @@ -18,6 +18,7 @@ <entityField> <name>FILTER_NAME</name> <title>Filter Name</title> + <onValidation>%aditoprj%/entity/DuplicateScan_entity/entityfields/filter_name/onValidation.js</onValidation> </entityField> <entityField> <name>EXTERNAL_SERVICE_USAGE_ALLOWED</name> diff --git a/entity/DuplicateScan_entity/entityfields/filter_name/onValidation.js b/entity/DuplicateScan_entity/entityfields/filter_name/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..597bb8faa5793a446bb110a7fc349a8d4895bf11 --- /dev/null +++ b/entity/DuplicateScan_entity/entityfields/filter_name/onValidation.js @@ -0,0 +1,27 @@ +import("system.translate"); +import("system.result"); +import("system.db"); +import("system.vars"); + +/* + * Because of the easy usage of the duplicate scan functionality, which can be called using the + * filtername and targetentity, this particular combination must be unique. Therefore it's + * uniqueness has to be verified on creation/modification + */ + +var targetEntity = vars.get("$field.ENTITY_TO_SCAN_NAME"); +var currentFilterName = vars.get("$field.FILTER_NAME"); +var messageText = "The combination of filter name and target entity is already in use"; + +if(targetEntity != "") +{ + var query = "select count(*) from DUPLICATESCANNER" + + " where ENTITY_TO_SCAN_NAME = '" + targetEntity + "'" + + " and FILTER_NAME = '" + currentFilterName + "'"; + + var occurrences = parseInt(db.cell(query), 10); + + if(occurrences > 0) + result.string(translate.text(messageText)); +} + \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index 3c24e652a4df98c3405ef76e0a758be155e4fcf0..076e0574da76ac6f7d6e6507290b3ab6d2eeac07 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -4956,6 +4956,21 @@ <entry> <key>Configuration name</key> </entry> + <entry> + <key>Export letter for selection</key> + </entry> + <entry> + <key>Export letter</key> + </entry> + <entry> + <key>Privacy agreement</key> + </entry> + <entry> + <key>Sufficient guarantees</key> + </entry> + <entry> + <key>The combination of filter name and target entity is already in use</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index fca114325e0aafe9e6a5472ed5fdf1d7cd3f8f40..6e773b6b1b876b37e8075be92394dd08d47aec89 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -6254,6 +6254,13 @@ <key>Configuration name</key> <value>Konfigurationsname</value> </entry> + <entry> + <key>Download letter</key> + </entry> + <entry> + <key>The combination of filter name and target entity is already in use</key> + <value>Die Kombination von Filtername und Zielentity existiert bereits</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 7feec0afc744e09c9b590585c083dac6bb2b8c37..dc8935925a5953e1bcba7a4bc7905a09ef5fc9cc 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -5005,6 +5005,21 @@ <entry> <key>Characters to use</key> </entry> + <entry> + <key>Export letter for selection</key> + </entry> + <entry> + <key>Export letter</key> + </entry> + <entry> + <key>Privacy agreement</key> + </entry> + <entry> + <key>Sufficient guarantees</key> + </entry> + <entry> + <key>The combination of filter name and target entity is already in use</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index a4c5ebc5a5c06422d50db082f87cf1625f6f410b..b18978470f71672b8ee1fd7258687c1fef033c47 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -1,3 +1,4 @@ +import("system.net"); import("system.logging"); import("system.db"); import("system.entities"); @@ -18,9 +19,14 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, let possibleDuplicates = _DuplicateScannerUtils._applyPreFilter(pTargetEntity, configuredFilters, pTargetEntityResultFields, pFilterValues); -// if(_DuplicateScannerUtils._isExternalScanServiceAvailable()) + if(possibleDuplicates.length <= 0) + { + return []; + } +// if(_DuplicateScannerUtils._isExternalScanServiceAvailable() +// && _DuplicateScannerUtils._useExternalScanServiceAllowed(pFilterName, pTargetEntity)) // { -// +// _DuplicateScannerUtils._callExternalScanService(); // } return possibleDuplicates; @@ -29,15 +35,19 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, function _DuplicateScannerUtils() {} +var INDEX_FILTER_CONDITION = 0; +var INDEX_COUNT_CHARS_TO_USE = 1; +var INDEX_MAX_RESULTS_THRESHOLD = 2; + _DuplicateScannerUtils._applyPreFilter = function(pTargetEntity, pFilterCountCharactersToUseRay, pTargetEntityResultFields, pFilterValues) { - var maxResultsTreshold = 4; var combinedFilter = {}; for (i = 0; i < pFilterCountCharactersToUseRay.length; i++) { - let filter = pFilterCountCharactersToUseRay[i][0]; - let countCharsOfValueToUse = pFilterCountCharactersToUseRay[i][1]; + let filter = pFilterCountCharactersToUseRay[i][INDEX_FILTER_CONDITION]; + let countCharsOfValueToUse = pFilterCountCharactersToUseRay[i][INDEX_COUNT_CHARS_TO_USE]; + let maxResultsThreshold = pFilterCountCharactersToUseRay[i][INDEX_MAX_RESULTS_THRESHOLD]; if(filter == null || filter == "") continue; @@ -73,9 +83,9 @@ _DuplicateScannerUtils._applyPreFilter = function(pTargetEntity, pFilterCountCha logging.log("rowCount -> " + rowCount); - if(rowCount > maxResultsTreshold) + if(rowCount > maxResultsThreshold) { - logging.log("zu viele rows gefundenn nächsten Filter anwenden -> rowCount:" + rowCount + " maxResultsTreshold:" + maxResultsTreshold); + logging.log("zu viele rows gefundenn nächsten Filter anwenden -> rowCount:" + rowCount + " maxResultsThreshold:" + maxResultsThreshold); //Found more rows than allowed by the threshold, run next filter to narrow the results continue; } @@ -105,19 +115,36 @@ _DuplicateScannerUtils._isExternalScanServiceAvailable = function() } _DuplicateScannerUtils._callExternalScanService = function(pFormattedJsonValues) +{ + let serviceConfig = _DuplicateScannerUtils._getExternalServiceConfiguration(); + let serviceUrl = ""; + let actionType = ""; + let queryParameter = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// let serviceUrl = ""; +// +// net.callRestWebserviceBasicAuth(serviceUrl, actionType, pQueryParams, pRequestEntity, pHeaders, pDatatypeAccept, pDataTypeSend, pDatatypeJDitoAccept, pDatatypeJDitoSend, pUser, pPassword, pReturnExtendedResponseInfos); +} + +_DuplicateScannerUtils._getExternalServiceConfiguration = function(pFormattedJsonValues) { //todo load config and call ws } _DuplicateScannerUtils._loadFilters = function(pFilterName, pTargetEntity) { - //entities.createConfigForLoadingRows().entity("DuplicateScanConditionConfig_entity")..fields(["$field.CONDITION", "$field.CONDITION_CONFIG_NAME", "$field.COUNT_CHARACTERS_TO_USE"]) - let query = "select \"CONDITION\", COUNT_CHARACTERS_TO_USE, EXTERNAL_SERVICE_USAGE_ALLOWED from DUPLICATESCANCONDITIONCONFIG" + let query = "select \"CONDITION\", COUNT_CHARACTERS_TO_USE, MAX_RESULTS_TRESHOLD from DUPLICATESCANCONDITIONCONFIG" + " join DUPLICATESCANNER on DUPLICATESCANNER.ID = DUPLICATESCANCONDITIONCONFIG.DUPLICATESCAN_ID" + " where FILTER_NAME = '" + pFilterName + "'" + " and ENTITY_TO_SCAN_NAME = '" + pTargetEntity + "'"; - logging.log("_loadFilters query -> " + query); return db.table(query); } @@ -162,7 +189,7 @@ _DuplicateScannerUtils._insertValuesInFilterTemplate = function(pJsonRootNode, p /* * Returns wether or not a value should be substring'd * - * @return If pCountCharsOfValueToUse is a number, greater than 0 and smaller than the values length -> true + * @return true if pCountCharsOfValueToUse is a number, greater than 0 and smaller than the values length */ _DuplicateScannerUtils._isValueLongerThanCharsToUse = function(pValueLength, pCountCharsOfValueToUse) {