From c863070591268662eced18e04ba52b96897ce7bd Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Tue, 2 May 2023 21:37:56 +0100 Subject: Don't handle ancestor-axis using regex quickfind (CPS-1664 #2) This is a preparatory patch to make refactoring easier in CPS-1664 #3 Issue-ID: CPS-1664 Signed-off-by: danielhanrahan Change-Id: I1f94fef137ae41f7dedc585d8314f13493885d1b --- .../onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java | 14 +++++--------- .../org/onap/cps/spi/repository/FragmentRepository.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'cps-ri') diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java index 78983ee0df..3a1588a59a 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java @@ -348,6 +348,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService private static boolean canUseRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption, final CpsPathQuery cpsPathQuery) { return fetchDescendantsOption.equals(FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) + && !cpsPathQuery.hasAncestorAxis() && !cpsPathQuery.hasLeafConditions() && !cpsPathQuery.hasTextFunctionCondition() && !cpsPathQuery.hasContainsFunctionCondition(); @@ -356,17 +357,12 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService private List getDataNodesUsingRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption, final AnchorEntity anchorEntity, final CpsPathQuery cpsPathQuery) { - Collection fragmentEntities; final String xpathRegex = FragmentQueryBuilder.getXpathSqlRegexForQuickFindWithDescendants(cpsPathQuery); final List fragmentExtracts = (anchorEntity == ALL_ANCHORS) - ? fragmentRepository.quickFindWithDescendantsAcrossAnchor(xpathRegex) : - fragmentRepository.quickFindWithDescendants(anchorEntity.getId(), xpathRegex); - fragmentEntities = FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts); - if (cpsPathQuery.hasAncestorAxis()) { - final Collection ancestorXpaths = processAncestorXpath(fragmentEntities, cpsPathQuery); - fragmentEntities = (anchorEntity == ALL_ANCHORS) ? getAncestorFragmentEntitiesAcrossAnchors(cpsPathQuery, - fragmentEntities) : getFragmentEntities(anchorEntity, ancestorXpaths, fetchDescendantsOption); - } + ? fragmentRepository.quickFindWithDescendantsAcrossAnchors(xpathRegex) + : fragmentRepository.quickFindWithDescendants(anchorEntity.getId(), xpathRegex); + final Collection fragmentEntities = + FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts); return createDataNodesFromFragmentEntities(fetchDescendantsOption, fragmentEntities); } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java index 8114f1055a..f389467a53 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java @@ -140,5 +140,5 @@ public interface FragmentRepository extends JpaRepository, + " CAST(attributes AS TEXT) AS attributes" + " FROM FRAGMENT WHERE xpath ~ :xpathRegex", nativeQuery = true) - List quickFindWithDescendantsAcrossAnchor(@Param("xpathRegex") String xpathRegex); + List quickFindWithDescendantsAcrossAnchors(@Param("xpathRegex") String xpathRegex); } -- cgit 1.2.3-korg