diff options
author | Luke Gleeson <luke.gleeson@est.tech> | 2023-07-20 09:47:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2023-07-20 09:47:48 +0000 |
commit | 00113a7e3a3c9ad7ea44258097d82431320f7605 (patch) | |
tree | 3e95037dab2c43aa0af4a01548bcb75c5fcf9cf3 /cps-service/src/main | |
parent | 6a2eca2859d8b2ab88ff04663902eb7cc74b4fc1 (diff) | |
parent | ad61e283f7d981c3c8e307af871fb3a63e0cf4f9 (diff) |
Merge "Persisting a list element to a parent list (ep2)"
Diffstat (limited to 'cps-service/src/main')
-rwxr-xr-x | cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 6e7c1649d7..7db87e87ea 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -116,8 +116,12 @@ public class CpsDataServiceImpl implements CpsDataService { final Anchor anchor = cpsAdminService.getAnchor(dataspaceName, anchorName); final Collection<DataNode> listElementDataNodeCollection = buildDataNodes(anchor, parentNodeXpath, jsonData, ContentType.JSON); - cpsDataPersistenceService.addListElements(dataspaceName, anchorName, parentNodeXpath, - listElementDataNodeCollection); + if (isRootNodeXpath(parentNodeXpath)) { + cpsDataPersistenceService.storeDataNodes(dataspaceName, anchorName, listElementDataNodeCollection); + } else { + cpsDataPersistenceService.addListElements(dataspaceName, anchorName, parentNodeXpath, + listElementDataNodeCollection); + } processDataUpdatedEventAsync(anchor, parentNodeXpath, UPDATE, observedTimestamp); } @@ -391,6 +395,10 @@ public class CpsDataServiceImpl implements CpsDataService { .get(anchor.getDataspaceName(), anchor.getSchemaSetName()).getSchemaContext(); } + private static boolean isRootNodeXpath(final String xpath) { + return ROOT_NODE_XPATH.equals(xpath); + } + private void processDataNodeUpdate(final Anchor anchor, final DataNode dataNodeUpdate) { cpsDataPersistenceService.batchUpdateDataLeaves(anchor.getDataspaceName(), anchor.getName(), Collections.singletonMap(dataNodeUpdate.getXpath(), dataNodeUpdate.getLeaves())); |