summaryrefslogtreecommitdiffstats
path: root/cps-ri
diff options
context:
space:
mode:
authorSourabh Sourabh <sourabh.sourabh@est.tech>2023-05-08 09:06:32 +0000
committerGerrit Code Review <gerrit@onap.org>2023-05-08 09:06:32 +0000
commitc1ff3a18970e7d53d20fae2617c1fef3791a6377 (patch)
tree05697fc26788b282feb223269a3929931e39a3d7 /cps-ri
parentb49d38cc15ad20e660d0e4ebd8a6d6a06e6a2207 (diff)
parentc863070591268662eced18e04ba52b96897ce7bd (diff)
Merge "Don't handle ancestor-axis using regex quickfind (CPS-1664 #2)"
Diffstat (limited to 'cps-ri')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java14
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java2
2 files changed, 6 insertions, 10 deletions
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<DataNode> getDataNodesUsingRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption,
final AnchorEntity anchorEntity,
final CpsPathQuery cpsPathQuery) {
- Collection<FragmentEntity> fragmentEntities;
final String xpathRegex = FragmentQueryBuilder.getXpathSqlRegexForQuickFindWithDescendants(cpsPathQuery);
final List<FragmentExtract> fragmentExtracts = (anchorEntity == ALL_ANCHORS)
- ? fragmentRepository.quickFindWithDescendantsAcrossAnchor(xpathRegex) :
- fragmentRepository.quickFindWithDescendants(anchorEntity.getId(), xpathRegex);
- fragmentEntities = FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts);
- if (cpsPathQuery.hasAncestorAxis()) {
- final Collection<String> 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<FragmentEntity> 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<FragmentEntity, Long>,
+ " CAST(attributes AS TEXT) AS attributes"
+ " FROM FRAGMENT WHERE xpath ~ :xpathRegex",
nativeQuery = true)
- List<FragmentExtract> quickFindWithDescendantsAcrossAnchor(@Param("xpathRegex") String xpathRegex);
+ List<FragmentExtract> quickFindWithDescendantsAcrossAnchors(@Param("xpathRegex") String xpathRegex);
}