Merge "[CPS] RI: Code Refactoring # Replace '[\s\S]' to '.' as it is same as '.'...
[cps.git] / cps-ri / src / main / java / org / onap / cps / spi / impl / CpsDataPersistenceServiceImpl.java
index 16ec270..cca5d9c 100644 (file)
@@ -343,6 +343,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();
@@ -351,17 +352,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);
     }