From d1e26003105404f974f9fa45d542f658706ad3cb Mon Sep 17 00:00:00 2001 From: Serge Simard Date: Tue, 18 Jun 2019 10:36:57 -0400 Subject: Create REST API layer for resource resolution stored configlet Issue-ID: CCSDK-1407 Signed-off-by: Serge Simard Change-Id: I18db6b654cbf4f416af54596ee71f56eaa860d32 --- .../db/ResourceResolutionResultService.kt | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt index cbc68bbc9..3cb9dec63 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt @@ -29,6 +29,21 @@ import java.util.* @Service class ResourceResolutionResultService(private val resourceResolutionRepository: ResourceResolutionRepository) { + suspend fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String, + resolutionKey: String): String = withContext(Dispatchers.IO) { + + val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! + + val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] + + resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( + resolutionKey, + blueprintName, + blueprintVersion, + artifactPrefix).result!! + } + suspend fun write(properties: Map, result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String) = withContext(Dispatchers.IO) { @@ -50,18 +65,15 @@ class ResourceResolutionResultService(private val resourceResolutionRepository: } } - suspend fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String, - resolutionKey: String): String = withContext(Dispatchers.IO) { + suspend fun readByKey(resolutionResultId: String): String = withContext(Dispatchers.IO) { - val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! + resourceResolutionRepository.getOne(resolutionResultId).result!! + } - val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION] - val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME] + suspend fun deleteByKey(resolutionResultId: String): Unit = withContext(Dispatchers.IO) { - resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( - resolutionKey, - blueprintName, - blueprintVersion, - artifactPrefix).result!! + val row = resourceResolutionRepository.getOne(resolutionResultId) + resourceResolutionRepository.delete(row) + resourceResolutionRepository.flush() } } \ No newline at end of file -- cgit 1.2.3-korg