diff options
Diffstat (limited to 'cps-service/src/main')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java | 2 | ||||
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/utils/DataMapUtils.java | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java index e7b639d48e..1013c13b76 100644 --- a/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java +++ b/cps-service/src/main/java/org/onap/cps/notification/CpsDataUpdatedEventFactory.java @@ -89,7 +89,7 @@ public class CpsDataUpdatedEventFactory { private Data createData(final DataNode dataNode) { final var data = new Data(); - DataMapUtils.toDataMap(dataNode).forEach(data::setAdditionalProperty); + DataMapUtils.toDataMapWithIdentifier(dataNode).forEach(data::setAdditionalProperty); return data; } 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 71a95f1ca0..42719d9b3c 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()) |