package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintAttributeDefinitionEnhancer {
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
\ No newline at end of file
\r
import com.att.eelf.configuration.EELFLogger\r
import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils\r
import org.springframework.stereotype.Service\r
+import java.util.*\r
\r
@Service\r
open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePrintRepoService,\r
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())\r
\r
override fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {\r
+ // Copy the Blueprint Content to Target Location\r
BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath)\r
- BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)\r
+\r
+ // Enhance the Blueprint\r
val enhancedBluePrintContext = enhance(enrichedBasePath)\r
+\r
+ // Delete the Old Type files\r
+ BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)\r
+\r
+ // Write the Type File Definitions\r
BluePrintFileUtils.writeBluePrintTypes(enhancedBluePrintContext)\r
return enhancedBluePrintContext\r
}\r
@Throws(BluePrintException::class)\r
override fun enhance(basePath: String): BluePrintContext {\r
log.info("Enhancing blueprint($basePath)")\r
- val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(basePath)\r
- val error = BluePrintError()\r
- bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",\r
- bluePrintContext.serviceTemplate)\r
- return bluePrintContext\r
- }\r
+ val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)\r
+ try {\r
\r
- @Throws(BluePrintException::class)\r
- override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {\r
- val bluePrintContext = BluePrintContext(serviceTemplate)\r
- val error = BluePrintError()\r
- bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",\r
- bluePrintContext.serviceTemplate)\r
- return bluePrintContext.serviceTemplate\r
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",\r
+ blueprintRuntimeService.bluePrintContext().serviceTemplate)\r
+\r
+ if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) {\r
+ throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString())\r
+ }\r
+ } catch (e: Exception) {\r
+ log.error("failed in blueprint enhancement", e)\r
+ }\r
+\r
+ return blueprintRuntimeService.bluePrintContext()\r
}\r
+\r
}\r
\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
log.info("Enhancing NodeTemplate($name)")
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = populateNodeType(nodeTypeName)
// Enrich NodeType
- bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
//Enrich Node Template Artifacts
enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
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.OperationDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTypeEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
val derivedFrom = nodeType.derivedFrom
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
val derivedFromNodeType = populateNodeType(name)
// Enrich NodeType
- enhance(bluePrintContext, error, derivedFrom, derivedFromNodeType)
+ enhance(bluePrintRuntimeService, derivedFrom, derivedFromNodeType)
}
// NodeType Property Definitions
open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
nodeType.properties?.let {
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, nodeType.properties!!)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
}
}
// Get Requirement NodeType from Repo and Update Service Template
val requirementNodeType = populateNodeType(requirementNodeTypeName)
// Enhanypece Node T
- enhance(bluePrintContext, error, requirementNodeTypeName, requirementNodeType)
+ enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
}
}
}
open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
nodeType.capabilities?.forEach { _, capabilityDefinition ->
capabilityDefinition.properties?.let { properties ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, properties)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, properties)
}
}
}
open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
operation.inputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
operation.outputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.PolicyType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
-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.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintPolicyTypeEnhancer {
- lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: PolicyType) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: PolicyType) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
// TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
: BluePrintPropertyDefinitionEnhancer {
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val propertyType = propertyDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+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
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintServiceTemplateEnhancer {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: ServiceTemplate) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: ServiceTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
initialCleanUp()
enhanceTopologyTemplate()
}
open fun enhanceTopologyTemplate() {
bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
- bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintContext, error, "default", topologyTemplate)
+ bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "default", topologyTemplate)
}
}
}
\ No newline at end of file
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintTopologyTemplateEnhancer {
- lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: TopologyTemplate) {
- this.bluePrintContext = bluePrintContext
- this.error = error
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: TopologyTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
enhanceTopologyTemplateInputs(type)
enhanceTopologyTemplateNodeTemplates(type)
open fun enhanceTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
topologyTemplate.inputs?.let { inputs ->
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
open fun enhanceTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
- bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, nodeTemplateName, nodeTemplate)
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate)
}
}
open fun enhanceTopologyTemplateWorkflowss(topologyTemplate: TopologyTemplate) {
topologyTemplate.workflows?.forEach { workflowName, workflow ->
- bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintContext, error, workflowName, workflow)
+ bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow)
}
}
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
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.interfaces.BluePrintWorkflowEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.beans.factory.config.ConfigurableBeanFactory
: BluePrintWorkflowEnhancer {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- lateinit var error: BluePrintError
+
+ val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
+
private val workflowDataTypes: MutableMap<String, DataType> = hashMapOf()
- override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
log.info("Enhancing Workflow($name)")
- this.bluePrintContext = bluePrintContext
- this.error = error
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val dynamicPropertyName = "$name-properties"
+ if (workflow.inputs == null) {
+ workflow.inputs = hashMapOf()
+ }
+ // Clean Dynamic Property Field, If present
+ workflow.inputs?.remove(dynamicPropertyName)
// Enrich Only for Resource Assignment and Dynamic Input Properties if any
- //enhanceStepTargets(workflow)
+ enhanceStepTargets(name, workflow)
// Enrich Workflow Inputs
- //enhanceWorkflowInputs(name, workflow)
+ enhanceWorkflowInputs(name, workflow)
}
open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
- val dynamicPropertyName = "$name-properties"
+
workflow.inputs?.let { inputs ->
- // TODO("Filter Dynamic Properties")
- bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
- private fun enhanceStepTargets(workflow: Workflow) {
+ private fun enhanceStepTargets(name: String, workflow: Workflow) {
+
+ // Get the first Step Target NodeTemplate name( Since that is the DG Node Template)
+ val dgNodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(name)
+
+ val dgNodeTemplate = bluePrintContext.nodeTemplateByName(dgNodeTemplateName)
- val workflowNodeTemplates = workflowTargets(workflow)
+ // Get the Dependent Component Node Template Names
+ val dependencyNodeTemplateNodes = dgNodeTemplate.properties?.get(PROPERTY_DEPENDENCY_NODE_TEMPLATES)
+ ?: throw BluePrintException("couldn't get property($PROPERTY_DEPENDENCY_NODE_TEMPLATES) ")
- workflowNodeTemplates.forEach { nodeTemplate ->
- val artifactFiles = bluePrintContext.nodeTemplateByName(nodeTemplate).artifacts?.filter {
+ val dependencyNodeTemplates = JacksonUtils.getListFromJsonNode(dependencyNodeTemplateNodes, String::class.java)
+
+ log.info("workflow($name) dependent component NodeTemplates($dependencyNodeTemplates)")
+
+ // Check and Get Resource Assignment File
+ val resourceAssignmentArtifacts = dependencyNodeTemplates?.mapNotNull { componentNodeTemplateName ->
+ log.info("Identified workflow($name) targets($componentNodeTemplateName")
+ val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName)
+ .artifacts?.filter {
it.value.type == "artifact-mapping-resource"
}?.map {
+ log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})")
it.value.file
}
+ resourceAssignmentArtifacts
+ }?.flatten()
+
+ log.info("Workflow($name) resource assignment files($resourceAssignmentArtifacts")
+
+ if (resourceAssignmentArtifacts != null && resourceAssignmentArtifacts.isNotEmpty()) {
+
+ // Add Workflow Dynamic Property
+ addWorkFlowDynamicPropertyDefinitions(name, workflow)
+
+ resourceAssignmentArtifacts.forEach { fileName ->
- artifactFiles?.let { fileName ->
val absoluteFilePath = "${bluePrintContext.rootPath}/$fileName"
- // Enhance Resource Assignment File
- enhanceResourceAssignmentFile(absoluteFilePath)
+ log.info("enriching workflow($name) artifacts file(${absoluteFilePath}")
+ // Enhance Resource Assignment File
+ val resourceAssignmentProperties = enhanceResourceAssignmentFile(absoluteFilePath)
+ // Add Workflow Dynamic DataType
+ addWorkFlowDynamicDataType(name, resourceAssignmentProperties)
}
}
}
- private fun workflowTargets(workflow: Workflow): List<String> {
- return workflow.steps?.map {
- it.value.target
- }?.filterNotNull() ?: arrayListOf()
- }
+ private fun enhanceResourceAssignmentFile(filePath: String): MutableMap<String, PropertyDefinition> {
+
+ val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
- open fun enhanceResourceAssignmentFile(filePath: String) {
val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
as? MutableList<ResourceAssignment>
?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
- resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintContext, error, resourceAssignments)
+
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+
+ resourceAssignments.forEach { resourceAssignment ->
+ resourceAssignmentProperties[resourceAssignment.name] = resourceAssignment.property!!
+ }
+ return resourceAssignmentProperties
+ }
+
+ private fun addWorkFlowDynamicPropertyDefinitions(name: String, workflow: Workflow) {
+ val dynamicPropertyName = "$name-properties"
+ val propertyDefinition = PropertyDefinition()
+ propertyDefinition.description = "Dynamic PropertyDefinition for workflow($name)."
+ propertyDefinition.type = "dt-$dynamicPropertyName"
+ propertyDefinition.required = true
+ // Add to Workflow Inputs
+ workflow.inputs?.put(dynamicPropertyName, propertyDefinition)
+ }
+
+ private fun addWorkFlowDynamicDataType(workflowName: String, mappingProperties: MutableMap<String, PropertyDefinition>) {
+
+ val dataTypeName = "dt-$workflowName-properties"
+
+ var recipeDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+
+ if (recipeDataType == null) {
+ log.info("DataType not present for the recipe({})", dataTypeName)
+ recipeDataType = DataType()
+ recipeDataType.version = "1.0.0"
+ recipeDataType.description = "Dynamic DataType definition for workflow($workflowName)."
+ recipeDataType.derivedFrom = ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC
+
+ val dataTypeProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
+ recipeDataType.properties = dataTypeProperties
+
+ // Overwrite WorkFlow DataType
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, recipeDataType)
+
+ } else {
+ log.info("Dynamic dataType($dataTypeName) already present for workflow($workflowName).")
+ }
+ // Merge all the Recipe Properties
+ mappingProperties.forEach { propertyName, propertyDefinition ->
+ recipeDataType.properties?.put(propertyName, propertyDefinition)
+ }
}
}
\ No newline at end of file
\r
import com.att.eelf.configuration.EELFLogger\r
import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
import org.onap.ccsdk.apps.controllerblueprints.core.format\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants\r
\r
@Throws(BluePrintException::class)\r
fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,\r
- bluePrintContext: BluePrintContext, error: BluePrintError,\r
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
resourceAssignments: List<ResourceAssignment>)\r
}\r
\r
* then get the NodeType of the Sources assigned\r
*/\r
override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,\r
- bluePrintContext: BluePrintContext, error: BluePrintError,\r
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
resourceAssignments: List<ResourceAssignment>) {\r
\r
val uniqueSourceNodeTypeNames = hashSetOf<String>()\r
// TODO("Candidate for Optimisation")\r
if (checkResourceDefinitionNeeded(resourceAssignment)) {\r
\r
- bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintContext, error, resourceAssignment.name,\r
+ bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name,\r
resourceAssignment.property!!);\r
\r
// Get the Resource Definition from Repo\r
?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))\r
\r
// Enrich as NodeTemplate\r
- bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, dictionarySource, sourceNodeTemplate)\r
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)\r
}\r
}\r
// Enrich the ResourceSource NodeTypes\r
uniqueSourceNodeTypeNames.map { nodeTypeName ->\r
val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)\r
- bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)\r
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)\r
}\r
\r
}\r
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})
String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
- BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath);
+ String targetPath = Paths.get("target", "bp-enhance").toUri().getPath();
+
+ BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath);
Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext);
+
}
}
\ No newline at end of file