aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java
diff options
context:
space:
mode:
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())