From e3ce81a541ace7a7aeef78d8513e1b171aacb051 Mon Sep 17 00:00:00 2001 From: seanbeirne Date: Thu, 23 Feb 2023 15:16:38 +0000 Subject: Refactor cmHandle(ID) queries - first execute cm-handle id search only - get cm handles for ids only when needed using multiple-get-method - use Collection interface where posisble (instead of Set) - use java Function to combine multiple queries in a more genric way Issue-ID: CPS-1494 Signed-off-by: seanbeirne Change-Id: Icfcb8ec94f75e261303aaee5c9034b920c01f3c4 --- .../onap/cps/ncmp/rest/controller/NetworkCmProxyController.java | 9 +++++---- .../ncmp/rest/controller/NetworkCmProxyInventoryController.java | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'cps-ncmp-rest') diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index 9f171f6094..4da251f3cc 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -1,7 +1,7 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2021 Pantheon.tech - * Modifications Copyright (C) 2021-2022 Nordix Foundation + * Modifications Copyright (C) 2021-2023 Nordix Foundation * Modifications Copyright (C) 2021 highstreet technologies GmbH * Modifications Copyright (C) 2021-2022 Bell Canada * ================================================================================ @@ -28,8 +28,8 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.PATCH; import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE; +import java.util.Collection; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -235,7 +235,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { final CmHandleQueryParameters cmHandleQueryParameters) { final CmHandleQueryApiParameters cmHandleQueryApiParameters = deprecationHelper.mapOldConditionProperties(cmHandleQueryParameters); - final Set cmHandles = networkCmProxyDataService + final Collection cmHandles = networkCmProxyDataService .executeCmHandleSearch(cmHandleQueryApiParameters); final List outputCmHandles = cmHandles.stream().map(this::toRestOutputCmHandle).collect(Collectors.toList()); @@ -253,7 +253,8 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { final CmHandleQueryParameters cmHandleQueryParameters) { final CmHandleQueryApiParameters cmHandleQueryApiParameters = jsonObjectMapper.convertToValueType(cmHandleQueryParameters, CmHandleQueryApiParameters.class); - final Set cmHandleIds = networkCmProxyDataService.executeCmHandleIdSearch(cmHandleQueryApiParameters); + final Collection cmHandleIds + = networkCmProxyDataService.executeCmHandleIdSearch(cmHandleQueryApiParameters); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java index 0c27d3efb0..5d8599a1a2 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyInventoryController.java @@ -22,8 +22,8 @@ package org.onap.cps.ncmp.rest.controller; import io.micrometer.core.annotation.Timed; +import java.util.Collection; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; import javax.validation.Valid; import lombok.RequiredArgsConstructor; @@ -55,7 +55,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = ncmpRestInputMapper .toCmHandleQueryServiceParameters(cmHandleQueryParameters); - final Set cmHandleIds = networkCmProxyDataService + final Collection cmHandleIds = networkCmProxyDataService .executeCmHandleIdSearchForInventory(cmHandleQueryServiceParameters); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } @@ -68,7 +68,7 @@ public class NetworkCmProxyInventoryController implements NetworkCmProxyInventor */ @Override public ResponseEntity> getAllCmHandleIdsForRegisteredDmi(final String dmiPluginIdentifier) { - final Set cmHandleIds = + final Collection cmHandleIds = networkCmProxyDataService.getAllCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier); return ResponseEntity.ok(List.copyOf(cmHandleIds)); } -- cgit 1.2.3-korg