aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt2
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt22
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt6
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt38
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt2
-rwxr-xr-xcomponents/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt103
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt14
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json54
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json98
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json9
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json44
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json49
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json1
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json5
-rw-r--r--components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt5
-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/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt59
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt84
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt)2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt)78
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt)78
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt)6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt)2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt8
-rwxr-xr-xms/controllerblueprints/application/opt/app/onap/config/application-dev.properties2
-rwxr-xr-xms/controllerblueprints/application/opt/app/onap/config/application.properties2
-rwxr-xr-xms/controllerblueprints/application/src/test/resources/application.properties2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java151
-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.kt27
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt7
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt5
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt132
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt14
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt83
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java73
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java56
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt75
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt40
-rwxr-xr-xms/controllerblueprints/modules/service/src/test/resources/application.properties2
47 files changed, 914 insertions, 598 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index fd6a8db1..102e2ebd 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -45,17 +45,13 @@ object BluePrintConstants {
const val USER_SYSTEM: String = "System"
- const val MODEL_CONTENT_TYPE_JSON: String = "JSON"
- const val MODEL_CONTENT_TYPE_YAML: String = "YAML"
- const val MODEL_CONTENT_TYPE_YANG: String = "YANG"
- const val MODEL_CONTENT_TYPE_SCHEMA: String = "SCHEMA"
-
const val PATH_DIVIDER: String = "/"
const val PATH_SERVICE_TEMPLATE: String = "service_template"
const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
const val PATH_METADATA: String = "metadata"
const val PATH_NODE_TYPES: String = "node_types"
const val PATH_POLICY_TYPES: String = "policy_types"
+ const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"
const val PATH_ARTIFACT_TYPES: String = "artifact_types"
const val PATH_DATA_TYPES: String = "data_types"
const val PATH_INPUTS: String = "inputs"
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 19f09432..9767b2e1 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
@@ -598,6 +598,8 @@ class ServiceTemplate : Cloneable {
var artifactTypes: MutableMap<String, ArtifactType>? = null
@get:JsonProperty("data_types")
var dataTypes: MutableMap<String, DataType>? = null
+ @get:JsonProperty("relationship_types")
+ var relationshipTypes: MutableMap<String, RelationshipType>? = null
@get:JsonProperty("node_types")
var nodeTypes: MutableMap<String, NodeType>? = null
@get:JsonProperty("policy_types")
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
index 6a50680e..8caec75f 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
@@ -16,15 +16,15 @@
package org.onap.ccsdk.apps.controllerblueprints.core.service
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
/**
*
@@ -35,12 +35,6 @@ object BluePrintExpressionService {
val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
@JvmStatic
- fun getExpressionData(propertyAssignment: Any): ExpressionData {
- val propertyAssignmentNode: JsonNode = JacksonUtils.jsonNodeFromObject(propertyAssignment)
- return getExpressionData(propertyAssignmentNode)
- }
-
- @JvmStatic
fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData {
log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)
val expressionData = ExpressionData(valueNode = propertyAssignmentNode)
@@ -53,19 +47,19 @@ object BluePrintExpressionService {
expressionData.expressionNode = propertyAssignmentNode
when (expressionData.command) {
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_INPUT -> {
+ BluePrintConstants.EXPRESSION_GET_INPUT -> {
expressionData.inputExpression = populateInputExpression(propertyAssignmentNode)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {
+ BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {
expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_PROPERTY -> {
+ BluePrintConstants.EXPRESSION_GET_PROPERTY -> {
expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {
+ BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {
expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode)
}
- org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
+ BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode)
}
}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
index fce06f3f..26eb19de 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt
@@ -28,11 +28,13 @@ import java.net.URLDecoder
import java.nio.charset.Charset
class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) {
+ companion object {
+ private const val PARENT_SERVICE_TEMPLATE: String = "parent"
+ }
private val log: Logger = LoggerFactory.getLogger(this::class.toString())
- val PARENT_SERVICE_TEMPLATE: String = "parent"
- var importServiceTemplateMap: MutableMap<String, ServiceTemplate> = hashMapOf()
+ private var importServiceTemplateMap: MutableMap<String, ServiceTemplate> = hashMapOf()
fun getImportResolvedServiceTemplate(): ServiceTemplate {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index 5540047c..bd19ae47 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -67,6 +67,12 @@ interface BluePrintRuntimeService<T> {
*/
fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode>
+ fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capability: String): MutableMap<String,
+ JsonNode>
+
+ fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap<String,
+ JsonNode>
+
fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>
fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap<String, JsonNode>
@@ -193,17 +199,15 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
- val propertyAssignments: MutableMap<String, JsonNode> =
- nodeTemplate.properties as MutableMap<String, JsonNode>
+ val propertyAssignments: MutableMap<String, JsonNode> = nodeTemplate.properties!!
// Get the Node Type Definitions
- val nodeTypeProperties: MutableMap<String, PropertyDefinition> =
- bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!!
+ val nodeTypeProperties: MutableMap<String, PropertyDefinition> = bluePrintContext.nodeTypeChainedProperties(nodeTemplate.type)!!
// Iterate Node Type Properties
nodeTypeProperties.forEach { nodeTypePropertyName, nodeTypeProperty ->
// Get the Express or Value for the Node Template
- val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]
+ val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]
var resolvedValue: JsonNode = NullNode.getInstance()
if (propertyAssignment != null) {
@@ -223,6 +227,18 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return propertyAssignmentValue
}
+ override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String):
+ MutableMap<String, JsonNode> {
+ log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " +
+ "($capabilityName)")
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun resolveNodeTemplateRequirementProperties(nodeTemplateName: String, requirementName: String): MutableMap<String, JsonNode> {
+ log.info("resolveNodeTemplateRequirementProperties for node template($nodeTemplateName) requirement ($requirementName)")
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String,
interfaceName: String, operationName: String): MutableMap<String, JsonNode> {
log.info("resolveNodeTemplateInterfaceOperationInputs for node template ({}),interface name ({}), " +
@@ -230,8 +246,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
- val propertyAssignments: MutableMap<String, Any> =
- bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>
+ val propertyAssignments: MutableMap<String, JsonNode> =
+ bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
?: hashMapOf()
val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type
@@ -245,7 +261,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
// Iterate Node Type Properties
nodeTypeInterfaceOperationInputs.forEach { nodeTypePropertyName, nodeTypeProperty ->
// Get the Express or Value for the Node Template
- val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]
+ val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]
var resolvedValue: JsonNode = NullNode.getInstance()
if (propertyAssignment != null) {
@@ -275,8 +291,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
- val propertyAssignments: MutableMap<String, Any> =
- bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>
+ val propertyAssignments: MutableMap<String, JsonNode> =
+ bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
?: hashMapOf()
val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type
@@ -289,7 +305,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->
// Get the Express or Value for the Node Template
- val propertyAssignment: Any? = propertyAssignments[nodeTypePropertyName]
+ val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName]
var resolvedValue: JsonNode = NullNode.getInstance()
if (propertyAssignment != null) {
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
index 36c141f5..17380fc0 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -47,7 +47,7 @@ If Property Assignment is Expression.
*/
fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String,
- assignment: Any): JsonNode {
+ assignment: JsonNode): JsonNode {
val valueNode: JsonNode
log.trace("Assignment ({})", assignment)
val expressionData = BluePrintExpressionService.getExpressionData(assignment)
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 18896f51..5a10e43f 100755
--- 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
@@ -33,12 +33,6 @@ import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
-import java.text.MessageFormat
-import java.time.Instant
-import java.time.temporal.ChronoUnit
-import java.time.ZoneId
-import java.time.format.DateTimeFormatter
-
class BluePrintFileUtils {
@@ -56,8 +50,9 @@ class BluePrintFileUtils {
val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR))
Files.createDirectories(metaDataDir.toPath())
- val metafile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE))
- Files.write(metafile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW)
+ val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants
+ .TOSCA_METADATA_ENTRY_DEFINITION_FILE))
+ Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW)
val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR))
Files.createDirectories(definitionsDir.toPath())
@@ -92,35 +87,6 @@ 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
@@ -147,6 +113,11 @@ class BluePrintFileUtils {
writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
}
+ blueprintContext.serviceTemplate.relationshipTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent)
+ }
+
blueprintContext.serviceTemplate.artifactTypes?.let {
val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true)
writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
@@ -163,7 +134,40 @@ class BluePrintFileUtils {
}
}
- fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) {
+ private fun populateDefaultImports(blueprintContext: BluePrintContext) {
+ // Get the Default Types
+ val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_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)
+ }
+ }
+
+ /**
+ * Re Generate the Blueprint Service Template Definition file based on BluePrint Context.
+ */
+ private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) {
val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition)
@@ -174,14 +178,15 @@ class BluePrintFileUtils {
writeServiceTemplate.dataTypes = null
writeServiceTemplate.artifactTypes = null
writeServiceTemplate.policyTypes = null
+ writeServiceTemplate.relationshipTypes = null
writeServiceTemplate.nodeTypes = null
- // Write the Serivice Template
+ // Write the Service Template
writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true))
}
- fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking {
- val definitionFile = File(definitionFile)
+ fun writeDefinitionFile(definitionFileName: String, content: String) = runBlocking {
+ val definitionFile = File(definitionFileName)
// Delete the File If exists
Files.deleteIfExists(definitionFile.toPath())
@@ -207,22 +212,6 @@ class BluePrintFileUtils {
"\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
"\nTemplate-Tags: <TAGS>"
}
-
- fun getBluePrintFile(fileName: String, targetPath: Path) : File {
- val filePath = targetPath.resolve(fileName).toString()
- val file = File(filePath)
- check(file.exists()) {
- throw BluePrintException("couldn't get definition file under path(${file.absolutePath})")
- }
- return file
- }
-
- fun getCBAGeneratedFileName(fileName: String, prefix: String): String {
- val DATE_FORMAT = "yyyyMMddHHmmss"
- val formatter = DateTimeFormatter.ofPattern(DATE_FORMAT)
- val datePrefix = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter)
- return MessageFormat.format(prefix, datePrefix, fileName)
- }
fun getCbaStorageDirectory(path: String): Path {
check(StringUtils.isNotBlank(path)) {
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 7ecf44b6..1dfb89a5 100644
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -56,6 +56,18 @@ class BluePrintRuntimeServiceTest {
}
@Test
+ fun testResolveNodeTemplateCapabilityProperties() {
+ log.info("************************ testResolveNodeTemplateRequirementProperties **********************")
+ //TODO
+ }
+
+ @Test
+ fun testResolveNodeTemplateRequirementProperties() {
+ log.info("************************ testResolveNodeTemplateRequirementProperties **********************")
+ //TODO
+ }
+
+ @Test
fun testResolveNodeTemplateInterfaceOperationInputs() {
log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************")
@@ -72,7 +84,7 @@ class BluePrintRuntimeServiceTest {
assertNotNull(inContext, "Failed to populate interface input property values")
assertEquals(inContext["action-name"], jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name")
assertEquals(inContext["request-id"], jsonNodeFromObject("12345"), "Failed to populate parameter action-name")
- }
+ }
@Test
fun testResolveNodeTemplateInterfaceOperationOutputs() {
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index 7d3a17a6..a3bf546d 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -12,6 +12,9 @@
"file": "Definitions/data_types.json"
},
{
+ "file": "Definitions/relationship_types.json"
+ },
+ {
"file": "Definitions/artifact_types.json"
},
{
@@ -205,6 +208,57 @@
"file": "Scripts/SamplePythonComponentNode.py"
}
}
+ },
+ "activate-netconf": {
+ "type": "component-netconf-executor",
+ "interfaces": {
+ "NetconfExecutorComponent": {
+ "operations": {
+ "process": {
+ "implementation": {
+ "primary": "component-script"
+ },
+ "inputs": {
+ "instance-dependencies": [
+ "json-parser-service",
+ "netconf-rpc-service"
+ ]
+ },
+ "outputs": {
+ "response-data": "",
+ "status": ""
+ }
+ }
+ }
+ }
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "sample-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ },
+ "artifacts": {
+ "component-script": {
+ "type": "artifact-script-jython",
+ "file": "Scripts/SamplePythonComponentNode.py"
+ }
+ }
+ },
+ "sample-netconf-device": {
+ "type": "vnf-netconf-device",
+ "capabilities": {
+ "netconf": {
+ "properties": {
+ "login-key": "sample-key",
+ "login-account": "sample-account",
+ "target-ip-address": "localhost",
+ "port-number": 830,
+ "connection-time-out": 30
+ }
+ }
+ }
}
},
"workflows": {
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 6a156ff1..f7970bfb 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
@@ -29,11 +29,68 @@
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
+ "tosca.nodes.ResourceSource" : {
+ "description" : "TOSCA base type for Resource Sources",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Vnf" : {
+ "description" : "This is VNF Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"tosca.nodes.component.Jython": {
"description": "This is Resource Assignment Jython Component API",
"version": "1.0.0",
"derived_from": "tosca.nodes.Root"
},
+ "component-netconf-executor": {
+ "description": "This is Netconf Transaction Configuration Component API",
+ "version": "1.0.0",
+ "capabilities": {
+ "component-node": {
+ "type": "tosca.capabilities.Node"
+ }
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "vnf-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces": {
+ "NetconfExecutorComponent": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "instance-dependencies": {
+ "description": "Instance Names to Inject to Jython Script.",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "outputs": {
+ "response-data": {
+ "description": "Execution Response Data in JSON format.",
+ "required": false,
+ "type": "string"
+ },
+ "status": {
+ "description": "Status of the Component Execution ( success or failure )",
+ "required": true,
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.component.Jython"
+ },
"component-resource-assignment": {
"description": "This is Resource Assignment Component API",
"version": "1.0.0",
@@ -131,6 +188,47 @@
}
},
"derived_from": "tosca.nodes.component.Jython"
+ },
+ "vnf-netconf-device": {
+ "description": "This is VNF Device with Netconf Capability",
+ "version": "1.0.0",
+ "capabilities": {
+ "netconf": {
+ "type": "tosca.capabilities.Netconf",
+ "properties": {
+ "login-key": {
+ "required": true,
+ "type": "string",
+ "default": "sdnc"
+ },
+ "login-account": {
+ "required": true,
+ "type": "string",
+ "default": "sdnc-tacacs"
+ },
+ "source": {
+ "required": true,
+ "type": "string",
+ "default": "npm"
+ },
+ "target-ip-address": {
+ "required": true,
+ "type": "string"
+ },
+ "port-number": {
+ "required": true,
+ "type": "integer",
+ "default": 830
+ },
+ "connection-time-out": {
+ "required": false,
+ "type": "integer",
+ "default": 30
+ }
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.Vnf"
}
}
} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json
new file mode 100644
index 00000000..87d2dc58
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/relationship_types.json
@@ -0,0 +1,9 @@
+{
+ "relationship_types": {
+ "tosca.relationships.ConnectsTo": {
+ "description": "Relationship tosca.relationships.ConnectsTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
index 7e1d8134..b8ac762e 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-netconf-executor.json
@@ -18,45 +18,13 @@
"operations": {
"process": {
"inputs": {
- "request-id": {
- "description": "Request Id used to store the generated configuration, in the database along with the template-name",
+ "instance-dependencies": {
"required": true,
- "type": "string"
- },
- "template-name": {
- "description": "Service Template Name",
- "required": true,
- "type": "string"
- },
- "template-version": {
- "description": "Service Template Version",
- "required": true,
- "type": "string"
- },
- "action-name": {
- "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- },
- "resource-type": {
- "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- },
- "resource-id": {
- "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority",
- "required": false,
- "type": "string"
- },
- "reservation-id": {
- "description": "Reservation Id used to send to NPM",
- "required": false,
- "type": "string"
- },
- "execution-script": {
- "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.",
- "required": true,
- "type": "string"
+ "description": "Instance Names to Inject to Jython Script.",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
}
},
"outputs": {
diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
new file mode 100644
index 00000000..241b6995
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
@@ -0,0 +1,49 @@
+{
+ "description": "This is Component Resource Source Node Type",
+ "version": "1.0.0",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string",
+ "default": "JAVA-COMPONENT",
+ "constraints": [
+ {
+ "valid_values": [
+ "JAVA-COMPONENT",
+ "JYTHON-COMPONENT"
+ ]
+ }
+ ]
+ },
+ "instance-name": {
+ "description": "Capability component instance reference name.",
+ "required": true,
+ "type": "string"
+ },
+ "input-key-mapping": {
+ "description": "Context name to input parameters name mapping.",
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "output-key-mapping": {
+ "description": "Context name to output parameters name mapping.",
+ "required": false,
+ "type": "map",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "key-dependencies": {
+ "description": "Resource Resolution dependency dictionary names.",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ }
+ },
+ "derived_from": "tosca.nodes.ResourceSource"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
index 246f1770..c6f512df 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/vnf-netconf-device.json
@@ -38,5 +38,4 @@
}
},
"derived_from": "tosca.nodes.Vnf"
-
}
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json
new file mode 100644
index 00000000..bcfb65ee
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.AttachesTo.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.AttachesTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json
new file mode 100644
index 00000000..4abb9483
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.ConnectsTo.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.ConnectsTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json
new file mode 100644
index 00000000..89987ff5
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.DependsOn.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.DependsOn",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json
new file mode 100644
index 00000000..a8337cd1
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.HostedOn.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.HostedOn",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json
new file mode 100644
index 00000000..1da73cde
--- /dev/null
+++ b/components/model-catalog/definition-type/starter-type/relationship_type/tosca.relationships.RoutesTo.json
@@ -0,0 +1,5 @@
+{
+ "description": "Relationship tosca.relationships.RoutesTo",
+ "version": "1.0.0",
+ "derived_from": "tosca.relationships.Root"
+} \ 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/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 0becc00c..53a2153a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -21,9 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
-import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
@@ -31,9 +29,6 @@ import org.springframework.stereotype.Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {
- @Autowired
- private lateinit var applicationContext: ApplicationContext
-
override fun process(executionRequest: ExecutionServiceInput) {
val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
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 16db9c96..5a7161da 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
@@ -17,7 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
new file mode 100644
index 00000000..b141025d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -0,0 +1,59 @@
+/*
+ * 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.blueprintsprocessor.functions.resource.resolution
+
+open class ResourceSourceProperties {
+
+}
+
+open class InputResourceSource : ResourceSourceProperties() {
+ lateinit var key: String
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class DefaultResourceSource : ResourceSourceProperties() {
+ lateinit var key: String
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class DatabaseResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var query: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class RestResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var urlPath: String
+ lateinit var path: String
+ lateinit var expressionType: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+}
+
+open class CapabilityResourceSource : ResourceSourceProperties() {
+ lateinit var type: String
+ lateinit var instanceName: String
+ lateinit var path: String
+ lateinit var expressionType: String
+ var inputKeyMapping: MutableList<String>? = null
+ var outputKeyMapping: MutableList<String>? = null
+ lateinit var keyDependencies: MutableList<String>
+} \ 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/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..f1de8f7d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
@@ -0,0 +1,84 @@
+/*
+ * 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.blueprintsprocessor.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceResolutionUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service("resource-assignment-processor-capability")
+open class CapabilityResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ companion object {
+ const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
+ const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
+ }
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
+
+ override fun getName(): String {
+ return "resource-assignment-processor-capability"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+
+ val resourceDefinition = resourceDictionaries[executionRequest.dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ${executionRequest.dictionaryName}")
+
+ val resourceSource = resourceDefinition.sources[executionRequest.dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition ${executionRequest.dictionaryName} source(${executionRequest.dictionarySource})")
+
+ checkNotNull(resourceSource.properties) { "failed to get ${executionRequest.dictionarySource} properties" }
+
+ val capabilityResourceSourceProperty = ResourceResolutionUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java)
+
+ val instanceType = capabilityResourceSourceProperty.type
+ val instanceName = capabilityResourceSourceProperty.instanceName
+
+
+ var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
+
+ when (instanceType) {
+ CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ // Initialize Capability Resource Assignment Processor
+ componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ }
+ CAPABILITY_TYPE_JYTHON_COMPONENT -> {
+ TODO(" No implementation")
+ }
+ }
+
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+
+ // Assign Current Blueprint runtime and ResourceDictionaries
+ componentResourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentResourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+
+ // Invoke componentResourceAssignmentProcessor
+ componentResourceAssignmentProcessor.apply(executionRequest)
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+
+ TODO("To Implement")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt
index 12120341..da77c273 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DataBaseResourceAssignmentProcessor.kt
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
index 58c9e1d8..1c5455fd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -1,40 +1,40 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.blueprintsprocessor.functions.resource.resolutionprocessor
-
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.springframework.stereotype.Service
-
-/**
- * DefaultResourceAssignmentProcessor
- *
- * @author Brinda Santh
- */
-@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
-
- override fun getName(): String {
- return "resource-assignment-processor-default"
- }
-
- override fun process(executionRequest: ResourceAssignment) {
- }
-
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
- }
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.blueprintsprocessor.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+/**
+ * DefaultResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-default")
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ override fun getName(): String {
+ return "resource-assignment-processor-default"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
index 10332484..9d476008 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -1,40 +1,40 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.blueprintsprocessor.functions.resource.resolutionprocessor
-
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.springframework.stereotype.Service
-
-/**
- * InputResourceAssignmentProcessor
- *
- * @author Brinda Santh
- */
-@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
-
- override fun getName(): String {
- return "resource-assignment-processor-input"
- }
-
- override fun process(executionRequest: ResourceAssignment) {
- }
-
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
- }
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.blueprintsprocessor.functions.resource.resolution.processor
+
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+/**
+ * InputResourceAssignmentProcessor
+ *
+ * @author Brinda Santh
+ */
+@Service("resource-assignment-processor-input")
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ override fun getName(): String {
+ return "resource-assignment-processor-input"
+ }
+
+ override fun process(executionRequest: ResourceAssignment) {
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index a55e615e..11cd3faa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
@@ -28,9 +28,9 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
- var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
+ lateinit var resourceDictionaries: Map<String, ResourceDefinition>
open fun resourceDefinition(name: String): ResourceDefinition {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
index c6732627..e05261d8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
new file mode 100644
index 00000000..6bcd21ba
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceResolutionUtils.kt
@@ -0,0 +1,32 @@
+/*
+ * 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.blueprintsprocessor.functions.resource.resolution.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+
+class ResourceResolutionUtils {
+ companion object {
+
+ fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
+ val content = JacksonUtils.getJson(properties)
+ return JacksonUtils.readValue(content, classType)
+ ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index 57217d0d..ef849605 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -21,10 +21,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
@@ -37,7 +34,8 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class,
InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
+ CapabilityResourceAssignmentProcessor::class])
class ResourceResolutionComponentTest {
@Autowired
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index df560076..7f41ba12 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -19,10 +19,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
@@ -39,7 +36,8 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionService::class,
InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
+ CapabilityResourceAssignmentProcessor::class])
class ResourceResolutionServiceTest {
private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
index 46d85307..e574778e 100755
--- a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
+++ b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties
@@ -49,7 +49,7 @@ spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
# Load Resource Source Mappings
-resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
+resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability
# Controller Blueprints Core Configuration
controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy
controllerblueprints.blueprintArchivePath=/etc/blueprints/archive
diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
index d618e015..91792394 100755
--- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties
+++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties
@@ -51,7 +51,7 @@ spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
# Load Resource Source Mappings
-resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
+resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability
# Controller Blueprints Core Configuration
controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy
diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties
index 9c8a96cb..1fafd8bc 100755
--- a/ms/controllerblueprints/application/src/test/resources/application.properties
+++ b/ms/controllerblueprints/application/src/test/resources/application.properties
@@ -33,7 +33,7 @@ swagger.contact.url=www.onap.com
swagger.contact.email=brindasanth@onap.com
# Load Resource Source Mappings
-resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
+resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability
# Controller Blueprints Core Configuration
controllerblueprints.blueprintDeployPath=./target/blueprints/deploy
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
deleted file mode 100644
index 9641f897..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * 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.validator;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-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.CapabilityDefinition;
-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.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * ModelTypeValidation.java Purpose: Provide Validation Service for Model Type ModelTypeValidation
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-public class ModelTypeValidator {
-
- private ModelTypeValidator() {
-
- }
-
- private static List<String> getValidModelDefinitionType() {
- List<String> validTypes = new ArrayList<>();
- validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
- validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
- validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE);
- validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE);
- return validTypes;
- }
-
- /**
- * This is a validateModelTypeDefinition
- *
- * @param definitionType definitionType
- * @param definitionContent definitionContent
- * @return boolean
- * @throws BluePrintException BluePrintException
- */
- public static boolean validateModelTypeDefinition(String definitionType, JsonNode definitionContent)
- throws BluePrintException {
- if (definitionContent != null) {
- if (BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType)) {
- DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
- if (dataType == null) {
- throw new BluePrintException(
- "Model type definition is not DataType valid content " + definitionContent);
- }
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE.equalsIgnoreCase(definitionType)) {
- NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
- if (nodeType == null) {
- throw new BluePrintException(
- "Model type definition is not NodeType valid content " + definitionContent);
- }
- } else if (BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE.equalsIgnoreCase(definitionType)) {
- ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
- if (artifactType == null) {
- throw new BluePrintException(
- "Model type definition is not ArtifactType valid content " + definitionContent);
- }
- }else if (BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE.equalsIgnoreCase(definitionType)) {
- CapabilityDefinition capabilityDefinition =
- JacksonUtils.readValue(definitionContent, CapabilityDefinition.class);
- if (capabilityDefinition == null) {
- throw new BluePrintException(
- "Model type definition is not CapabilityDefinition valid content " + definitionContent);
- }
- }
-
- }
- return true;
- }
-
- /**
- * This is a validateModelType method
- *
- * @param modelType modelType
- * @return boolean
- * @throws BluePrintException BluePrintException
- */
- public static boolean validateModelType(ModelType modelType) throws BluePrintException {
- if (modelType != null) {
-
- if (StringUtils.isBlank(modelType.getModelName())) {
- throw new BluePrintException("Model Name Information is missing.");
- }
-
- if (StringUtils.isBlank(modelType.getDefinitionType())) {
- throw new BluePrintException("Model Root Type Information is missing.");
- }
- if (StringUtils.isBlank(modelType.getDerivedFrom())) {
- throw new BluePrintException("Model Type Information is missing.");
- }
-
- if (modelType.getDefinition() == null) {
- throw new BluePrintException("Model Definition Information is missing.");
- }
- if (StringUtils.isBlank(modelType.getDescription())) {
- throw new BluePrintException("Model Description Information is missing.");
- }
-
- if (StringUtils.isBlank(modelType.getVersion())) {
- throw new BluePrintException("Model Version Information is missing.");
- }
-
- if (StringUtils.isBlank(modelType.getUpdatedBy())) {
- throw new BluePrintException("Model Updated By Information is missing.");
- }
-
- List<String> validRootTypes = getValidModelDefinitionType();
- if (!validRootTypes.contains(modelType.getDefinitionType())) {
- throw new BluePrintException("Not Valid Model Root Type(" + modelType.getDefinitionType()
- + "), It should be " + validRootTypes);
- }
-
- validateModelTypeDefinition(modelType.getDefinitionType(), modelType.getDefinition());
-
- } else {
- throw new BluePrintException("Model Type Information is missing.");
- }
-
- return true;
-
- }
-
-}
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 d7895957..d4e4a24c 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
@@ -21,7 +21,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.interfaces.BluePrintEnhancerService
-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
@@ -31,8 +30,7 @@ import org.springframework.stereotype.Service
import java.util.*
@Service
-open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
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 4e226b2e..6ff0b39b 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,6 +18,7 @@ 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
@@ -57,7 +58,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
// NodeType Attribute Definitions
- enrichNodeTypeAtributes(name, nodeType)
+ enrichNodeTypeAttributes(name, nodeType)
// NodeType Property Definitions
enrichNodeTypeProperties(name, nodeType)
@@ -73,7 +74,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
- open fun enrichNodeTypeAtributes(nodeTypeName: String, nodeType: NodeType) {
+ open fun enrichNodeTypeAttributes(nodeTypeName: String, nodeType: NodeType) {
nodeType.attributes?.let {
bluePrintTypeEnhancerService.enhanceAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
}
@@ -87,14 +88,20 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
- nodeType.requirements?.forEach { _, requirementDefinition ->
+ nodeType.requirements?.forEach { requirementName, requirementDefinition ->
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext,
bluePrintRepoService, requirementNodeTypeName)
- // Enhanypece Node T
+ // Enhance Node Type
enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
+
+ // Enhance Relationship Type
+ val relationShipTypeName = requirementDefinition.relationship
+ ?: throw BluePrintException("couldn't get relationship name for the NodeType($nodeTypeName) " +
+ "Requirement($requirementName)")
+ enrichRelationShipType(relationShipTypeName)
}
}
}
@@ -120,7 +127,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
interfaceObj.operations?.forEach { operationName, operation ->
enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)
- enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)
+ enrichNodeTypeInterfaceOperationOutputs(nodeTypeName, operationName, operation)
}
}
@@ -130,10 +137,18 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
- open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ open fun enrichNodeTypeInterfaceOperationOutputs(nodeTypeName: String, operationName: String,
+ operation: OperationDefinition) {
operation.outputs?.let { inputs ->
bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
+ /**
+ * Get the Relationship Type from database and add to Blueprint Context
+ */
+ open fun enrichRelationShipType(relationshipName: String) {
+ BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, relationshipName)
+ }
+
} \ 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 51064bb4..8c269e54 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
@@ -19,7 +19,6 @@ 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.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
@@ -30,8 +29,7 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintServiceTemplateEnhancer {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString())
@@ -52,11 +50,14 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService
bluePrintContext.serviceTemplate.nodeTypes?.clear()
bluePrintContext.serviceTemplate.dataTypes?.clear()
bluePrintContext.serviceTemplate.policyTypes?.clear()
+ bluePrintContext.serviceTemplate.relationshipTypes?.clear()
bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf()
+ log.info("reinitialized all type definitions")
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
index 8b6e54af..8144a1e7 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.service.load
import com.att.eelf.configuration.EELFManager
+import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.event.EventListener
@@ -49,7 +50,9 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
if (bluePrintLoadConfiguration.loadModelType) {
val paths = bluePrintLoadConfiguration.loadModeTypePaths?.split(",")
paths?.let {
- modelTypeLoadService.loadPathsModelType(paths)
+ runBlocking {
+ modelTypeLoadService.loadPathsModelType(paths)
+ }
}
}
}
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 51bbca7d..061ef88e 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
@@ -21,9 +21,8 @@ import kotlinx.coroutines.*
import org.apache.commons.io.FilenameUtils
import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-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.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler
@@ -37,11 +36,14 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java)
private val updateBySystem = "System"
- open fun loadPathsModelType(modelTypePaths: List<String>) {
- modelTypePaths.forEach { loadPathModelType(it) }
+ open suspend fun loadPathsModelType(modelTypePaths: List<String>) {
+ modelTypePaths.forEach { runBlocking { loadPathModelType(it) } }
}
- open fun loadPathModelType(modelTypePath: String) = runBlocking {
+ /**
+ * Load the Model Type file content from the defined path, Load of sequencing should be maintained.
+ */
+ open suspend fun loadPathModelType(modelTypePath: String) = runBlocking {
log.info(" *************************** loadModelType **********************")
try {
val errorBuilder = StrBuilder()
@@ -51,17 +53,35 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
val deferredResults = mutableListOf<Deferred<Unit>>()
- for (file in dataTypeFiles) deferredResults += async { loadDataType(file, errorBuilder) }
+ for (file in dataTypeFiles) deferredResults += async {
+ loadModelType(file, DataType::class.java, errorBuilder)
+ }
deferredResults.awaitAll()
}
coroutineScope {
- val artifactTypefiles = File("$modelTypePath/artifact_type").listFiles()
+ val artifactTypeFiles = File("$modelTypePath/artifact_type").listFiles()
val deferredResults = mutableListOf<Deferred<Unit>>()
- for (file in artifactTypefiles) deferredResults += async { loadArtifactType(file, errorBuilder) }
+ for (file in artifactTypeFiles) deferredResults += async {
+ loadModelType(file,
+ ArtifactType::class.java, errorBuilder)
+ }
+
+ deferredResults.awaitAll()
+ }
+
+ coroutineScope {
+ val relationshipTypeFiles = File("$modelTypePath/relationship_type").listFiles()
+
+ val deferredResults = mutableListOf<Deferred<Unit>>()
+
+ for (file in relationshipTypeFiles) deferredResults += async {
+ loadModelType(file,
+ RelationshipType::class.java, errorBuilder)
+ }
deferredResults.awaitAll()
}
@@ -71,7 +91,10 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
val deferredResults = mutableListOf<Deferred<Unit>>()
- for (file in nodeTypeFiles) deferredResults += async { loadNodeType(file, errorBuilder) }
+ for (file in nodeTypeFiles) deferredResults += async {
+ loadModelType(file,
+ NodeType::class.java, errorBuilder)
+ }
deferredResults.awaitAll()
}
@@ -83,76 +106,45 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
}
}
- private fun loadDataType(file: File, errorBuilder: StrBuilder) {
- try {
- log.trace("Loading DataType(${file.name}")
- val dataKey = FilenameUtils.getBaseName(file.name)
- val definitionContent = file.readText(Charset.defaultCharset())
- val dataType = JacksonUtils.readValue(definitionContent, DataType::class.java)
- checkNotNull(dataType) { "failed to get data type from file : ${file.name}" }
-
- val modelType = ModelType()
- modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
- modelType.derivedFrom = dataType.derivedFrom
- modelType.description = dataType.description
- modelType.definition = JacksonUtils.jsonNode(definitionContent)
- modelType.modelName = dataKey
- modelType.version = dataType.version
- modelType.updatedBy = updateBySystem
- modelType.tags = (dataKey + "," + dataType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
- modelTypeHandler.saveModel(modelType)
- log.trace("DataType(${file.name}) loaded successfully ")
- } catch (e: Exception) {
- errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}")
- }
- }
-
- private fun loadArtifactType(file: File, errorBuilder: StrBuilder) {
+ private inline fun <reified T> loadModelType(file: File, classType: Class<T>, errorBuilder: StrBuilder) {
try {
- log.trace("Loading ArtifactType(${file.name}")
+ log.trace("Loading ${classType.name} (${file.name})")
val dataKey = FilenameUtils.getBaseName(file.name)
val definitionContent = file.readText(Charset.defaultCharset())
- val artifactType = JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
- checkNotNull(artifactType) { "failed to get artifact type from file : ${file.name}" }
+ val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType
+ //checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
val modelType = ModelType()
- modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE
- modelType.derivedFrom = artifactType.derivedFrom
- modelType.description = artifactType.description
+ val definitionType: String?
+ when (T::class) {
+ DataType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ }
+ RelationshipType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE
+ }
+ ArtifactType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE
+ }
+ NodeType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE
+ }
+ else -> {
+ throw BluePrintException("couldn't process model type($classType) definition")
+ }
+ }
+ modelType.definitionType = definitionType
+ modelType.derivedFrom = definition.derivedFrom
+ modelType.description = definition.description
modelType.definition = JacksonUtils.jsonNode(definitionContent)
modelType.modelName = dataKey
- modelType.version = artifactType.version
+ modelType.version = definition.version
modelType.updatedBy = updateBySystem
- modelType.tags = (dataKey + "," + artifactType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
+ modelType.tags = (dataKey + "," + definition.derivedFrom + "," + definitionType)
modelTypeHandler.saveModel(modelType)
- log.trace("ArtifactType(${file.name}) loaded successfully ")
+ log.trace("${classType.name}(${file.name}) loaded successfully ")
} catch (e: Exception) {
- errorBuilder.appendln("Couldn't load ArtifactType(${file.name}: ${e.message}")
+ errorBuilder.appendln("Couldn't load ${classType.name}(${file.name}: ${e.message}")
}
}
-
- private fun loadNodeType(file: File, errorBuilder: StrBuilder) {
- try {
- log.trace("Loading NodeType(${file.name}")
- val nodeKey = FilenameUtils.getBaseName(file.name)
- val definitionContent = file.readText(Charset.defaultCharset())
- val nodeType = JacksonUtils.readValue(definitionContent, NodeType::class.java)
- checkNotNull(nodeType) { "failed to get node type from file : ${file.name}" }
-
- val modelType = ModelType()
- modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE
- modelType.derivedFrom = nodeType.derivedFrom
- modelType.description = nodeType.description
- modelType.definition = JacksonUtils.jsonNode(definitionContent)
- modelType.modelName = nodeKey
- modelType.version = nodeType.version
- modelType.updatedBy = updateBySystem
- modelType.tags = (nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + nodeType.derivedFrom)
- modelTypeHandler.saveModel(modelType)
- log.trace("NodeType(${file.name}) loaded successfully ")
- } catch (e: Exception) {
- errorBuilder.appendln("Couldn't load NodeType(${file.name}: ${e.message}")
- }
- }
-
} \ No newline at end of file
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
index 2f18abfd..c2d6f6aa 100644
--- 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
@@ -21,7 +21,7 @@ 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.data.RelationshipType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.springframework.http.codec.multipart.FilePart
@@ -45,13 +45,23 @@ class BluePrintEnhancerUtils {
return dataType
}
+ fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ relationshipName: String): RelationshipType {
+
+ val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName)
+ ?: bluePrintRepoService.getRelationshipType(relationshipName)
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.")
+ bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType)
+ return relationshipType
+ }
+
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))
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.")
bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt
new file mode 100644
index 00000000..1428c81d
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidator.kt
@@ -0,0 +1,83 @@
+/*
+ * 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.validator
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.data.*
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+
+class ModelTypeValidator {
+ companion object {
+ /**
+ * This is a validateModelTypeDefinition
+ *
+ * @param definitionType definitionType
+ * @param definitionContent definitionContent
+ * @return boolean
+ */
+ fun validateModelTypeDefinition(definitionType: String, definitionContent: JsonNode): Boolean {
+
+ when (definitionType) {
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> {
+ JacksonUtils.readValue(definitionContent, DataType::class.java)
+ ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> {
+ JacksonUtils.readValue(definitionContent, NodeType::class.java)
+ ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> {
+ JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
+ ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> {
+ JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java)
+ ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> {
+ JacksonUtils.readValue(definitionContent, RelationshipType::class.java)
+ ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent")
+ }
+ }
+ return true
+ }
+
+ /**
+ * This is a validateModelType method
+ *
+ * @param modelType modelType
+ * @return boolean
+ */
+ fun validateModelType(modelType: ModelType?): Boolean {
+ checkNotNull(modelType) { "Model Type Information is missing." }
+
+ val validRootTypes = BluePrintTypes.validModelTypes()
+
+ check(validRootTypes.contains(modelType.definitionType)) {
+ "Not Valid Model Root Type(${modelType.definitionType}), It should be $validRootTypes"
+ }
+
+ validateModelTypeDefinition(modelType.definitionType, modelType.definition)
+ return true
+ }
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
deleted file mode 100644
index 23e5294f..00000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java
+++ /dev/null
@@ -1,73 +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.enhancer;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService;
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext;
-import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService;
-import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.nio.file.Paths;
-
-@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = {TestApplication.class})
-@TestPropertySource(locations = {"classpath:application.properties"})
-public class BluePrintEnhancerServiceImplTest {
-
- @Autowired
- private ModelTypeLoadService modelTypeLoadService;
-
- @Autowired
- private ResourceDictionaryLoadService resourceDictionaryLoadService;
-
- @Autowired
- private BluePrintEnhancerService bluePrintEnhancerService;
-
- @Autowired
- private BluePrintValidatorService bluePrintValidatorService;
-
- @Before
- public void init() {
- modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type");
- resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary");
- }
-
- @Test
- public void testEnhancementAndValidation() throws Exception {
-
- String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
-
- String targetPath = Paths.get("target", "bp-enhance").toUri().getPath();
-
- BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath);
- Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext);
-
- // Validate the Generated BluePrints
- Boolean valid = bluePrintValidatorService.validateBluePrints(targetPath);
- Assert.assertTrue("blueprint validation failed ", valid);
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java
deleted file mode 100644
index 16b2bc81..00000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2018 IBM.
- *
- * 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.validator;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-
-public class ModelTypeValidatorTest {
-
- @Before
- public void setup(){
- ModelTypeValidator modelTypeValidator;
- }
-
- @Test
- public void testGetValidModelDefinitionType_definitionContentNULL() throws Exception{
- String definitionType=null;
- JsonNode definitionContent=null;
- boolean valid= ModelTypeValidator.validateModelTypeDefinition(definitionType, definitionContent);
- Assert.assertTrue(valid);
-
- }
-
- @Test(expected=BluePrintException.class)
- public void testvalidateModelType() throws Exception{
- ModelType modelType = new ModelType();
- modelType.setDefinitionType("");
- modelType.setDerivedFrom("");
- modelType.setDescription("");
- JsonNode definitionContent=null;
- modelType.setDefinition(definitionContent);
- modelType.setModelName("");
- modelType.setVersion("");
- modelType.setTags("");
- modelType.setUpdatedBy("");
- ModelTypeValidator.validateModelType(modelType);
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
new file mode 100644
index 00000000..4ab67084
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
@@ -0,0 +1,75 @@
+/*
+ * 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.enhancer
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService
+import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import java.nio.file.Paths
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = arrayOf(TestApplication::class))
+@TestPropertySource(locations = arrayOf("classpath:application.properties"))
+class BluePrintEnhancerServiceImplTest {
+
+ @Autowired
+ private val modelTypeLoadService: ModelTypeLoadService? = null
+
+ @Autowired
+ private val resourceDictionaryLoadService: ResourceDictionaryLoadService? = null
+
+ @Autowired
+ private val bluePrintEnhancerService: BluePrintEnhancerService? = null
+
+ @Autowired
+ private val bluePrintValidatorService: BluePrintValidatorService? = null
+
+ @Before
+ fun init() {
+ runBlocking {
+ modelTypeLoadService!!.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
+ resourceDictionaryLoadService!!.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
+ }
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testEnhancementAndValidation() {
+
+ val basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+
+ val targetPath = Paths.get("target", "bp-enhance").toUri().path
+
+ val bluePrintContext = bluePrintEnhancerService!!.enhance(basePath, targetPath)
+ Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
+
+ // Validate the Generated BluePrints
+ val valid = bluePrintValidatorService!!.validateBluePrints(targetPath)
+ Assert.assertTrue("blueprint validation failed ", valid)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt
new file mode 100644
index 00000000..db4ee5c9
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/ModelTypeValidatorTest.kt
@@ -0,0 +1,40 @@
+/*
+ * 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.validator
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType
+
+class ModelTypeValidatorTest {
+
+ @Test(expected = IllegalStateException::class)
+ @Throws(Exception::class)
+ fun testvalidateModelType() {
+ val modelType = ModelType()
+ modelType.definitionType = ""
+ modelType.derivedFrom = ""
+ modelType.description = ""
+ val definitionContent: JsonNode? = null
+ modelType.definition = definitionContent
+ modelType.modelName = ""
+ modelType.version = ""
+ modelType.tags = ""
+ modelType.updatedBy = ""
+ ModelTypeValidator.validateModelType(modelType)
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index 4e1bedf2..29bb2b90 100755
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -20,7 +20,7 @@ logging.level.org.springframework.web=INFO
logging.level.org.hibernate.SQL=warn
logging.level.org.hibernate.type.descriptor.sql=debug
# Load Resource Source Mappings
-resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest
+resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability
# Controller Blueprints Core Configuration
controllerblueprints.blueprintDeployPath=./target/blueprints/deploy
controllerblueprints.blueprintArchivePath=./target/blueprints/archive