blob: 8087f7e3fee52267396d6bc70fc57c3f0276ffb3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) :
DefaultBluePrintRuntimeService(id, bluePrintContext) {
private lateinit var resolutionId: String
private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
fun createUniqueId(key: String) {
resolutionId = "$id-$key"
}
fun cleanResourceStore() {
resourceStore.clear()
}
fun putResolutionStore(key: String, value: JsonNode) {
resourceStore[key] = value
}
fun getResolutionStore(): MutableMap<String, JsonNode> {
return resourceStore.mapValues { e -> e.value.deepCopy() as JsonNode }.toMutableMap()
}
fun getResolutionStore(key: String): JsonNode {
return resourceStore[key]
?: throw BluePrintProcessorException("failed to get execution property ($key)")
}
fun checkResolutionStore(key: String): Boolean {
return resourceStore.containsKey(key)
}
fun getJsonNodeFromResolutionStore(key: String): JsonNode {
return getResolutionStore(key)
}
fun getStringFromResolutionStore(key: String): String? {
return getResolutionStore(key).asText()
}
fun getBooleanFromResolutionStore(key: String): Boolean? {
return getResolutionStore(key).asBoolean()
}
fun getIntFromResolutionStore(key: String): Int? {
return getResolutionStore(key).asInt()
}
fun getDoubleFromResolutionStore(key: String): Double? {
return getResolutionStore(key).asDouble()
}
fun putDictionaryStore(key: String, value: JsonNode) {
resourceStore["dictionary-$key"] = value
}
fun getDictionaryStore(key: String): JsonNode {
return resourceStore["dictionary-$key"]
?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
}
fun checkDictionaryStore(key: String): Boolean {
return resourceStore.containsKey("dictionary-$key")
}
fun getJsonNodeFromDictionaryStore(key: String): JsonNode {
return getResolutionStore("dictionary-$key")
}
fun getStringFromDictionaryStore(key: String): String? {
return getResolutionStore("dictionary-$key").asText()
}
fun getBooleanFromDictionaryStore(key: String): Boolean? {
return getResolutionStore("dictionary-$key").asBoolean()
}
fun getIntFromDictionaryStore(key: String): Int? {
return getResolutionStore("dictionary-$key").asInt()
}
fun getDoubleFromDictionaryStore(key: String): Double? {
return getResolutionStore("dictionary-$key").asDouble()
}
}
|