X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Futils%2FDataMapUtils.java;h=42719d9b3cd55277d27187af754f72e1f4cdbe20;hb=ebfa4077b2e462237301e93566fed6ef2f56674c;hp=71a95f1ca084b4b7daa4eb2b5186dd14cd5a1328;hpb=a15c0e5b58f16c3ab4a7c7610ac8c4a191e5e051;p=cps.git 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 @@ -36,13 +36,24 @@ import org.onap.cps.spi.model.DataNode; @NoArgsConstructor(access = AccessLevel.PRIVATE) 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 toDataMapWithIdentifier(final DataNode dataNode) { + return ImmutableMap.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 toDataMap(final DataNode dataNode) { return ImmutableMap.builder() .putAll(dataNode.getLeaves())