import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactExpression
import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeExpression
import org.onap.ccsdk.cds.controllerblueprints.core.data.DSLExpression
*
* @author Brinda Santh
*/
-object BlueprintExpressionService {
+object BluePrintExpressionService {
val log = LoggerFactory.getLogger(this::class.toString())
val json = propertyAssignmentNode.toString()
// FIXME("Check if any Optimisation needed")
return (
- json.contains(BlueprintConstants.EXPRESSION_GET_INPUT) ||
- json.contains(BlueprintConstants.EXPRESSION_GET_ATTRIBUTE) ||
- json.contains(BlueprintConstants.EXPRESSION_GET_PROPERTY)
+ json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) ||
+ json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE) ||
+ json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY)
)
}
log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)
val expressionData = ExpressionData(valueNode = propertyAssignmentNode)
if (propertyAssignmentNode is ObjectNode) {
- val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BlueprintTypes.validCommands())
+ val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands())
if (commands.isNotEmpty()) {
expressionData.isExpression = true
expressionData.command = commands.first()
expressionData.expressionNode = propertyAssignmentNode
when (expressionData.command) {
- BlueprintConstants.EXPRESSION_GET_INPUT -> {
+ BluePrintConstants.EXPRESSION_GET_INPUT -> {
expressionData.inputExpression = populateInputExpression(propertyAssignmentNode)
}
- BlueprintConstants.EXPRESSION_GET_ATTRIBUTE -> {
+ BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> {
expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode)
}
- BlueprintConstants.EXPRESSION_GET_PROPERTY -> {
+ BluePrintConstants.EXPRESSION_GET_PROPERTY -> {
expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode)
}
- BlueprintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {
+ BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> {
expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode)
}
- BlueprintConstants.EXPRESSION_GET_ARTIFACT -> {
+ BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode)
}
}
}
} else if (propertyAssignmentNode is TextNode &&
- propertyAssignmentNode.textValue().startsWith(BlueprintConstants.EXPRESSION_DSL_REFERENCE)
+ propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
) {
expressionData.isExpression = true
- expressionData.command = BlueprintConstants.EXPRESSION_DSL_REFERENCE
+ expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE
expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode)
}
return expressionData
fun populateDSLExpression(jsonNode: TextNode): DSLExpression {
return DSLExpression(
propertyName = jsonNode.textValue()
- .removePrefix(BlueprintConstants.EXPRESSION_DSL_REFERENCE)
+ .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
)
}
fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BlueprintException(
+ throw BluePrintException(
String.format(
"missing property expression, " +
"it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +
fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BlueprintException(
+ throw BluePrintException(
String.format(
"missing attribute expression, " +
"it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 4) {
- throw BlueprintException(
+ throw BluePrintException(
String.format(
"missing operation output expression, " +
"it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}",
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BlueprintException(
+ throw BluePrintException(
String.format(
"missing artifact expression, " +
"it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}",