summaryrefslogtreecommitdiffstats
path: root/components/resource-dict
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-14 16:41:37 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-14 16:41:37 -0500
commit5045877d046ebcddc80a8b83c14351a0d9fe6a49 (patch)
treec197485e2949705caef23c7825b1ecc7ff3dc77c /components/resource-dict
parent72066bf5f27870a6bd009b920452a77d57fd8af3 (diff)
Add blueprint resource definition enrichment.
Change-Id: I01234093028ffdc8bf1688e41baba20fae7da5ce Issue-ID: CCSDK-747 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
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 aa6a9fb6..a39139ed 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 a3456cd4..1aeda0ba 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