Simplify NetconfRpcService
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Mon, 18 Feb 2019 13:08:24 +0000 (08:08 -0500)
committerAlexis de Talhouët <adetalhouet89@gmail.com>
Mon, 18 Feb 2019 22:31:41 +0000 (17:31 -0500)
Change-Id: I6daac25c272ab6b437c07602167a76a2d61816db
Issue-ID: CCSDK-790
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt

index d4e4a24..63171de 100644 (file)
@@ -67,14 +67,14 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
             }\r
 \r
         } catch (e: Exception) {\r
-            log.error("failed in blueprint enhancement", e)\r
+            throw e\r
         }\r
 \r
         return blueprintRuntimeService.bluePrintContext()\r
     }\r
 \r
     private fun enhanceResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>) {\r
-\r
+        log.info("##### Enhancing blueprint Resource Definitions")\r
         resourceDefinitionEnhancerService.enhance(blueprintRuntimeService)\r
     }\r
 \r
index ab5ca74..43eb019 100644 (file)
@@ -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<ResourceAssignment>) {
-        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()