diff options
author | jananib <janani.b@huawei.com> | 2020-08-12 22:47:11 +0530 |
---|---|---|
committer | jananib <janani.b@huawei.com> | 2020-08-12 22:47:11 +0530 |
commit | 8652382567ec5bb8e0527469f2c6334d44584df6 (patch) | |
tree | d6c72d98990d0aba0d51e69ad6471626b83279c6 | |
parent | 6ceb4fb11b426e68e965e008761c26cee484e770 (diff) |
Append input param true in workflow-spec
Workflow spec
Change-Id: Iac833abcc3d1079fbe8d12a354fd7ceff1aa758e
Issue-ID: CCSDK-422
Signed-off-by: jananib <janani.b@huawei.com>
2 files changed, 34 insertions, 5 deletions
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) } } } |