summaryrefslogtreecommitdiffstats
path: root/components/resource-dict
diff options
context:
space:
mode:
Diffstat (limited to 'components/resource-dict')
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt2
-rw-r--r--components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt20
2 files changed, 20 insertions, 2 deletions
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
index aa6a9fb65..a39139edc 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
@@ -31,4 +31,6 @@ object ResourceDictionaryConstants {
const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping"
const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping"
const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies"
+
+ const val PATH_RESOURCE_DEFINITION_TYPE = "resource_definition_types"
} \ No newline at end of file
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
index a3456cd43..1aeda0ba1 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
+++ b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
@@ -17,16 +17,20 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.apache.commons.collections.MapUtils
import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
-import com.att.eelf.configuration.EELFManager
+import java.io.File
object ResourceDictionaryUtils {
@@ -49,7 +53,7 @@ object ResourceDictionaryUtils {
resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT
}
log.info("auto map resourceAssignment : {}", resourceAssignment)
- }else {
+ } else {
resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT
}
}
@@ -75,4 +79,16 @@ object ResourceDictionaryUtils {
context[path] = valueNode
}
}
+
+ fun getResourceAssignmentFromFile(filePath: String): List<ResourceAssignment> {
+ return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
+ }
+
+ fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map<String, ResourceDefinition>) {
+ val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)
+ .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
+ val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true)
+ BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent)
+ }
} \ No newline at end of file