summaryrefslogtreecommitdiffstats
path: root/cps-rest/src/main/java/org/onap
diff options
context:
space:
mode:
authorniamhcore <niamh.core@est.tech>2021-08-10 16:39:53 +0100
committerniamhcore <niamh.core@est.tech>2021-08-11 10:31:45 +0100
commit4802d46c0d3e7d65a9dcfbf6c168c6466d55c0b2 (patch)
tree263fe222a0a05019fe025ab0db9b3a1879bf7535 /cps-rest/src/main/java/org/onap
parentdce1d58005d90950e00b22078d82559748dcb255 (diff)
Update response query format
Issue-ID: CPS-560 Change-Id: I1c71270a8cde7e940c5af80bc743d0f01ab6b9bb Signed-off-by: niamhcore <niamh.core@est.tech>
Diffstat (limited to 'cps-rest/src/main/java/org/onap')
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java
index b7fc9f7950..8aa65a0057 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/QueryRestController.java
@@ -21,12 +21,16 @@
package org.onap.cps.rest.controller;
import com.google.gson.Gson;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
+import java.util.Map;
import javax.validation.Valid;
import org.onap.cps.api.CpsQueryService;
import org.onap.cps.rest.api.CpsQueryApi;
import org.onap.cps.spi.FetchDescendantsOption;
import org.onap.cps.spi.model.DataNode;
+import org.onap.cps.utils.DataMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -47,6 +51,10 @@ public class QueryRestController implements CpsQueryApi {
? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS;
final Collection<DataNode> dataNodes =
cpsQueryService.queryDataNodes(dataspaceName, anchorName, cpsPath, fetchDescendantsOption);
- return new ResponseEntity<>(new Gson().toJson(dataNodes), HttpStatus.OK);
+ final List<Map<String, Object>> dataNodeList = new ArrayList<>();
+ for (final DataNode dataNode : dataNodes) {
+ dataNodeList.add(DataMapUtils.toDataMap(dataNode));
+ }
+ return new ResponseEntity<>(new Gson().toJson(dataNodeList), HttpStatus.OK);
}
}