diff options
author | seanbeirne <sean.beirne@est.tech> | 2024-01-17 15:18:10 +0000 |
---|---|---|
committer | seanbeirne <sean.beirne@est.tech> | 2024-01-19 13:47:50 +0000 |
commit | 84c8d8d383469e05420f8e3e482d00e527c87734 (patch) | |
tree | aaf7284e8adb942e2121e0886c7d1f8d4a9fd8bf /cps-ncmp-service/src/main | |
parent | 2dce7ab2fd627450550666e3993e28e10f6a8548 (diff) |
Remove Lambda & Restructure File
-Removed Lambda from CompositeStateUtils
-Restructured CpsDataPersistenceServiceImpl to more logical layout
Issue-ID: CPS-1238
Change-Id: I09096dab474230d04b15c204cbea95a2f1285366
Signed-off-by: seanbeirne <sean.beirne@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main')
2 files changed, 26 insertions, 39 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCmHandleStateHandlerImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCmHandleStateHandlerImpl.java index a31332f094..0ed95adff2 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCmHandleStateHandlerImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCmHandleStateHandlerImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -164,12 +164,12 @@ public class LcmEventsCmHandleStateHandlerImpl implements LcmEventsCmHandleState } private void setInitialStates(final YangModelCmHandle yangModelCmHandle) { - CompositeStateUtils.setInitialDataStoreSyncState().accept(yangModelCmHandle.getCompositeState()); - CompositeStateUtils.setCompositeState(READY).accept(yangModelCmHandle.getCompositeState()); + CompositeStateUtils.setInitialDataStoreSyncState(yangModelCmHandle.getCompositeState()); + CompositeStateUtils.setCompositeState(READY, yangModelCmHandle.getCompositeState()); } private void retryCmHandle(final YangModelCmHandle yangModelCmHandle) { - CompositeStateUtils.setCompositeStateForRetry().accept(yangModelCmHandle.getCompositeState()); + CompositeStateUtils.setCompositeStateForRetry(yangModelCmHandle.getCompositeState()); } private void registerNewCmHandle(final YangModelCmHandle yangModelCmHandle) { @@ -178,7 +178,7 @@ public class LcmEventsCmHandleStateHandlerImpl implements LcmEventsCmHandleState } private void setCmHandleState(final YangModelCmHandle yangModelCmHandle, final CmHandleState targetCmHandleState) { - CompositeStateUtils.setCompositeState(targetCmHandleState).accept(yangModelCmHandle.getCompositeState()); + CompositeStateUtils.setCompositeState(targetCmHandleState, yangModelCmHandle.getCompositeState()); } private boolean isNew(final CompositeState existingCompositeState) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CompositeStateUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CompositeStateUtils.java index 99cca8c0b3..35ad54fdef 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CompositeStateUtils.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CompositeStateUtils.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation + * Copyright (C) 2022-2024 Nordix Foundation * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package org.onap.cps.ncmp.api.impl.inventory; -import java.util.function.Consumer; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -34,31 +33,23 @@ public class CompositeStateUtils { /** * Sets the cmHandleState to the provided state and updates the timestamp. - * - * @return Updated CompositeState */ - public static Consumer<CompositeState> setCompositeState(final CmHandleState cmHandleState) { - return compositeState -> { - compositeState.setCmHandleState(cmHandleState); - compositeState.setLastUpdateTimeNow(); - }; + public static void setCompositeState(final CmHandleState cmHandleState, + final CompositeState compositeState) { + compositeState.setCmHandleState(cmHandleState); + compositeState.setLastUpdateTimeNow(); } /** * Set the Operational datastore sync state based on the global flag. - * - * @return Updated CompositeState */ - public static Consumer<CompositeState> setInitialDataStoreSyncState() { - - return compositeState -> { - compositeState.setDataSyncEnabled(false); - final CompositeState.Operational operational = - getInitialDataStoreSyncState(compositeState.getDataSyncEnabled()); - final CompositeState.DataStores dataStores = - CompositeState.DataStores.builder().operationalDataStore(operational).build(); - compositeState.setDataStores(dataStores); - }; + public static void setInitialDataStoreSyncState(final CompositeState compositeState) { + compositeState.setDataSyncEnabled(false); + final CompositeState.Operational operational = + getInitialDataStoreSyncState(compositeState.getDataSyncEnabled()); + final CompositeState.DataStores dataStores = + CompositeState.DataStores.builder().operationalDataStore(operational).build(); + compositeState.setDataStores(dataStores); } /** @@ -91,19 +82,15 @@ public class CompositeStateUtils { /** * Sets the cmHandleState to ADVISED and retain the lock details. Used in retry scenarios. - * - * @return Updated CompositeState */ - public static Consumer<CompositeState> setCompositeStateForRetry() { - return compositeState -> { - compositeState.setCmHandleState(CmHandleState.ADVISED); - compositeState.setLastUpdateTimeNow(); - final String oldLockReasonDetails = compositeState.getLockReason().getDetails(); - final CompositeState.LockReason lockReason = - CompositeState.LockReason.builder() - .lockReasonCategory(compositeState.getLockReason().getLockReasonCategory()) - .details(oldLockReasonDetails).build(); - compositeState.setLockReason(lockReason); - }; + public static void setCompositeStateForRetry(final CompositeState compositeState) { + compositeState.setCmHandleState(CmHandleState.ADVISED); + compositeState.setLastUpdateTimeNow(); + final String oldLockReasonDetails = compositeState.getLockReason().getDetails(); + final CompositeState.LockReason lockReason = + CompositeState.LockReason.builder() + .lockReasonCategory(compositeState.getLockReason().getLockReasonCategory()) + .details(oldLockReasonDetails).build(); + compositeState.setLockReason(lockReason); } } |