From 94f1ee42d44dce02beb266438bd297886ff3b463 Mon Sep 17 00:00:00 2001 From: Srinath S Date: Tue, 12 Feb 2019 14:59:51 -0800 Subject: [PATCH] Do a case insensitive equality check for entity name when creating and running flows , if it returns more than one result, revert to strict check. (#1868) --- .../root/data-hub/4/impl/flow-lib.xqy | 21 +++++++++++++++---- .../root/data-hub/4/impl/hub-entities.xqy | 8 ++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/flow-lib.xqy b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/flow-lib.xqy index 88b2f60844..e9b0dac783 100644 --- a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/flow-lib.xqy +++ b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/flow-lib.xqy @@ -98,15 +98,28 @@ declare function flow:get-flow-nocache( { hul:run-in-modules(function() { - /hub:flow[ - hub:entity = $entity-name and + let $flow := /hub:flow[ + fn:lower-case(hub:entity) = fn:lower-case($entity-name) and hub:name = $flow-name] - [ + [ + if (fn:exists($flow-type)) then + hub:type = $flow-type + else + fn:true() + ] + return + if ((fn:count($flow)) > 1) then + /hub:flow[ + hub:entity = $entity-name and + hub:name = $flow-name] + [ if (fn:exists($flow-type)) then hub:type = $flow-type else fn:true() - ] + ] + else + $flow }) ! hul:deep-copy(.) }; diff --git a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy index 70186003eb..9ed3da7aba 100644 --- a/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy +++ b/marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/4/impl/hub-entities.xqy @@ -33,7 +33,13 @@ declare function hent:get-model($entity-name as xs:string) declare function hent:get-model($entity-name as xs:string, $used-models as xs:string*) { - let $model := fn:collection($ENTITY-MODEL-COLLECTION)[info/title = $entity-name] + let $model := + let $_ := fn:collection($ENTITY-MODEL-COLLECTION)[lower-case(info/title) = lower-case($entity-name)] + return + if (fn:count($_) > 1) then + fn:collection($ENTITY-MODEL-COLLECTION)[info/title = $entity-name] + else + $_ where fn:exists($model) return let $model-map as map:map? := $model