diff options
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt')
-rw-r--r-- | ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt index 906aedf09..af6d1abc1 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt @@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory import org.springframework.dao.DataIntegrityViolationException import org.springframework.dao.EmptyResultDataAccessException import org.springframework.stereotype.Service +import java.lang.IllegalArgumentException import java.util.UUID @Service @@ -336,4 +337,55 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa artifactPrefix ) } + + suspend fun deleteTemplates( + blueprintName: String, + blueprintVersion: String, + artifactPrefix: String, + resolutionKey: String, + lastNOccurrences: Int? + ): Int = lastNOccurrences?.let { + if (lastNOccurrences < 0) { + throw IllegalArgumentException("last N occurrences must be a positive integer") + } + templateResolutionRepository.deleteTemplates( + blueprintName, + blueprintVersion, + artifactPrefix, + resolutionKey, + it + ) + } ?: templateResolutionRepository.deleteByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName( + resolutionKey, + blueprintName, + blueprintVersion, + artifactPrefix + ) + + suspend fun deleteTemplates( + blueprintName: String, + blueprintVersion: String, + artifactPrefix: String, + resourceType: String, + resourceId: String, + lastNOccurrences: Int? + ): Int = lastNOccurrences?.let { + if (lastNOccurrences < 0) { + throw IllegalArgumentException("last N occurrences must be a positive integer") + } + templateResolutionRepository.deleteTemplates( + blueprintName, + blueprintVersion, + artifactPrefix, + resourceType, + resourceId, + it + ) + } ?: templateResolutionRepository.deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName( + resourceId, + resourceType, + blueprintName, + blueprintVersion, + artifactPrefix + ) } |