From eba77598601a7e3430f9582dfe433495ded3244c Mon Sep 17 00:00:00 2001 From: seanbeirne Date: Mon, 20 Feb 2023 15:00:11 +0000 Subject: Omit descendants when not need in ncmp inventory queries -Seperated tests by Id and details Issue-ID: CPS-1494 Signed-off-by: seanbeirne Change-Id: Ia1c2b637aa5ab2ffe3a92930d74af1dd7d0dbe92 --- .../api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java | 11 +++++++---- .../org/onap/cps/ncmp/api/inventory/CmHandleQueriesImpl.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'cps-ncmp-service/src/main/java/org') diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java index a98c6008cf..ecb6e522f7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java @@ -26,6 +26,7 @@ import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.vali import static org.onap.cps.ncmp.api.impl.utils.YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle; import static org.onap.cps.spi.FetchDescendantsOption.FETCH_DIRECT_CHILDREN_ONLY; import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS; +import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS; import java.util.ArrayList; import java.util.Collection; @@ -49,6 +50,7 @@ import org.onap.cps.ncmp.api.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.inventory.enums.PropertyType; import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters; import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; +import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.model.ConditionProperties; import org.onap.cps.spi.model.DataNode; @@ -78,7 +80,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm } final Map combinedQueryResult = executeInventoryQueries( - cmHandleQueryServiceParameters); + cmHandleQueryServiceParameters, INCLUDE_ALL_DESCENDANTS); return new HashSet<>(combineWithModuleNameQuery(cmHandleQueryServiceParameters, combinedQueryResult).values()); } @@ -98,7 +100,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm } final Map combinedQueryResult = executeInventoryQueries( - cmHandleQueryServiceParameters); + cmHandleQueryServiceParameters, OMIT_DESCENDANTS); final Collection moduleNamesForQuery = getModuleNamesForQuery(cmHandleQueryServiceParameters.getCmHandleQueryParameters()); @@ -229,7 +231,8 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm } private Map executeInventoryQueries( - final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) { + final CmHandleQueryServiceParameters cmHandleQueryServiceParameters, + final FetchDescendantsOption fetchDescendantsOption) { final Map cpsPath = getCpsPath(cmHandleQueryServiceParameters.getCmHandleQueryParameters()); if (!validateCpsPathConditionProperties(cpsPath)) { return Collections.emptyMap(); @@ -240,7 +243,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm } else { try { cpsPathQueryResult = cmHandleQueries.queryCmHandleDataNodesByCpsPath( - cpsPath.get("cpsPath"), INCLUDE_ALL_DESCENDANTS) + cpsPath.get("cpsPath"), fetchDescendantsOption) .stream().map(this::createNcmpServiceCmHandle) .collect(Collectors.toMap(NcmpServiceCmHandle::getCmHandleId, Function.identity())); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImpl.java index 0f86cb7be6..6ca716c270 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/CmHandleQueriesImpl.java @@ -78,7 +78,7 @@ public class CmHandleQueriesImpl implements CmHandleQueries { + publicPropertyQueryPair.getKey() + "\" and @value=\"" + publicPropertyQueryPair.getValue() + "\"]"; - final Collection dataNodes = queryCmHandleDataNodesByCpsPath(cpsPath, INCLUDE_ALL_DESCENDANTS); + final Collection dataNodes = queryCmHandleDataNodesByCpsPath(cpsPath, OMIT_DESCENDANTS); if (cmHandleIdToNcmpServiceCmHandles == null) { cmHandleIdToNcmpServiceCmHandles = collectDataNodesToNcmpServiceCmHandles(dataNodes); } else { -- cgit 1.2.3-korg