summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution
diff options
context:
space:
mode:
authorSerge Simard <serge@agilitae.com>2019-06-18 10:36:57 -0400
committerSerge Simard <serge@agilitae.com>2019-06-18 10:36:57 -0400
commitd1e26003105404f974f9fa45d542f658706ad3cb (patch)
tree154fbabc9232146e518a25dee845ee16ec4f2405 /ms/blueprintsprocessor/functions/resource-resolution
parent39167cccae3271603819aa39c6476e434c759533 (diff)
Create REST API layer for resource resolution stored configlet
Issue-ID: CCSDK-1407 Signed-off-by: Serge Simard <serge@agilitae.com> Change-Id: I18db6b654cbf4f416af54596ee71f56eaa860d32
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt32
1 files changed, 22 insertions, 10 deletions
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<String, Any>, 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