aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-02-14 10:56:35 +0000
committerRenu Kumari <renu.kumari@bell.ca>2022-02-17 17:19:09 +0000
commitebfa4077b2e462237301e93566fed6ef2f56674c (patch)
treeee235c331884988bd34d008cc9c7f15729b1c615 /cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
parenta15c0e5b58f16c3ab4a7c7610ac8c4a191e5e051 (diff)
Align JSON DataNode for Get and Post/Put API in CPS
Issue-ID: CPS-865 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I60b1f9c94e79bdd66d60fe6a68f5fc4adc718d35
Diffstat (limited to 'cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java')
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java b/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
index 71a95f1ca..42719d9b3 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
@@ -37,12 +37,23 @@ import org.onap.cps.spi.model.DataNode;
public class DataMapUtils {
/**
+ * Converts DataNode structure into a map including the root node identifier for a JSON response.
+ *
+ * @param dataNode data node object
+ * @return a map representing same data with the root node identifier
+ */
+ public static Map<String, Object> toDataMapWithIdentifier(final DataNode dataNode) {
+ return ImmutableMap.<String, Object>builder()
+ .put(getNodeIdentifier(dataNode.getXpath()), toDataMap(dataNode))
+ .build();
+ }
+
+ /**
* Converts DataNode structure into a map for a JSON response.
*
* @param dataNode data node object
* @return a map representing same data
*/
-
public static Map<String, Object> toDataMap(final DataNode dataNode) {
return ImmutableMap.<String, Object>builder()
.putAll(dataNode.getLeaves())