.resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
}
+suspend fun AbstractComponentFunction.storedResolutionKeysForArtifactNameNB(
+ artifactName: String
+): List<String> {
+ return BluePrintDependencyService.resourceResolutionService()
+ .resolveResolutionKeysFromDatabase(bluePrintRuntimeService, artifactName)
+}
+
+suspend fun AbstractComponentFunction.storedArtifactNamesAndResolutionKeysNB(): Map<String,List<String>> {
+ return BluePrintDependencyService.resourceResolutionService()
+ .resolveArtifactNamesAndResolutionKeysFromDatabase(bluePrintRuntimeService)
+}
+
suspend fun AbstractComponentFunction.storedResourceResolutionsNB(
resolutionKey: String,
artifactName: String,
}
fun AbstractComponentFunction.contentFromResolvedArtifact(artifactPrefix: String): String = runBlocking {
- contentFromResolvedArtifactNB(artifactPrefix)
-}
+ contentFromResolvedArtifactNB(artifactPrefix)
+ }
\ No newline at end of file
resolutionKey: String
): String
+ suspend fun resolveResolutionKeysFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String
+ ): List<String>
+
+ suspend fun resolveArtifactNamesAndResolutionKeysFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>
+ ): Map<String, List<String>>
+
suspend fun resolveResources(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
nodeTemplateName: String,
)
}
+ override suspend fun resolveResolutionKeysFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactTemplate: String
+ ): List<String> {
+ return templateResolutionDBService.findResolutionKeysByBlueprintNameAndBlueprintVersionAndArtifactName(
+ bluePrintRuntimeService,
+ artifactTemplate
+ )
+ }
+
+ override suspend fun resolveArtifactNamesAndResolutionKeysFromDatabase(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>): Map<String, List<String>> {
+ return templateResolutionDBService.findArtifactNamesAndResolutionKeysByBlueprintNameAndBlueprintVersion(
+ bluePrintRuntimeService
+ )
+ }
+
override suspend fun resolveResources(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
nodeTemplateName: String,
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
)
}
-}
+}
\ No newline at end of file
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db
import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.data.jpa.repository.Query
+import org.springframework.data.repository.query.Param
import org.springframework.stereotype.Repository
import javax.transaction.Transactional
occurrence: Int
): TemplateResolution?
+ @Query(
+ "select tr.resolutionKey from TemplateResolution tr where tr.blueprintName = :blueprintName and tr.blueprintVersion = :blueprintVersion and tr.artifactName = :artifactName and tr.occurrence = :occurrence"
+ )
+ fun findResolutionKeysByBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
+ @Param("blueprintName") blueprintName: String?,
+ @Param("blueprintVersion") blueprintVersion: String?,
+ @Param("artifactName") artifactName: String,
+ @Param("occurrence") occurrence: Int
+ ): List<String>?
+
+ @Query(
+ "select tr.artifactName as artifactName, tr.resolutionKey as resolutionKey from TemplateResolution tr where tr.blueprintName = :blueprintName and tr.blueprintVersion = :blueprintVersion and tr.occurrence = :occurrence"
+ )
+ fun findArtifactNamesAndResolutionKeysByBlueprintNameAndBlueprintVersionAndOccurrence(
+ @Param("blueprintName") blueprintName: String?,
+ @Param("blueprintVersion") blueprintVersion: String?,
+ @Param("occurrence") occurrence: Int
+ ): List<TemplateResolutionSelector>?
+
@Transactional
fun deleteByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
resourceId: String,
--- /dev/null
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db
+
+interface TemplateResolutionSelector {
+ fun getArtifactName(): String
+ fun getResolutionKey(): String
+}
\ No newline at end of file
)?.result ?: throw EmptyResultDataAccessException(1)
}
+ suspend fun findResolutionKeysByBlueprintNameAndBlueprintVersionAndArtifactName(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String,
+ occurrence: Int = 1
+ ): List<String> =
+ withContext(Dispatchers.IO) {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]!!
+ val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]!!
+
+ templateResolutionRepository.findResolutionKeysByBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
+ blueprintName,
+ blueprintVersion,
+ artifactPrefix,
+ occurrence
+ ) ?: throw EmptyResultDataAccessException(1)
+ }
+
+ suspend fun findArtifactNamesAndResolutionKeysByBlueprintNameAndBlueprintVersion(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ occurrence: Int = 1
+ ): Map<String,List<String>> =
+ withContext(Dispatchers.IO) {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]!!
+ val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]!!
+
+ val resultList = templateResolutionRepository.findArtifactNamesAndResolutionKeysByBlueprintNameAndBlueprintVersionAndOccurrence(
+ blueprintName,
+ blueprintVersion,
+ occurrence
+ ) ?: throw EmptyResultDataAccessException(1)
+
+ var resultMap: MutableMap<String, MutableList<String>> = mutableMapOf()
+
+ resultList.forEach { it ->
+ if (!resultMap.containsKey(it.getArtifactName())) {
+ resultMap[it.getArtifactName()] = mutableListOf(it.getResolutionKey())
+ } else {
+ resultMap[it.getArtifactName()]!!.add(it.getResolutionKey())
+ }
+ }
+ resultMap
+ .mapValues { it.value.toList() }
+ .toMap()
+ }
+
suspend fun findByResoureIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactName(
blueprintName: String,
blueprintVersion: String,
throw BluePrintException("Failed to store resource api result.", ex)
}
}
-}
+}
\ No newline at end of file