val resolutionKey =
getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
val storeResult = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)?.asBoolean() ?: false
+ val forceResolution = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION)?.asBoolean() ?: false
val resourceId =
getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
val properties: MutableMap<String, Any> = mutableMapOf()
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION] = forceResolution
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = resolutionKey
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] = resourceId
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] = resourceType
val artifactTemplate = "$artifactPrefix-template"
// Resource Assignment Artifact Definition Name
val artifactMapping = "$artifactPrefix-mapping"
+ val forceResolution = isForceResolution(properties)
log.info("Resolving resource with resource assignment artifact($artifactMapping)")
if (isToStore(properties)) {
val existingResourceResolution = isNewResolution(bluePrintRuntimeService, properties, artifactPrefix)
if (existingResourceResolution.isNotEmpty()) {
- updateResourceAssignmentWithExisting(
- bluePrintRuntimeService as ResourceAssignmentRuntimeService,
- existingResourceResolution, resourceAssignments
- )
+ if (forceResolution) {
+ resourceResolutionDBService.deleteResourceResolutionList(existingResourceResolution)
+ log.info("Force resolution is enabled - will resolve all resources.")
+ } else {
+ updateResourceAssignmentWithExisting(
+ bluePrintRuntimeService as ResourceAssignmentRuntimeService,
+ existingResourceResolution, resourceAssignments
+ )
+ log.info("Force resolution is disabled - will resolve all resources not already resolved.")
+ }
}
}
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
}
+ private fun isForceResolution(properties: Map<String, Any>): Boolean =
+ properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION) &&
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION] as Boolean
+
// Check whether resolution already exist in the database for the specified resolution-key or resourceId/resourceType
private suspend fun isNewResolution(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
)
if (existingResourceAssignments.isNotEmpty()) {
log.info(
- "Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
+ "Resolution with resolutionKey=($resolutionKey) already exist",
resolutionKey
)
}
)
if (existingResourceAssignments.isNotEmpty()) {
log.info(
- "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already " +
- "exist - will resolve all resources not already resolved."
+ "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist"
)
}
return existingResourceAssignments