summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2019-07-24 10:55:34 -0400
committerOleg Mitsura <oleg.mitsura@amdocs.com>2019-07-30 10:26:23 -0400
commit2553d3773484c6867ae5af630847487579047c27 (patch)
tree9e65f9143e8a0a4dd53af41ff376fb1a3f89e5b2
parent06c38f1ae1e83103d615194fbaf3c55180bccb5d (diff)
TemplateResolutionService default #occurrence 0->1
JPA repository functions .findBy......... needs occurence value the API in the TemplateResolutionService was defaulting it to 1. Issue-Id: CCSDK-1526 Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: Iea1e7c50d57c60323eb5c71c0caf61d1ad573bfb
-rwxr-xr-xms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt4
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionService.kt13
2 files changed, 10 insertions, 7 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
index 70aadb4b1..e3f876365 100755
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolution.kt
@@ -71,7 +71,7 @@ class TemplateResolution : Serializable {
@get:ApiModelProperty(value = "If resolution occurred multiple time, this field provides the index.",
required = true)
@Column(name = "occurrence", nullable = false)
- var occurrence: Int = 0
+ var occurrence: Int = 1
@Id
@Column(name = "template_resolution_id")
@@ -87,4 +87,4 @@ class TemplateResolution : Serializable {
companion object {
private const val serialVersionUID = 1L
}
-} \ No newline at end of file
+}
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 55f7e770b..c64605ef0 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
@@ -53,7 +53,7 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
blueprintVersion: String,
artifactPrefix: String,
resolutionKey: String,
- occurrence: Int = 0): String =
+ occurrence: Int = 1): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -69,7 +69,7 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
artifactPrefix: String,
resourceId: String,
resourceType: String,
- occurrence: Int = 0): String =
+ occurrence: Int = 1): String =
withContext(Dispatchers.IO) {
templateResolutionRepository.findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
@@ -93,7 +93,6 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
val resourceId = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] as String
val resourceType = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] as String
val occurrence = properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] as Int
-
write(blueprintName,
blueprintVersion,
artifactPrefix,
@@ -105,7 +104,7 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
}
suspend fun write(blueprintName: String, blueprintVersion: String, artifactPrefix: String,
- template: String, occurrence: Int = 0, resolutionKey: String = "", resourceId: String = "",
+ template: String, occurrence: Int = 1, resolutionKey: String = "", resourceId: String = "",
resourceType: String = ""): TemplateResolution =
withContext(Dispatchers.IO) {
@@ -148,9 +147,13 @@ class TemplateResolutionService(private val templateResolutionRepository: Templa
}
}
try {
+ log.info("Writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence")
templateResolutionRepository.saveAndFlush(resourceResolutionResult)
} catch (ex: DataIntegrityViolationException) {
+ log.error("Error writing out template_resolution result: bpName: $blueprintName bpVer $blueprintVersion resKey:$resolutionKey" +
+ " (resourceId: $resourceId resourceType: $resourceType) occurrence:$occurrence error: {}", ex.message)
throw BluePrintException("Failed to store resource api result.", ex)
}
}
-} \ No newline at end of file
+}