summaryrefslogtreecommitdiffstats
path: root/components/core
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/core
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/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt43
1 files changed, 36 insertions, 7 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
index 0092b702..9dbe15ef 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
@@ -64,20 +64,24 @@ object BluePrintMetadataUtils {
}
@JvmStatic
- fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
+ fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+ val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
- log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+ val context: MutableMap<String, JsonNode> = hashMapOf()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
- return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+ val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ bluePrintRuntimeService.setExecutionContext(context)
+
+ return bluePrintRuntimeService
}
@JvmStatic
- fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
-
- val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
+ fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath)
val context: MutableMap<String, JsonNode> = hashMapOf()
context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
@@ -97,6 +101,31 @@ object BluePrintMetadataUtils {
}
@JvmStatic
+ fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
+
+ val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+
+ log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+
+ return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
+ }
+
+ fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext {
+ val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+ // Clean Type files
+ BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath)
+ val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions)
+ val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
+
+ // Clean the Import Definitions
+ rootServiceTemplate.imports?.clear()
+
+ val blueprintContext = BluePrintContext(rootServiceTemplate)
+ blueprintContext.rootPath = blueprintBasePath
+ return blueprintContext
+ }
+
+ @JvmStatic
fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)
val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)