From 8652382567ec5bb8e0527469f2c6334d44584df6 Mon Sep 17 00:00:00 2001 From: jananib Date: Wed, 12 Aug 2020 22:47:11 +0530 Subject: Append input param true in workflow-spec Workflow spec Change-Id: Iac833abcc3d1079fbe8d12a354fd7ceff1aa758e Issue-ID: CCSDK-422 Signed-off-by: jananib --- .../core/data/BluePrintModel.kt | 2 ++ .../designer/api/handler/BluePrintModelHandler.kt | 37 +++++++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'ms/blueprintsprocessor/modules') diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt index 24901257e..8968ce3ef 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt @@ -162,6 +162,8 @@ class PropertyDefinition { var description: String? = null var required: Boolean? = null lateinit var type: String + @get:JsonProperty("input-param") + var inputparam: Boolean? = null @get:JsonProperty("default") var defaultValue: JsonNode? = null var status: String? = null diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt index b94b21252..3140abfb3 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt @@ -49,6 +49,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCach import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes import org.onap.ccsdk.cds.error.catalog.core.utils.errorCauseOrDefault import org.onap.ccsdk.cds.error.catalog.core.utils.errorMessageOrDefault @@ -63,6 +65,7 @@ import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import java.io.File import java.io.IOException import java.util.UUID @@ -121,30 +124,54 @@ open class BluePrintModelHandler( workFlowData.workFlowName = req.workflowName workFlowData.inputs = workFlow.inputs workFlowData.outputs = workFlow.outputs + wfRes.workFlowData = workFlowData if (workFlow.inputs != null) { for ((k, v) in workFlow.inputs!!) { - addPropertyInfo(v, blueprintContext, wfRes) + addPropertyInfo(k, v, blueprintContext, wfRes) } } if (workFlow.outputs != null) { for ((k, v) in workFlow.outputs!!) { - addPropertyInfo(v, blueprintContext, wfRes) + addPropertyInfo(k, v, blueprintContext, wfRes) } } - wfRes.workFlowData = workFlowData return wfRes } - private fun addPropertyInfo(prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) { + private fun addPropertyInfo(propName: String, prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) { + updatePropertyInfo(propName, prop, ctx, res) addDataType(prop.type, ctx, res) if (prop.entrySchema != null && prop.entrySchema!!.type != null) { addDataType(prop.entrySchema!!.type, ctx, res) } } + private fun updatePropertyInfo(name: String, prop: PropertyDefinition, ctx: BluePrintContext, res: WorkFlowSpecResponse) { + if (prop.inputparam == null || prop.inputparam == false) { + var workflow = ctx.workflowByName(res.workFlowData.workFlowName) + for ((k, v) in workflow.steps!!) { + var arts = ctx.nodeTemplateArtifacts(v.target!!) + if (arts != null) { + for ((k, v) in arts.entries!!) { + if (v.type == "artifact-mapping-resource") { + val file: String = v.file + val completePath = ctx.rootPath.plus(File.separator).plus(file) + val resourceAssignment = JacksonUtils.getListFromFile(completePath, ResourceAssignment::class.java) + for (res in resourceAssignment) { + if (res.name == name && res.inputParameter) { + prop.inputparam = true + return + } + } + } + } + } + } + } + } private fun addDataType(name: String, ctx: BluePrintContext, res: WorkFlowSpecResponse) { var data = ctx.dataTypeByName(name) if (data != null) { @@ -156,7 +183,7 @@ open class BluePrintModelHandler( private fun addParentDataType(data: DataType, ctx: BluePrintContext, res: WorkFlowSpecResponse) { if (data.properties != null) { for ((k, v) in data.properties!!) { - addPropertyInfo(v, ctx, res) + addPropertyInfo(k, v, ctx, res) } } } -- cgit 1.2.3-korg