summaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
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 0092b7026..9dbe15ef1 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)