diff options
author | emaclee <lee.anjella.macabuhay@est.tech> | 2022-06-17 17:42:56 +0100 |
---|---|---|
committer | emaclee <lee.anjella.macabuhay@est.tech> | 2022-06-30 12:08:14 +0100 |
commit | e1f73e264e2dca1f10c273620653f541c2f25d69 (patch) | |
tree | f9adc065420549de0368842ae1f4e7df30c4effe /cps-ncmp-rest/src/main | |
parent | f7c7848d4cd7654ab94d9c31b62a71ed2bc4b9e8 (diff) |
Add method to get YANG module sources for CM handle
- part of this commit includes renaming the enum SyncState to
DataStoreSyncState
Issue-ID: CPS-1064
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Change-Id: I6bf419141a1b33f09871946445cdfff422c8c354
Diffstat (limited to 'cps-ncmp-rest/src/main')
3 files changed, 25 insertions, 1 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapper.java index a9ec863d53..118fa45263 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapper.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NcmpRestInputMapper.java @@ -20,6 +20,7 @@ package org.onap.cps.ncmp.rest.controller; +import org.mapstruct.InheritConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.NullValueCheckStrategy; @@ -28,7 +29,9 @@ import org.onap.cps.ncmp.api.models.DmiPluginRegistration; import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; import org.onap.cps.ncmp.rest.model.RestDmiPluginRegistration; import org.onap.cps.ncmp.rest.model.RestInputCmHandle; +import org.onap.cps.ncmp.rest.model.RestModuleDefinition; import org.onap.cps.ncmp.rest.model.RestModuleReference; +import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.spi.model.ModuleReference; @Mapper(componentModel = "spring") @@ -52,4 +55,8 @@ public interface NcmpRestInputMapper { RestModuleReference toRestModuleReference( final ModuleReference moduleReference); + + @InheritConfiguration(name = "toRestModuleReference") + RestModuleDefinition toRestModuleDefinition( + final ModuleDefinition moduleDefinition); }
\ No newline at end of file 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 e0488c2279..33355475d9 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 @@ -47,6 +47,7 @@ import org.onap.cps.ncmp.rest.executor.CpsNcmpTaskExecutor; import org.onap.cps.ncmp.rest.mapper.CmHandleStateMapper; import org.onap.cps.ncmp.rest.model.CmHandlePublicProperties; import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters; +import org.onap.cps.ncmp.rest.model.RestModuleDefinition; import org.onap.cps.ncmp.rest.model.RestModuleReference; import org.onap.cps.ncmp.rest.model.RestOutputCmHandle; import org.onap.cps.ncmp.rest.model.RestOutputCmHandleCompositeState; @@ -290,6 +291,21 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { } /** + * Return module definitions for a cm handle. + * + * @param cmHandleId cm-handle identifier + * @return list of module definitions (module name, revision, yang resource content) + */ + @Override + public ResponseEntity<List<RestModuleDefinition>> getModuleDefinitionsByCmHandleId(final String cmHandleId) { + final List<RestModuleDefinition> restModuleDefinitions = + networkCmProxyDataService.getModuleDefinitionsByCmHandleId(cmHandleId).stream() + .map(ncmpRestInputMapper::toRestModuleDefinition) + .collect(Collectors.toList()); + return new ResponseEntity<>(restModuleDefinitions, HttpStatus.OK); + } + + /** * Return module references for a cm handle. * * @param cmHandle the cm handle diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java index 933ca88c9e..ca109d649c 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapper.java @@ -55,7 +55,8 @@ public interface CmHandleStateMapper { if (compositeStateDataStore.getOperationalDataStore() != null) { final SyncState operationalSyncState = new SyncState(); - operationalSyncState.setState(compositeStateDataStore.getOperationalDataStore().getSyncState().name()); + operationalSyncState.setState(compositeStateDataStore.getOperationalDataStore() + .getDataStoreSyncState().name()); operationalSyncState.setLastSyncTime(compositeStateDataStore.getOperationalDataStore().getLastSyncTime()); dataStores.setOperational(operationalSyncState); } |