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