From e4eb1fc26edd78b62e9e05d00dc5fec44b2be534 Mon Sep 17 00:00:00 2001 From: kuldip Rai Date: Tue, 20 Oct 2020 16:37:42 -0400 Subject: Enable retrieving ResourceResolution objects from database in kotlin scripts Issue-ID: CCSDK-2949 Change-Id: I9605d8cdb2a61cba45c56f3dcc12740d4da0b5c8 Signed-off-by: kuldipr --- .../resolution/ResourceResolutionExtensions.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ms/blueprintsprocessor/functions/resource-resolution') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt index 6451b8fc8..4774ad57a 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionExtensions.kt @@ -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 { + return BluePrintDependencyService.resourceResolutionDBService() + .findByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyAndOccurrence( + bluePrintRuntimeService, + resolutionKey, + occurrence, + artifactName + ) +} + /** * Return resolved and mashed artifact content for artifact prefix [artifactPrefix] */ -- cgit 1.2.3-korg