Enable retrieving ResourceResolution objects from database in kotlin scripts 62/114362/2
authorkuldip Rai <kuldip.rai@bell.ca>
Tue, 20 Oct 2020 20:37:42 +0000 (16:37 -0400)
committerkuldipr <kuldip.rai@amdocs.com>
Wed, 28 Oct 2020 15:25:22 +0000 (11:25 -0400)
Issue-ID: CCSDK-2949
Change-Id: I9605d8cdb2a61cba45c56f3dcc12740d4da0b5c8
Signed-off-by: kuldipr <kuldip.rai@amdocs.com>
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt

index 6451b8f..4774ad5 100644 (file)
@@ -17,6 +17,8 @@
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
 
 import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolution
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionDBService
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
 
@@ -26,6 +28,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyS
 fun BluePrintDependencyService.resourceResolutionService(): ResourceResolutionService =
     instance(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
 
+fun BluePrintDependencyService.resourceResolutionDBService(): ResourceResolutionDBService =
+    instance(ResourceResolutionDBService::class.java)
+
 suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(
     resolutionKey: String,
     artifactName: String
@@ -34,6 +39,20 @@ suspend fun AbstractComponentFunction.storedContentFromResolvedArtifactNB(
         .resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
 }
 
+suspend fun AbstractComponentFunction.storedResourceResolutionsNB(
+    resolutionKey: String,
+    artifactName: String,
+    occurrence: Int = 1
+): List<ResourceResolution> {
+    return BluePrintDependencyService.resourceResolutionDBService()
+        .findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence(
+            bluePrintRuntimeService,
+            resolutionKey,
+            occurrence,
+            artifactName
+        )
+}
+
 /**
  * Return resolved and mashed artifact content for artifact prefix [artifactPrefix]
  */