From 48b1bea8c1a636169cb5fecd3d0091064e02145b Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 18 Feb 2019 08:08:24 -0500 Subject: Simplify NetconfRpcService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6daac25c272ab6b437c07602167a76a2d61816db Issue-ID: CCSDK-790 Signed-off-by: Alexis de Talhouët --- .../service/enhancer/BluePrintEnhancerServiceImpl.kt | 4 ++-- .../service/enhancer/ResourceDefinitionEnhancerService.kt | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'ms/controllerblueprints') diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt index d4e4a24c..63171de6 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt @@ -67,14 +67,14 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService } } catch (e: Exception) { - log.error("failed in blueprint enhancement", e) + throw e } return blueprintRuntimeService.bluePrintContext() } private fun enhanceResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>) { - + log.info("##### Enhancing blueprint Resource Definitions") resourceDefinitionEnhancerService.enhance(blueprintRuntimeService) } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt index ab5ca74c..43eb019e 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +76,7 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe artifactDefinitionMap.value.file } - }?.single { it.isNotEmpty() }?.distinct() + }?.flatten()?.distinct() } // Convert file content to ResourceAssignments asynchronously @@ -103,12 +104,12 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe // Read the Resource Definitions from the Database and write to type file. private fun generateResourceDictionaryFile(blueprintBasePath: String, resourceAssignments: List) { - val resourcekeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct() - log.info("distinct resource keys ($resourcekeys)") + val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted() + log.info("distinct resource keys ($resourceKeys)") //TODO("Optimise DB single Query to multiple Query") // Collect the Resource Definition from database and convert to map to save in file - val resourceDefinitionMap = resourcekeys.map { resourceKey -> + val resourceDefinitionMap = resourceKeys.map { resourceKey -> getResourceDefinition(resourceKey) }.map { it.name to it }.toMap() -- cgit 1.2.3-korg