Set resource data value when fetch from database 35/93135/4
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Thu, 8 Aug 2019 22:20:13 +0000 (18:20 -0400)
committerDan Timoney <dtimoney@att.com>
Fri, 9 Aug 2019 19:49:22 +0000 (19:49 +0000)
When doing resource resolution, if the same resolution-key,
or the same resource-id/resource-type combo, is used, then the
process will only try to resolve the resources set with a "failure"
status from the RESOURCE_RESOLUTION db table.
In the case the resource has previsously successfully been resolved,
then we need to set its value in the resource assignemnt resolution
store so it can be used later in the processing, for instance if another
resource depends on it.

Change-Id: Ifa3957fe3d2365e1f4347aa61ed963124f8a69f7
Issue-ID: CCSDK-1606
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt

index 3140657..b9b7103 100644 (file)
@@ -121,7 +121,8 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
         if (isToStore(properties)) {
             val existingResourceResolution = isNewResolution(bluePrintRuntimeService, properties, artifactPrefix)
             if (existingResourceResolution.isNotEmpty()) {
-                updateResourceAssignmentWithExisting(existingResourceResolution, resourceAssignments)
+                updateResourceAssignmentWithExisting(bluePrintRuntimeService as ResourceAssignmentRuntimeService,
+                    existingResourceResolution, resourceAssignments)
             }
         }
 
@@ -296,15 +297,18 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
     }
 
     // Update the resource assignment list with the status of the resource that have already been resolved
-    private fun updateResourceAssignmentWithExisting(resourceResolutionList: List<ResourceResolution>,
+    private fun updateResourceAssignmentWithExisting(raRuntimeService : ResourceAssignmentRuntimeService,
+                                                     resourceResolutionList: List<ResourceResolution>,
                                                      resourceAssignmentList: MutableList<ResourceAssignment>) {
         resourceResolutionList.forEach { resourceResolution ->
             if (resourceResolution.status == BluePrintConstants.STATUS_SUCCESS) {
                 resourceAssignmentList.forEach {
                     if (compareOne(resourceResolution, it)) {
                         log.info("Resource ({}) already resolve: value=({})", it.name, resourceResolution.value)
-                        it.property!!.value = resourceResolution.value!!.asJsonPrimitive()
+                        val value = resourceResolution.value!!.asJsonPrimitive()
+                        it.property!!.value = value
                         it.status = resourceResolution.status
+                        ResourceAssignmentUtils.setResourceDataValue(it, raRuntimeService, value)
                     }
                 }
             }