aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-18 08:16:28 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-18 08:16:28 -0500
commitbefd14604e8f19a517f79c0f8b6ff2f4b418d747 (patch)
tree05f074c48d9bf025d83abd12ddba856df9dba345
parent4db65041b3b076a518be6b62c2dc22c455faa2ab (diff)
Add attribute definition enhancer.
Change-Id: Ie8ac60910f04dfca477d0276aa451821cfcd8510 Issue-ID: CCSDK-718 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt8
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt12
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt4
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt63
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt165
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json5
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json (renamed from components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json)0
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt14
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt27
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt26
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt17
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt20
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt15
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt35
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt61
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java33
23 files changed, 322 insertions, 205 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
index 8bfa2db7..5461798d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt
@@ -26,13 +26,5 @@ object ConfigModelConstant {
const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"
const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"
-
- const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
-
- const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
-
const val CAPABILITY_PROPERTY_MAPPING = "mapping"
-
- const val PROPERTY_RECIPE_NAMES = "action-names"
-
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index 9b6fbbf1..19f09432 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.core.data
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
+import com.fasterxml.jackson.annotation.JsonPropertyOrder
import com.fasterxml.jackson.databind.JsonNode
import io.swagger.annotations.ApiModelProperty
@@ -183,12 +184,14 @@ class AttributeDefinition {
@get:JsonIgnore
var id: String? = null
var description: String? = null
+ var required: Boolean? = null
lateinit var type: String
@JsonProperty("default")
var defaultValue: JsonNode? = null
var status: String? = null
+ var constraints: MutableList<ConstraintClause>? = null
@JsonProperty("entry_schema")
- var entrySchema: String? = null
+ var entrySchema: EntrySchema? = null
}
/*
@@ -579,7 +582,8 @@ class ConditionClause {
A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.
*/
-class ServiceTemplate {
+@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"])
+class ServiceTemplate : Cloneable {
@get:JsonIgnore
var id: String? = null
@get:JsonProperty("tosca_definitions_version")
@@ -600,6 +604,10 @@ class ServiceTemplate {
var policyTypes: MutableMap<String, PolicyType>? = null
@get:JsonProperty("topology_template")
var topologyTemplate: TopologyTemplate? = null
+
+ override public fun clone(): ServiceTemplate {
+ return super.clone() as ServiceTemplate
+ }
}
class ToscaMetaData {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
index 84af3f98..bc1f4b43 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
@@ -36,6 +36,10 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
* Blueprint CBA extracted file location
*/
var rootPath = "."
+ /**
+ * Root Definition file path
+ */
+ var entryDefinition = ""
val imports: List<ImportDefinition>? = serviceTemplate.imports
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
index f9ac8760..67ae3987 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -22,6 +22,8 @@ import kotlinx.coroutines.runBlocking
import org.apache.commons.io.FileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import java.io.File
import java.io.FileFilter
@@ -79,6 +81,46 @@ class BluePrintFileUtils {
}
}
+ fun populateDefaultImports(blueprintContext: BluePrintContext) {
+ // Get the Default Types
+ val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_ARTIFACT_TYPES,
+ BluePrintConstants.PATH_NODE_TYPES, BluePrintConstants.PATH_POLICY_TYPES)
+
+ // Clean Type Imports
+ cleanImportTypes(blueprintContext.serviceTemplate)
+
+ val imports = mutableListOf<ImportDefinition>()
+ types.forEach { typeName ->
+ val import = ImportDefinition()
+ import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json")
+ imports.add(import)
+ }
+
+ blueprintContext.serviceTemplate.imports = imports
+ }
+
+ fun cleanImportTypes(serviceTemplate: ServiceTemplate) {
+ // Clean the Type imports
+ val toDeleteTypes = serviceTemplate.imports?.filter {
+ it.file.endsWith("_types.json")
+ }
+
+ if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) {
+ serviceTemplate.imports?.removeAll(toDeleteTypes)
+ }
+ }
+
+ fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) {
+
+ // Write Blueprint Types
+ writeBluePrintTypes(blueprintContext)
+ // Re Populate the Imports
+ populateDefaultImports(blueprintContext)
+ // Rewrite the Entry Definition Files
+ writeEntryDefinitionFile(blueprintContext)
+
+ }
+
fun writeBluePrintTypes(blueprintContext: BluePrintContext) {
val basePath = blueprintContext.rootPath
@@ -110,10 +152,29 @@ class BluePrintFileUtils {
}
}
+ fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) {
+
+ val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition)
+
+ val serviceTemplate = blueprintContext.serviceTemplate
+
+ // Clone the Service Template
+ val writeServiceTemplate = serviceTemplate.clone()
+ writeServiceTemplate.dataTypes = null
+ writeServiceTemplate.artifactTypes = null
+ writeServiceTemplate.policyTypes = null
+ writeServiceTemplate.nodeTypes = null
+
+ // Write the Serivice Template
+ writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true))
+ }
+
fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking {
val definitionFile = File(definitionFile)
+ // Delete the File If exists
+ Files.deleteIfExists(definitionFile.toPath())
- Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE)
+ Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW)
check(definitionFile.exists()) {
throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})")
}
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 9dbe15ef..5b5561f6 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
@@ -31,109 +31,114 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRun
import java.io.File
import java.nio.charset.Charset
-object BluePrintMetadataUtils {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+class BluePrintMetadataUtils {
+ companion object {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- @JvmStatic
- fun toscaMetaData(basePath: String): ToscaMetaData {
- val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER).plus("TOSCA-Metadata/TOSCA.meta")
- return toscaMetaDataFromMetaFile(toscaMetaPath)
- }
- @JvmStatic
- fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
- val toscaMetaData = ToscaMetaData()
- val lines: MutableList<String> = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset())
- lines.forEach { line ->
- if (line.contains(":")) {
- val keyValue = line.split(":")
- if (keyValue.size == 2) {
- val value: String = keyValue[1].trim()
- when (keyValue[0]) {
- "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value
- "CSAR-Version" -> toscaMetaData.csarVersion = value
- "Created-By" -> toscaMetaData.createdBy = value
- "Entry-Definitions" -> toscaMetaData.entityDefinitions = value
- "Template-Tags" -> toscaMetaData.templateTags = value
+ fun toscaMetaData(basePath: String): ToscaMetaData {
+ val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
+ return toscaMetaDataFromMetaFile(toscaMetaPath)
+ }
+
+ fun entryDefinitionFile(basePath: String): String {
+ val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
+ return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions
+ }
+
+ fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
+ val toscaMetaData = ToscaMetaData()
+ val lines: MutableList<String> = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset())
+ lines.forEach { line ->
+ if (line.contains(":")) {
+ val keyValue = line.split(":")
+ if (keyValue.size == 2) {
+ val value: String = keyValue[1].trim()
+ when (keyValue[0]) {
+ "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value
+ "CSAR-Version" -> toscaMetaData.csarVersion = value
+ "Created-By" -> toscaMetaData.createdBy = value
+ "Entry-Definitions" -> toscaMetaData.entityDefinitions = value
+ "Template-Tags" -> toscaMetaData.templateTags = value
+ }
}
}
- }
+ }
+ return toscaMetaData
}
- return toscaMetaData
- }
- @JvmStatic
- fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
+ val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
- val context: MutableMap<String, JsonNode> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
+ val context: MutableMap<String, JsonNode> = hashMapOf()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
+ context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
- val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
- bluePrintRuntimeService.setExecutionContext(context)
+ val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ bluePrintRuntimeService.setExecutionContext(context)
- return bluePrintRuntimeService
- }
+ return bluePrintRuntimeService
+ }
- @JvmStatic
- fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ 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()
+ 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()
- val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
- bluePrintRuntimeService.setExecutionContext(context)
+ val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ bluePrintRuntimeService.setExecutionContext(context)
- return bluePrintRuntimeService
- }
+ return bluePrintRuntimeService
+ }
- @JvmStatic
- fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode>): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
- val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
- val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
- bluePrintRuntimeService.setExecutionContext(executionContext)
- return bluePrintRuntimeService
- }
+ fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode>): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
+ val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ bluePrintRuntimeService.setExecutionContext(executionContext)
+ return bluePrintRuntimeService
+ }
- @JvmStatic
- fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
+ fun getBluePrintContext(blueprintBasePath: String): BluePrintContext {
- val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
+ val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath)
- log.info("Processing blueprint base path ($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
+ log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})")
- return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath)
- }
+ 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)
+ private 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()
+ // Clean the Import Definitions
+ BluePrintFileUtils.cleanImportTypes(rootServiceTemplate)
- val blueprintContext = BluePrintContext(rootServiceTemplate)
- blueprintContext.rootPath = blueprintBasePath
- return blueprintContext
- }
+ val blueprintContext = BluePrintContext(rootServiceTemplate)
+ blueprintContext.rootPath = blueprintBasePath
+ blueprintContext.entryDefinition = toscaMetaData.entityDefinitions
+ return blueprintContext
+ }
- @JvmStatic
- fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
- val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)
- val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
- // Recursively Import Template files
- val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath)
- val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()
- val blueprintContext = BluePrintContext(completeServiceTemplate)
- blueprintContext.rootPath = basePath
- return blueprintContext
+ private fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext {
+ val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions)
+ val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath)
+ // Recursively Import Template files
+ val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath)
+ val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate()
+ val blueprintContext = BluePrintContext(completeServiceTemplate)
+ blueprintContext.rootPath = basePath
+ blueprintContext.entryDefinition = entityDefinitions
+ return blueprintContext
+ }
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
index 7330663c..6a156ff1 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
@@ -37,9 +37,8 @@
"component-resource-assignment": {
"description": "This is Resource Assignment Component API",
"version": "1.0.0",
- "properties": {
- "request-id": {
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",
+ "attributes": {
+ "assignment-params": {
"required": true,
"type": "string"
}
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json
index 557f6efc..557f6efc 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_definition_types.json
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
index 51d70ede..38fc97d7 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
@@ -1,6 +1,12 @@
{
"description": "This is Resource Assignment Component API",
"version": "1.0.0",
+ "attributes": {
+ "assignment-params": {
+ "required": true,
+ "type": "string"
+ }
+ },
"capabilities": {
"component-node": {
"type": "tosca.capabilities.Node"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 3211d6e8..eaa8eacc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -21,7 +21,7 @@ class ResourceResolutionConstants {
const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
- const val FILE_NAME_RESOURCE_DICTIONARY_TYPES = "resources_dictionary_types.json"
+ const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index c3cf0097..16db9c96 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -83,7 +83,7 @@ class ResourceResolutionService {
// Get the Resource Dictionary Name
val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
.plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
- .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DICTIONARY_TYPES)
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
index 3c6b14ba..96931014 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java
@@ -48,7 +48,7 @@ public class ConfigModelUtils {
public static ConfigModel getConfigModel(String blueprintPath) throws Exception {
Preconditions.checkArgument(StringUtils.isNotBlank(blueprintPath), "Blueprint Path is missing");
- ToscaMetaData toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintPath);
+ ToscaMetaData toscaMetaData = BluePrintMetadataUtils.Companion.toscaMetaData(blueprintPath);
Preconditions.checkNotNull(toscaMetaData, "failed to get Blueprint Metadata information");
Preconditions.checkArgument(StringUtils.isNotBlank(toscaMetaData.getEntityDefinitions()), "failed to get Blueprint Definition file");
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
index 986ce986..3b14d82f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
@@ -22,7 +22,6 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -30,6 +29,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.springframework.stereotype.Service
@Service
@@ -56,10 +56,10 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val artifactTypeName = artifactDefinition.type
- ?: throw BluePrintException("Artifact type is missing for ArtifactDefinition($name)")
+ ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)")
// Populate Artifact Type
- populateArtifactType(artifactTypeName)
+ BluePrintEnhancerUtils.populateArtifactType(bluePrintContext, bluePrintRepoService, artifactTypeName)
when (artifactTypeName) {
ARTIFACT_TYPE_MAPPING_SOURCE -> {
@@ -90,12 +90,4 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
}
}
- open fun populateArtifactType(artifactTypeName: String): ArtifactType {
-
- val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)
- ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
- bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
- return artifactType
- }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
index 9f579bc5..f69e344f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
@@ -16,17 +16,40 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintAttributeDefinitionEnhancer {
- override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val propertyType = attributeDefinition.type
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+ val entrySchema = attributeDefinition.entrySchema
+ ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
+
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
+ }
+ } else {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
+ }
}
+
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index 6c7b6e08..d7895957 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -58,8 +58,8 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePr
bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",
blueprintRuntimeService.bluePrintContext().serviceTemplate)
- // Write the Type File Definitions
- BluePrintFileUtils.writeBluePrintTypes(blueprintRuntimeService.bluePrintContext())
+ // Write the Enhanced Blueprint Definitions
+ BluePrintFileUtils.writeEnhancedBluePrint(blueprintRuntimeService.bluePrintContext())
// Enhance Resource Dictionary
enhanceResourceDefinition(blueprintRuntimeService)
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
index 941be07f..4e226b2e 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
@@ -18,17 +18,16 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.InterfaceDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationDefinition
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -52,11 +51,14 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
val derivedFrom = nodeType.derivedFrom
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
- val derivedFromNodeType = populateNodeType(name)
+ val derivedFromNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, name)
// Enrich NodeType
enhance(bluePrintRuntimeService, derivedFrom, derivedFromNodeType)
}
+ // NodeType Attribute Definitions
+ enrichNodeTypeAtributes(name, nodeType)
+
// NodeType Property Definitions
enrichNodeTypeProperties(name, nodeType)
@@ -71,6 +73,12 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
+ open fun enrichNodeTypeAtributes(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.attributes?.let {
+ bluePrintTypeEnhancerService.enhanceAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
+ }
+ }
+
open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
nodeType.properties?.let {
bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
@@ -83,7 +91,8 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
- val requirementNodeType = populateNodeType(requirementNodeTypeName)
+ val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext,
+ bluePrintRepoService, requirementNodeTypeName)
// Enhanypece Node T
enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
}
@@ -127,13 +136,4 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
- open fun populateNodeType(nodeTypeName: String): NodeType {
-
- val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName)
- ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
- bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
- return nodeType
- }
-
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
index ee3e6c37..1ae558fa 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
@@ -18,14 +18,13 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -36,11 +35,9 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintPropertyDefinitionEnhancer {
-
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
-
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -53,19 +50,11 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
?: throw BluePrintException("Entry Schema is missing for collection property($name)")
if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
- populateDataTypes(entrySchema.type)
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
}
} else {
- populateDataTypes(propertyType)
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
}
}
- open fun populateDataTypes(dataTypeName: String): DataType {
- val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
- ?: bluePrintRepoService.getDataType(dataTypeName)
- ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
- bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType)
- return dataType
- }
-
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
index 2ad0583e..51064bb4 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
@@ -62,7 +62,7 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService
open fun enhanceTopologyTemplate() {
bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
- bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "default", topologyTemplate)
+ bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "topology_template", topologyTemplate)
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
index 6b72d420..428d490b 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
@@ -37,7 +37,7 @@ open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoServic
enhanceTopologyTemplateInputs(type)
enhanceTopologyTemplateNodeTemplates(type)
- enhanceTopologyTemplateWorkflowss(type)
+ enhanceTopologyTemplateWorkflows(type)
}
open fun enhanceTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
@@ -52,7 +52,7 @@ open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoServic
}
}
- open fun enhanceTopologyTemplateWorkflowss(topologyTemplate: TopologyTemplate) {
+ open fun enhanceTopologyTemplateWorkflows(topologyTemplate: TopologyTemplate) {
topologyTemplate.workflows?.forEach { workflowName, workflow ->
bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow)
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
index a620e9bf..9fbf0916 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -18,9 +18,9 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
@@ -169,27 +169,27 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
val dataTypeName = "dt-$workflowName-properties"
- var recipeDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ var dynamicDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
- if (recipeDataType == null) {
+ if (dynamicDataType == null) {
log.info("dataType not present for the recipe({})", dataTypeName)
- recipeDataType = DataType()
- recipeDataType.version = "1.0.0"
- recipeDataType.description = "Dynamic DataType definition for workflow($workflowName)."
- recipeDataType.derivedFrom = ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC
+ dynamicDataType = DataType()
+ dynamicDataType.version = "1.0.0"
+ dynamicDataType.description = "Dynamic DataType definition for workflow($workflowName)."
+ dynamicDataType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
val dataTypeProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
- recipeDataType.properties = dataTypeProperties
+ dynamicDataType.properties = dataTypeProperties
// Overwrite WorkFlow DataType
- bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, recipeDataType)
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dynamicDataType)
} else {
log.info("dynamic dataType($dataTypeName) already present for workflow($workflowName).")
}
// Merge all the Recipe Properties
mappingProperties.forEach { propertyName, propertyDefinition ->
- recipeDataType.properties?.put(propertyName, propertyDefinition)
+ dynamicDataType.properties?.put(propertyName, propertyDefinition)
}
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
index d6a00ae1..4d1f44a6 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
@@ -20,7 +20,6 @@ import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -70,8 +69,7 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
resourceAssignments.map { resourceAssignment ->
val dictionaryName = resourceAssignment.dictionaryName!!
val dictionarySource = resourceAssignment.dictionarySource!!
- log.debug("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
- dictionaryName, dictionarySource)
+ log.debug("Enriching assignment name(${resourceAssignment.name}), dictionary name($dictionaryName), source($dictionarySource)")
val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)
// Add Unique Node Types
@@ -87,7 +85,7 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
- ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
+ ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)")
// Enrich as NodeTemplate
bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)
@@ -101,15 +99,6 @@ open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionR
}
- /*
- override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
- val bluePrintEnhancerService = BluePrintEnhancerServiceImpl(resourceDefinitionRepoService)
- bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
- bluePrintEnhancerService.initialCleanUp()
- enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
- return bluePrintEnhancerService.serviceTemplate
- }
- */
private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
|| resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
index 1c5276c8..31b1a16b 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.service.load
import com.att.eelf.configuration.EELFManager
+import kotlinx.coroutines.*
import org.apache.commons.io.FilenameUtils
import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
@@ -40,19 +41,39 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService)
modelTypePaths.forEach { loadPathModelType(it) }
}
- open fun loadPathModelType(modelTypePath: String) {
+ open fun loadPathModelType(modelTypePath: String) = runBlocking {
log.info(" *************************** loadModelType **********************")
try {
val errorBuilder = StrBuilder()
- val dataTypeFiles = File("$modelTypePath/data_type").listFiles()
- dataTypeFiles.forEach { loadDataType(it, errorBuilder) }
+ coroutineScope {
+ val dataTypeFiles = File("$modelTypePath/data_type").listFiles()
- val artifactTypefiles = File("$modelTypePath/artifact_type").listFiles()
- artifactTypefiles.forEach { loadArtifactType(it, errorBuilder) }
+ val deferredResults = mutableListOf<Deferred<Unit>>()
- val nodeTypeFiles = File("$modelTypePath/node_type").listFiles()
- nodeTypeFiles.forEach { loadNodeType(it, errorBuilder) }
+ for (file in dataTypeFiles) deferredResults += async { loadDataType(file, errorBuilder) }
+
+ deferredResults.awaitAll()
+ }
+
+ coroutineScope {
+ val artifactTypefiles = File("$modelTypePath/artifact_type").listFiles()
+
+ val deferredResults = mutableListOf<Deferred<Unit>>()
+
+ for (file in artifactTypefiles) deferredResults += async { loadArtifactType(file, errorBuilder) }
+
+ deferredResults.awaitAll()
+ }
+
+ coroutineScope {
+ val nodeTypeFiles = File("$modelTypePath/node_type").listFiles()
+
+ val deferredResults = mutableListOf<Deferred<Unit>>()
+
+ for (file in nodeTypeFiles) deferredResults += async { loadNodeType(file, errorBuilder) }
+ deferredResults.awaitAll()
+ }
if (!errorBuilder.isEmpty) {
log.error(errorBuilder.toString())
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
new file mode 100644
index 00000000..801c22a1
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.utils
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+
+
+class BluePrintEnhancerUtils {
+ companion object {
+
+ fun populateDataTypes(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ dataTypeName: String): DataType {
+ val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: bluePrintRepoService.getDataType(dataTypeName)
+ ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.")
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType)
+ return dataType
+ }
+
+
+ fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ nodeTypeName: String): NodeType {
+
+ val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
+ ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
+ bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
+ return nodeType
+ }
+
+ fun populateArtifactType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ artifactTypeName: String): ArtifactType {
+
+ val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
+ bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
+ return artifactType
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java
deleted file mode 100644
index b38dd6de..00000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtilsTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.utils;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-
-public class ConfigModelUtilsTest {
-
- @Test
- public void testConfigModel() throws Exception {
-
- ConfigModel configModel = ConfigModelUtils.getConfigModel("load/blueprints/vrr-test");
- Assert.assertNotNull("Failed to prepare config model", configModel);
- Assert.assertTrue("Failed to prepare config model contents", CollectionUtils.isNotEmpty(configModel.getConfigModelContents()));
- }
-}