aboutsummaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-13 11:34:49 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-12-13 11:34:49 -0500
commit2294f097df4a787eaa609cdeab24a6bc6d3b19ee (patch)
tree05ddc8d91a79bf9ff8c8d0f0c947786bf0dd5a3e /components/core
parent478a8a7a321556ed01ec757cde3c827ef10690c0 (diff)
Implement Blueprint Workflow Enhancement
Change-Id: I64d6e949e9a4bc2100b49fedb3781b04c1c03f43 Issue-ID: CCSDK-722 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'components/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt1
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt51
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt23
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt32
4 files changed, 66 insertions, 41 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 167496ebc..fd6a8db10 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
@@ -55,6 +55,7 @@ object BluePrintConstants {
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_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/interfaces/BluePrintEnhancer.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
index cb835d736..f6659e7db 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
@@ -16,13 +16,13 @@
package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
interface BluePrintEnhancer<T> {
- fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: T)
+ fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T)
}
interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer<ServiceTemplate>
@@ -49,9 +49,6 @@ interface BluePrintEnhancerService {
@Throws(BluePrintException::class)
fun enhance(basePath: String): BluePrintContext
-
- @Throws(BluePrintException::class)
- fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
}
interface BluePrintTypeEnhancerService {
@@ -72,63 +69,63 @@ interface BluePrintTypeEnhancerService {
fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer>
- fun enhanceServiceTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, serviceTemplate: ServiceTemplate) {
+ fun enhanceServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) {
val enhancers = getServiceTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, serviceTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, serviceTemplate, enhancers)
}
- fun enhanceTopologyTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, topologyTemplate: TopologyTemplate) {
+ fun enhanceTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) {
val enhancers = getTopologyTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, topologyTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers)
}
- fun enhanceWorkflow(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
val enhancers = getWorkflowEnhancers()
- doEnhancement(bluePrintContext, error, name, workflow, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, workflow, enhancers)
}
- fun enhanceNodeTemplate(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+ fun enhanceNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
val enhancers = getNodeTemplateEnhancers()
- doEnhancement(bluePrintContext, error, name, nodeTemplate, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers)
}
- fun enhanceNodeType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
+ fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
val enhancers = getNodeTypeEnhancers()
- doEnhancement(bluePrintContext, error, name, nodeType, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers)
}
- fun enhancePolicyType(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, policyType: PolicyType) {
+ fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) {
val enhancers = getPolicyTypeEnhancers()
- doEnhancement(bluePrintContext, error, name, policyType, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, policyType, enhancers)
}
- fun enhancePropertyDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, properties: MutableMap<String, PropertyDefinition>) {
+ fun enhancePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap<String, PropertyDefinition>) {
properties.forEach { propertyName, propertyDefinition ->
- enhancePropertyDefinition(bluePrintContext, error, propertyName, propertyDefinition)
+ enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition)
}
}
- fun enhancePropertyDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
+ fun enhancePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
val enhancers = getPropertyDefinitionEnhancers()
- doEnhancement(bluePrintContext, error, name, propertyDefinition, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, propertyDefinition, enhancers)
}
- fun enhanceAttributeDefinitions(bluePrintContext: BluePrintContext, error: BluePrintError, attributes: MutableMap<String, AttributeDefinition>) {
+ fun enhanceAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap<String, AttributeDefinition>) {
attributes.forEach { attributeName, attributeDefinition ->
- enhanceAttributeDefinition(bluePrintContext, error, attributeName, attributeDefinition)
+ enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition)
}
}
- fun enhanceAttributeDefinition(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, attributeDefinition: AttributeDefinition) {
+ fun enhanceAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) {
val enhancers = getAttributeDefinitionEnhancers()
- doEnhancement(bluePrintContext, error, name, attributeDefinition, enhancers)
+ doEnhancement(bluePrintRuntimeService, name, attributeDefinition, enhancers)
}
@Suppress("UNCHECKED_CAST")
- private fun <T> doEnhancement(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
+ private fun <T> doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
if (enhancers.isNotEmpty()) {
enhancers.forEach {
- it.enhance(bluePrintContext, error, name, definition as T)
+ it.enhance(bluePrintRuntimeService, name, definition as T)
}
}
}
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 448a06a86..cf518bd14 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
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
@@ -55,6 +56,10 @@ interface BluePrintRuntimeService<T> {
fun getAsDouble(key: String): Double?
+ fun getBluePrintError(): BluePrintError
+
+ fun setBluePrintError(bluePrintError: BluePrintError)
+
/*
Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
*/
@@ -113,6 +118,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
private var store: MutableMap<String, JsonNode> = hashMapOf()
+ private var bluePrintError = BluePrintError()
+
override fun id(): String {
return id
}
@@ -162,9 +169,17 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return get(key).asDouble()
}
+ override fun getBluePrintError(): BluePrintError {
+ return this.bluePrintError
+ }
+
+ override fun setBluePrintError(bluePrintError: BluePrintError) {
+ this.bluePrintError = bluePrintError
+ }
+
/*
- Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
- */
+ Get the Node Type Definition for the Node Template, Then iterate Node Type Properties and resolve the expressing
+ */
override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode> {
log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName)
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
@@ -439,11 +454,11 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
setInputValue(propertyName, property, valueNode)
}
}
-
+ // Load Dynamic data Types
val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName)
workflowDynamicInputs?.let {
- bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property ->
+ bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property ->
val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName)
?: NullNode.getInstance()
setInputValue(propertyName, property, valueNode)
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 d9222d754..4cb247b5d 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -89,25 +89,37 @@ class BluePrintFileUtils {
throw BluePrintException("couldn't get definition file under path(${definitionDir.absolutePath})")
}
- blueprintContext.dataTypes.let {
- val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, blueprintContext.dataTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
+ blueprintContext.serviceTemplate.dataTypes?.let {
+ val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent)
+ }
+ blueprintContext.serviceTemplate.artifactTypes?.let {
+ val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
}
- blueprintContext.artifactTypes.let {
- val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, blueprintContext.artifactTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent)
+ blueprintContext.serviceTemplate.nodeTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent)
}
- blueprintContext.nodeTypes.let {
- val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, blueprintContext.nodeTypes!!, true)
- writeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent)
+ blueprintContext.serviceTemplate.policyTypes?.let {
+ val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it, true)
+ writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent)
}
+ }
+ fun writeDefinitionFile(definitionFile: String, content: String) = runBlocking {
+ val definitionFile = File(definitionFile)
+
+ Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE)
+ check(definitionFile.exists()) {
+ throw BluePrintException("couldn't write definition file under path(${definitionFile.absolutePath})")
+ }
}
- private fun writeFile(definitionPath: String, type: String, content: String) = runBlocking {
+ private fun writeTypeFile(definitionPath: String, type: String, content: String) = runBlocking {
val typeFile = File(definitionPath.plus(File.separator).plus("$type.json"))
Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW)