package org.onap.ccsdk.cds.controllerblueprints.core.service
-
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
-import org.onap.ccsdk.cds.controllerblueprints.core.*
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ExpressionData
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationOutputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.format
+import org.onap.ccsdk.cds.controllerblueprints.core.isComplexType
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonPathParse
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
+import org.slf4j.LoggerFactory
/**
*
* @author Brinda Santh
*/
class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService<MutableMap<String, JsonNode>>) {
- private val log= LoggerFactory.getLogger(this::class.toString())
+
+ private val log = LoggerFactory.getLogger(this::class.toString())
private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext()
-/*
+ /*
-If Property Assignment is Expression.
- Get the Expression
- Recursively resolve the expression
- */
+ If Property Assignment is Expression.
+ Get the Expression
+ Recursively resolve the expression
+ */
- fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String,
- assignment: JsonNode): JsonNode {
+ fun resolveAssignmentExpression(
+ nodeTemplateName: String,
+ assignmentName: String,
+ assignment: JsonNode
+ ): JsonNode {
val valueNode: JsonNode
log.trace("Assignment ({})", assignment)
val expressionData = BluePrintExpressionService.getExpressionData(assignment)
valueNode = bluePrintRuntimeService.resolveDSLExpression(expressionData.dslExpression!!.propertyName)
}
BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> {
-
}
else -> {
throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command))
}
BluePrintConstants.PROPERTY_BPP -> {
valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(BluePrintConstants.PROPERTY_BPP, attributeName)
- ?: throw BluePrintException("failed to get env attribute name ($attributeName) ")
+ ?: throw BluePrintException("failed to get env attribute name ($attributeName) ")
}
else -> {
if (!attributeExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) {
}
var attributeDefinition: AttributeDefinition = bluePrintContext
- .nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)
- ?: throw BluePrintException("failed to get attribute definitions for node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
+ .nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)
+ ?: throw BluePrintException("failed to get attribute definitions for node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName)
- ?: throw BluePrintException("failed to get node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
+ ?: throw BluePrintException("failed to get node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ")
}
-
}
if (subAttributeName != null) {
if (valueNode.isComplexType())
}
val nodeTemplatePropertyExpression = bluePrintContext.nodeTemplateByName(propertyNodeTemplateName).properties?.get(propertyName)
- ?: throw BluePrintException(format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, propertyName))
+ ?: throw BluePrintException(
+ format(
+ "failed to get property definitions for node template ({})'s property name ({}) ",
+ nodeTemplateName,
+ propertyName
+ )
+ )
var propertyDefinition: PropertyDefinition = bluePrintContext.nodeTemplateNodeType(propertyNodeTemplateName).properties?.get(propertyName)!!
- log.info("node template name ({}), property Name ({}) resolved value ({})", propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
+ log.info(
+ "node template name ({}), property Name ({}) resolved value ({})",
+ propertyNodeTemplateName,
+ propertyName,
+ nodeTemplatePropertyExpression
+ )
// Check it it is a nested expression
valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression)
outputNodeTemplateName = operationOutputExpression.modelableEntityName
}
- var valueNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName,
- operationOutputExpression.interfaceName, operationOutputExpression.operationName,
- operationOutputExpression.propertyName)
+ var valueNode = bluePrintRuntimeService.getNodeTemplateOperationOutputValue(
+ outputNodeTemplateName,
+ operationOutputExpression.interfaceName, operationOutputExpression.operationName,
+ operationOutputExpression.propertyName
+ )
val subPropertyName: String? = operationOutputExpression.subPropertyName
if (subPropertyName != null) {
artifactNodeTemplateName = artifactExpression.modelableEntityName
}
val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName)
- .artifacts?.get(artifactExpression.artifactName)
- ?: throw BluePrintException(format("failed to get artifact definitions for node template ({})'s " +
- "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName))
+ .artifacts?.get(artifactExpression.artifactName)
+ ?: throw BluePrintException(
+ format(
+ "failed to get artifact definitions for node template ({})'s " +
+ "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName
+ )
+ )
return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition))
}
return ""
}
}
-