diff options
author | Arpit Singh <as00745003@techmahindra.com> | 2023-08-02 18:35:31 +0530 |
---|---|---|
committer | Priyank Maheshwari <priyank.maheshwari@est.tech> | 2023-11-14 16:42:42 +0000 |
commit | 0339c71815a4ca4cbab3d263d6c4586a112cda64 (patch) | |
tree | 89a3ed8006daa27542f464834071fc5191484668 /cps-rest/src/main | |
parent | 0fdda53aa0dde9ec3a4c1b287b3ff8da4a75da5c (diff) |
CPS Delta API 1: Delta between 2 anchors
- CPS Delta Feature Part 1: To find delta between two anchors
- created new endpoint deltaByDataspaceAndAnchors
- endpoint to take dataspaceName, source anchor, target anchor,
xpath, descendants as input
- added new service CpsDeltaService
- added method to find delta between DataNodes:
getDeltaReport
- added method to find removed data nodes: getRemovedDeltaReports
- added method to get Added DataNodes: getAddedDeltaReports
- added method to get Map of xpath to DataNode: convertToXPathToDataNodesMap
- added a POJO for delta report
- Added new JSON data for delta feature testing
- Added groovy test files CpsDeltaServiceImplSpec and DeltaReportBuilderSpec
- code related to update operation, will be added in
separate commit
Issue-ID: CPS-1824
Signed-off-by: Arpit Singh <as00745003@techmahindra.com>
Change-Id: I313f0f71d04b03878be7643f709d8af1aa6df6ba
Diffstat (limited to 'cps-rest/src/main')
-rwxr-xr-x | cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java index 60e7fb6d2d..4f9328b6cd 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java @@ -38,6 +38,7 @@ import org.onap.cps.api.CpsDataService; import org.onap.cps.rest.api.CpsDataApi; import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.model.DataNode; +import org.onap.cps.spi.model.DeltaReport; import org.onap.cps.utils.ContentType; import org.onap.cps.utils.DataMapUtils; import org.onap.cps.utils.JsonObjectMapper; @@ -166,6 +167,23 @@ public class DataRestController implements CpsDataApi { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + @Override + @Timed(value = "cps.data.controller.get.delta", + description = "Time taken to get delta between anchors") + public ResponseEntity<Object> getDeltaByDataspaceAndAnchors(final String dataspaceName, + final String sourceAnchorName, + final String targetAnchorName, + final String xpath, + final String descendants) { + final FetchDescendantsOption fetchDescendantsOption = + FetchDescendantsOption.getFetchDescendantsOption(descendants); + + final List<DeltaReport> deltaBetweenAnchors = + cpsDataService.getDeltaByDataspaceAndAnchors(dataspaceName, sourceAnchorName, + targetAnchorName, xpath, fetchDescendantsOption); + return new ResponseEntity<>(jsonObjectMapper.asJsonString(deltaBetweenAnchors), HttpStatus.OK); + } + private static boolean isRootXpath(final String xpath) { return ROOT_XPATH.equals(xpath); } |