Skip deleting list xpaths that are list elements
[cps.git] / cps-path-parser / src / main / java / org / onap / cps / cpspath / parser / CpsPathUtil.java
index 283463b..bde9b06 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation
+ *  Copyright (C) 2022-2023 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
 
 package org.onap.cps.cpspath.parser;
 
-import static org.onap.cps.cpspath.parser.CpsPathPrefixType.ABSOLUTE;
-
+import java.util.List;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -60,6 +59,11 @@ public class CpsPathUtil {
         return getCpsPathBuilder(xpathSource).build().getNormalizedParentPath();
     }
 
+    public static String[] getXpathNodeIdSequence(final String xpathSource) {
+        final List<String> containerNames = getCpsPathBuilder(xpathSource).build().getContainerNames();
+        return containerNames.toArray(new String[containerNames.size()]);
+    }
+
 
     /**
      * Returns boolean indicating xpath is an absolute path to a list element.
@@ -69,7 +73,7 @@ public class CpsPathUtil {
      */
     public static boolean isPathToListElement(final String xpathSource) {
         final CpsPathQuery cpsPathQuery = getCpsPathBuilder(xpathSource).build();
-        return cpsPathQuery.getCpsPathPrefixType() == ABSOLUTE && cpsPathQuery.hasLeafConditions();
+        return cpsPathQuery.isPathToListElement();
     }
 
     /**