1 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
3 import com.fasterxml.jackson.databind.JsonNode
4 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
5 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
6 import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
8 class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
9 : DefaultBluePrintRuntimeService(id, bluePrintContext) {
11 private lateinit var resolutionId: String
12 private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
14 fun createUniqueId(key: String) {
15 resolutionId = "$id-$key"
18 fun cleanResourceStore() {
22 fun putResolutionStore(key: String, value: JsonNode) {
23 resourceStore[key] = value
26 fun getResolutionStore(key: String): JsonNode {
27 return resourceStore[key]
28 ?: throw BluePrintProcessorException("failed to get execution property ($key)")
31 fun checkResolutionStore(key: String): Boolean {
32 return resourceStore.containsKey(key)
35 fun getJsonNodeFromResolutionStore(key: String): JsonNode {
36 return getResolutionStore(key)
39 fun getStringFromResolutionStore(key: String): String? {
40 return getResolutionStore(key).asText()
43 fun getBooleanFromResolutionStore(key: String): Boolean? {
44 return getResolutionStore(key).asBoolean()
47 fun getIntFromResolutionStore(key: String): Int? {
48 return getResolutionStore(key).asInt()
51 fun getDoubleFromResolutionStore(key: String): Double? {
52 return getResolutionStore(key).asDouble()
55 fun putDictionaryStore(key: String, value: JsonNode) {
56 resourceStore["dictionary-$key"] = value
59 fun getDictionaryStore(key: String): JsonNode {
60 return resourceStore["dictionary-$key"]
61 ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
64 fun checkDictionaryStore(key: String): Boolean {
65 return resourceStore.containsKey("dictionary-$key")
68 fun getJsonNodeFromDictionaryStore(key: String): JsonNode {
69 return getResolutionStore("dictionary-$key")
72 fun getStringFromDictionaryStore(key: String): String? {
73 return getResolutionStore("dictionary-$key").asText()
76 fun getBooleanFromDictionaryStore(key: String): Boolean? {
77 return getResolutionStore("dictionary-$key").asBoolean()
80 fun getIntFromDictionaryStore(key: String): Int? {
81 return getResolutionStore("dictionary-$key").asInt()
84 fun getDoubleFromDictionaryStore(key: String): Double? {
85 return getResolutionStore("dictionary-$key").asDouble()