Enhancement to the Resource Resolution Service to add ResourceResolutionRunTimeService
Change-Id: Ia0799447e8a71e7455c5a18abc08dce503db6d35
Issue-ID: CCSDK-958
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.core
-
-/**
- * BluePrintConstants
- *
- * @author Brinda Santh
- */
-object BluePrintConstants {
-
- const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
- const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
- const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
- const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
-
- const val STATUS_SUCCESS: String = "success"
- const val STATUS_FAILURE: String = "failure"
-
- const val TYPE_DEFAULT: String = "default"
-
- const val DATA_TYPE_STRING: String = "string"
- const val DATA_TYPE_INTEGER: String = "integer"
- const val DATA_TYPE_FLOAT: String = "float"
- const val DATA_TYPE_BOOLEAN: String = "boolean"
- const val DATA_TYPE_TIMESTAMP: String = "timestamp"
- const val DATA_TYPE_NULL: String = "null"
- const val DATA_TYPE_LIST: String = "list"
- const val DATA_TYPE_MAP: String = "map"
-
- const val USER_SYSTEM: String = "System"
-
- const val PATH_DIVIDER: String = "/"
- const val PATH_SERVICE_TEMPLATE: String = "service_template"
- const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
- const val PATH_METADATA: String = "metadata"
- const val PATH_NODE_TYPES: String = "node_types"
- const val PATH_POLICY_TYPES: String = "policy_types"
- const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"
- const val PATH_ARTIFACT_TYPES: String = "artifact_types"
- const val PATH_DATA_TYPES: String = "data_types"
- const val PATH_INPUTS: String = "inputs"
- const val PATH_NODE_WORKFLOWS: String = "workflows"
- const val PATH_NODE_TEMPLATES: String = "node_templates"
- const val PATH_CAPABILITIES: String = "capabilities"
- const val PATH_REQUIREMENTS: String = "requirements"
- const val PATH_INTERFACES: String = "interfaces"
- const val PATH_OPERATIONS: String = "operations"
- const val PATH_OUTPUTS: String = "outputs"
- const val PATH_PROPERTIES: String = "properties"
- const val PATH_ATTRIBUTES: String = "attributes"
- const val PATH_ARTIFACTS: String = "artifacts"
-
- const val MODEL_DIR_MODEL_TYPE: String = "definition-type"
-
- const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
- const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
- const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
- const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"
- const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"
-
- const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"
- const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"
- const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"
- const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"
- const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"
- const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"
- const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"
-
- const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"
- const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"
- const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"
- const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
- const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
-
- const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
- const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
- const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
- @Deprecated("Artifacts will be attached to Node Template")
- const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
- const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
-
- const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
- const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
- const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
- const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
- const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"
- const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
-
- const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
-
- const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
-
- const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"
- const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"
- const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"
- const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"
- const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"
- const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"
- const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"
- const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"
- // Custom capabilities
- const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"
- const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"
- const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"
- const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
- const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
-
- const val EXPRESSION_GET_INPUT: String = "get_input"
- const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
- const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
- const val EXPRESSION_GET_PROPERTY: String = "get_property"
- const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"
- const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"
-
- const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"
- const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"
- const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"
- const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"
- const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"
- const val PROPERTY_BLUEPRINT_NAME: String = "template_name"
- const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"
-
- const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata"
- const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"
- const val TOSCA_DEFINITIONS_DIR: String = "Definitions"
- const val TOSCA_PLANS_DIR: String = "Plans"
- const val TOSCA_SCRIPTS_DIR: String = "Scripts"
- const val TOSCA_MAPPINGS_DIR: String = "Mappings"
- const val TOSCA_TEMPLATES_DIR: String = "Templates"
-
- const val METADATA_USER_GROUPS = "user-groups"
- const val METADATA_TEMPLATE_NAME = "template_name"
- const val METADATA_TEMPLATE_VERSION = "template_version"
- const val METADATA_TEMPLATE_AUTHOR = "template_author"
- const val METADATA_TEMPLATE_TAGS = "template_tags"
- const val METADATA_WORKFLOW_NAME = "workflow_name"
-
- const val PAYLOAD_DATA = "payload-data"
- const val PROPERTY_CURRENT_STEP = "current-step"
- const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
- const val PROPERTY_CURRENT_INTERFACE = "current-interface"
- const val PROPERTY_CURRENT_OPERATION = "current-operation"
- const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
- const val PROPERTY_EXECUTION_REQUEST = "execution-request"
-
- const val OPERATION_PROCESS = "process"
- const val OPERATION_PREPARE = "prepare"
-
- const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
- const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
- const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
-
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.controllerblueprints.core\r
+\r
+/**\r
+ * BluePrintConstants\r
+ *\r
+ * @author Brinda Santh\r
+ */\r
+object BluePrintConstants {\r
+\r
+ const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"\r
+ const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"\r
+ const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"\r
+ const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"\r
+\r
+ const val STATUS_SUCCESS: String = "success"\r
+ const val STATUS_FAILURE: String = "failure"\r
+\r
+ const val TYPE_DEFAULT: String = "default"\r
+\r
+ const val DATA_TYPE_STRING: String = "string"\r
+ const val DATA_TYPE_INTEGER: String = "integer"\r
+ const val DATA_TYPE_FLOAT: String = "float"\r
+ const val DATA_TYPE_DOUBLE: String = "double"\r
+ const val DATA_TYPE_BOOLEAN: String = "boolean"\r
+ const val DATA_TYPE_TIMESTAMP: String = "timestamp"\r
+ const val DATA_TYPE_NULL: String = "null"\r
+ const val DATA_TYPE_LIST: String = "list"\r
+ const val DATA_TYPE_MAP: String = "map"\r
+\r
+ const val USER_SYSTEM: String = "System"\r
+\r
+ const val PATH_DIVIDER: String = "/"\r
+ const val PATH_SERVICE_TEMPLATE: String = "service_template"\r
+ const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"\r
+ const val PATH_METADATA: String = "metadata"\r
+ const val PATH_NODE_TYPES: String = "node_types"\r
+ const val PATH_POLICY_TYPES: String = "policy_types"\r
+ const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"\r
+ const val PATH_ARTIFACT_TYPES: String = "artifact_types"\r
+ const val PATH_DATA_TYPES: String = "data_types"\r
+ const val PATH_INPUTS: String = "inputs"\r
+ const val PATH_NODE_WORKFLOWS: String = "workflows"\r
+ const val PATH_NODE_TEMPLATES: String = "node_templates"\r
+ const val PATH_CAPABILITIES: String = "capabilities"\r
+ const val PATH_REQUIREMENTS: String = "requirements"\r
+ const val PATH_INTERFACES: String = "interfaces"\r
+ const val PATH_OPERATIONS: String = "operations"\r
+ const val PATH_OUTPUTS: String = "outputs"\r
+ const val PATH_PROPERTIES: String = "properties"\r
+ const val PATH_ATTRIBUTES: String = "attributes"\r
+ const val PATH_ARTIFACTS: String = "artifacts"\r
+\r
+ const val MODEL_DIR_MODEL_TYPE: String = "definition-type"\r
+\r
+ const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"\r
+ const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"\r
+ const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"\r
+ const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"\r
+ const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"\r
+\r
+ const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"\r
+ const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"\r
+ const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"\r
+ const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"\r
+ const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"\r
+ const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"\r
+ const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"\r
+\r
+ const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"\r
+ const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"\r
+ const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"\r
+ const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"\r
+ const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"\r
+\r
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"\r
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"\r
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"\r
+ @Deprecated("Artifacts will be attached to Node Template")\r
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"\r
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"\r
+\r
+ const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"\r
+ const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"\r
+ const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"\r
+ const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"\r
+ const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"\r
+ const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"\r
+\r
+ const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"\r
+\r
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"\r
+\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"\r
+ // Custom capabilities\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"\r
+ const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"\r
+\r
+ const val EXPRESSION_GET_INPUT: String = "get_input"\r
+ const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"\r
+ const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"\r
+ const val EXPRESSION_GET_PROPERTY: String = "get_property"\r
+ const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"\r
+ const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"\r
+\r
+ const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"\r
+ const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"\r
+ const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"\r
+ const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"\r
+ const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"\r
+ const val PROPERTY_BLUEPRINT_NAME: String = "template_name"\r
+ const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"\r
+\r
+ const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata"\r
+ const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"\r
+ const val TOSCA_DEFINITIONS_DIR: String = "Definitions"\r
+ const val TOSCA_PLANS_DIR: String = "Plans"\r
+ const val TOSCA_SCRIPTS_DIR: String = "Scripts"\r
+ const val TOSCA_MAPPINGS_DIR: String = "Mappings"\r
+ const val TOSCA_TEMPLATES_DIR: String = "Templates"\r
+\r
+ const val METADATA_USER_GROUPS = "user-groups"\r
+ const val METADATA_TEMPLATE_NAME = "template_name"\r
+ const val METADATA_TEMPLATE_VERSION = "template_version"\r
+ const val METADATA_TEMPLATE_AUTHOR = "template_author"\r
+ const val METADATA_TEMPLATE_TAGS = "template_tags"\r
+ const val METADATA_WORKFLOW_NAME = "workflow_name"\r
+\r
+ const val PAYLOAD_DATA = "payload-data"\r
+ const val PROPERTY_CURRENT_STEP = "current-step"\r
+ const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"\r
+ const val PROPERTY_CURRENT_INTERFACE = "current-interface"\r
+ const val PROPERTY_CURRENT_OPERATION = "current-operation"\r
+ const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"\r
+ const val PROPERTY_EXECUTION_REQUEST = "execution-request"\r
+\r
+ const val OPERATION_PROCESS = "process"\r
+ const val OPERATION_PREPARE = "prepare"\r
+\r
+ const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"\r
+ const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"\r
+ const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"\r
+\r
}
\ No newline at end of file
validTypes.add(BluePrintConstants.DATA_TYPE_STRING)\r
validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)\r
validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)\r
+ validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE)\r
validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)\r
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)\r
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)\r
validTypes.add(BluePrintConstants.DATA_TYPE_STRING)\r
validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)\r
validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)\r
+ validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE)\r
validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)\r
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)\r
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)\r
// Checks\r
\r
fun checkNotEmpty(value: String?): Boolean {\r
- return value != null && value.isNotEmpty()\r
+ return value != null && value.isNotBlank()\r
}\r
\r
-fun checkNotEmptyNThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean {\r
- val notEmpty = value != null && value.isNotEmpty()\r
+fun checkNotEmptyOrThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean {\r
+ val notEmpty = checkNotEmpty(value)\r
if (!notEmpty) {\r
throw BluePrintException(message!!)\r
}\r
return notEmpty\r
}\r
\r
+fun checkEqualsOrThrow(value1: String?, value2: String?, lazyMessage: () -> Any): Boolean {\r
+ if (value1.equals(value2, ignoreCase = true)) {\r
+ return true\r
+ } else {\r
+ throw BluePrintException(lazyMessage().toString())\r
+ }\r
+}\r
+\r
+fun nullToEmpty(value: String?): String {\r
+ return if (checkNotEmpty(value)) value!! else ""\r
+}\r
+\r
+fun returnNotEmptyOrThrow(value: String?, lazyMessage: () -> Any): String {\r
+ if (checkNotEmpty(value)) {\r
+ return value!!\r
+ } else {\r
+ throw IllegalStateException(lazyMessage().toString())\r
+ }\r
+}\r
+\r
fun InputStream.toFile(path: String): File {\r
val file = File(path)\r
file.outputStream().use { this.copyTo(it) }\r
return file\r
}\r
\r
-\r
-\r
-\r
-\r
-\r
\r
@Throws(BluePrintException::class)\r
open fun validateImplementation(implementation: Implementation) {\r
- checkNotEmptyNThrow(implementation.primary)\r
+ checkNotEmptyOrThrow(implementation.primary)\r
}\r
\r
@Throws(BluePrintException::class)\r
import org.apache.commons.io.IOUtils\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
import java.io.File\r
import java.nio.charset.Charset\r
+import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType\r
\r
/**\r
*\r
return getMapFromJson(content, valueType)\r
}\r
\r
+ fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {\r
+ return readValue(getJson(properties), classType)\r
+ ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")\r
+ }\r
+\r
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
+ if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) {\r
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)\r
} else if (BluePrintTypes.validCollectionTypes().contains(type)) {\r
return checkJsonNodeValueOfCollectionType(type, jsonNode)\r
return false\r
}\r
\r
+ fun checkIfPrimitiveType(primitiveType: String): Boolean {\r
+ return when (primitiveType.toLowerCase()) {\r
+ BluePrintConstants.DATA_TYPE_STRING -> true\r
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> true\r
+ BluePrintConstants.DATA_TYPE_INTEGER -> true\r
+ BluePrintConstants.DATA_TYPE_FLOAT -> true\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> true\r
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> true\r
+ else -> false\r
+ }\r
+ }\r
+\r
fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {\r
- when (primitiveType) {\r
- BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual\r
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean\r
- BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt\r
- BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble\r
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual\r
- else -> return false\r
+ return when (primitiveType.toLowerCase()) {\r
+ BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual\r
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean\r
+ BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt\r
+ BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble\r
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual\r
+ else -> false\r
}\r
}\r
\r
fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {\r
- when (type) {\r
- BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray\r
- BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode\r
- else -> return false\r
+ return when (type.toLowerCase()) {\r
+ BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray\r
+ BluePrintConstants.DATA_TYPE_MAP -> jsonNode.isContainerNode\r
+ else -> false\r
}\r
}\r
\r
fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {\r
- when (primitiveType) {\r
+ when (primitiveType.toLowerCase()) {\r
BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)\r
BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)\r
BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, value as Double)\r
BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)\r
else -> objectNode.put(key, value as String)\r
}\r
}\r
\r
fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {\r
- when (primitiveType) {\r
+ when (primitiveType.toLowerCase()) {\r
BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)\r
BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)\r
BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(value as Double)\r
BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)\r
else -> arrayNode.add(value as String)\r
}\r
}\r
\r
fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {\r
- when (primitiveType) {\r
+ when (primitiveType.toLowerCase()) {\r
BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)\r
BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)\r
BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, 0.0)\r
else -> objectNode.put(key, "")\r
}\r
}\r
\r
fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {\r
- when (primitiveType) {\r
+ when (primitiveType.toLowerCase()) {\r
BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)\r
BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)\r
BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(0.0)\r
else -> arrayNode.add("")\r
}\r
}\r
}\r
}\r
\r
- fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {\r
- when (type) {\r
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)\r
- BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)\r
- BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)\r
- else -> return JacksonUtils.getJsonNode(value)\r
+ fun convertPrimitiveResourceValue(type: String, value: String): JsonNode {\r
+ return when (type.toLowerCase()) {\r
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(java.lang.Boolean.valueOf(value))\r
+ BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(Integer.valueOf(value))\r
+ BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(java.lang.Float.valueOf(value))\r
+ BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(java.lang.Double.valueOf(value))\r
+ else -> getJsonNode(value)\r
}\r
}\r
+\r
}\r
}
\ No newline at end of file
import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
}
open fun validateImplementation(implementation: Implementation) {
- checkNotEmptyNThrow(implementation.primary)
+ checkNotEmptyOrThrow(implementation.primary)
}
}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
-
-import java.util.Date
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.fasterxml.jackson.databind.node.NullNode
-import com.fasterxml.jackson.databind.node.ObjectNode
-import org.onap.ccsdk.apps.controllerblueprints.core.*
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-
-class ResourceAssignmentUtils {
- companion object {
-
- private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
-
- @Synchronized
- @Throws(BluePrintProcessorException::class)
- fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) {
-
- val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
- checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
-
- if (checkNotEmpty(resourceAssignment.dictionaryName)) {
- resourceAssignment.dictionaryName = resourceAssignment.name
- logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
- }
-
- try {
- if (checkNotEmpty(resourceProp.type)) {
- val convertedValue = convertResourceValue(resourceProp.type, value)
- logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
- resourceProp.value = convertedValue
- resourceAssignment.updatedDate = Date()
- resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
- resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS
- }
- } catch (e: Exception) {
- throw BluePrintProcessorException("Failed in setting value for template key (%s) and " +
- "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e)
- }
- }
-
- private fun convertResourceValue(type: String, value: Any?): JsonNode? {
- var convertedValue: JsonNode?
-
- if (value == null || value is NullNode) {
- logger.info("Returning {} value from convertResourceValue", value)
- return null
- } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) {
- convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value)
- } else {
- // Case where Resource is non-primitive type
- if (value is String) {
- convertedValue = JacksonUtils.jsonNode(value)
- } else {
- convertedValue = JacksonUtils.getJsonNode(value)
- }
- }
- return convertedValue
- }
-
- @Synchronized
- fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
- if (checkNotEmpty(resourceAssignment.name)) {
- resourceAssignment.updatedDate = Date()
- resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
- resourceAssignment.status = BluePrintConstants.STATUS_FAILURE
- resourceAssignment.message = message
- }
- }
-
- @Synchronized
- @Throws(BluePrintProcessorException::class)
- fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
- val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
- if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) {
- logger.error("failed to populate mandatory resource mapping ($resourceAssignment)")
- throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)")
- }
- }
-
- @Synchronized
- @Throws(BluePrintProcessorException::class)
- fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
- var result = "{}"
- try {
- val mapper = ObjectMapper()
- val root = mapper.readTree(result)
-
- assignments.forEach {
- if (checkNotEmpty(it.name) && it.property != null) {
-
- val type = it.property?.type
- val value = it.property?.value
- logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type,
- value)
- if (value == null) {
- (root as ObjectNode).set(it.name, null)
- } else if (value is JsonNode) {
- (root as ObjectNode).put(it.name, value as JsonNode)
- } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) {
- (root as ObjectNode).put(it.name, value as String)
- } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) {
- (root as ObjectNode).put(it.name, value as Boolean)
- } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) {
- (root as ObjectNode).put(it.name, value as Int)
- } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) {
- (root as ObjectNode).put(it.name, value as Float)
- } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) {
- (root as ObjectNode).put(it.name, value as String)
- } else {
- val jsonNode = JacksonUtils.getJsonNode(value)
- if (jsonNode != null) {
- (root as ObjectNode).put(it.name, jsonNode)
- } else {
- (root as ObjectNode).set(it.name, null)
- }
- }
- }
- }
- result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
- logger.info("Generated Resource Param Data ({})", result)
- } catch (e: Exception) {
- throw BluePrintProcessorException("kapil is failing with $e.message", e)
- }
-
- return result
- }
-
- fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
- val content = JacksonUtils.getJson(properties)
- return JacksonUtils.readValue(content, classType)
- ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)")
- }
-
- }
-}
\ No newline at end of file
import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
- checkNotEmptyNThrow(content, "artifact ($artifactName) content is empty")
+ checkNotEmptyOrThrow(content, "artifact ($artifactName) content is empty")
val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
pythonPath.add(blueprintBasePath)
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<name>Blueprints Processor Function - Resource Resolution</name>
<description>Blueprints Processor Function - Resource Resolution</description>
+ <dependencies>
+ <!--<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>db-resources</artifactId>
+ <version>${project.version}</version>
+ </dependency>-->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
</project>
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService\r
\r
class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)\r
- : DefaultBluePrintRuntimeService(id, bluePrintContext){\r
+ : DefaultBluePrintRuntimeService(id, bluePrintContext) {\r
\r
- private var resourceResolutionStore: MutableMap<String, JsonNode> = hashMapOf()\r
+ private lateinit var resolutionId: String\r
+ private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()\r
\r
- override fun getExecutionContext(): MutableMap<String, JsonNode> {\r
- return resourceResolutionStore\r
+ fun createUniqueId(key: String) {\r
+ resolutionId = "$id-$key"\r
}\r
\r
- @Suppress("UNCHECKED_CAST")\r
- override fun setExecutionContext(executionContext: MutableMap<String, JsonNode>) {\r
- this.resourceResolutionStore = executionContext\r
+ fun cleanResourceStore() {\r
+ resourceStore.clear()\r
}\r
\r
- override fun put(key: String, value: JsonNode) {\r
- resourceResolutionStore[key] = value\r
+ fun putResolutionStore(key: String, value: JsonNode) {\r
+ resourceStore[key] = value\r
}\r
\r
- override fun get(key: String): JsonNode {\r
- return resourceResolutionStore[key] ?: throw BluePrintProcessorException("failed to get execution property($key)")\r
+ fun getResolutionStore(key: String): JsonNode {\r
+ return resourceStore[key]\r
+ ?: throw BluePrintProcessorException("failed to get execution property ($key)")\r
}\r
\r
- override fun check(key: String): Boolean {\r
- return resourceResolutionStore.containsKey(key)\r
+ fun checkResolutionStore(key: String): Boolean {\r
+ return resourceStore.containsKey(key)\r
}\r
\r
- override fun cleanRuntime() {\r
- resourceResolutionStore.clear()\r
+ fun getJsonNodeFromResolutionStore(key: String): JsonNode {\r
+ return getResolutionStore(key)\r
}\r
\r
- private fun getJsonNode(key: String): JsonNode {\r
- return get(key)\r
+ fun getStringFromResolutionStore(key: String): String? {\r
+ return getResolutionStore(key).asText()\r
}\r
\r
- override fun getAsString(key: String): String? {\r
- return get(key).asText()\r
+ fun getBooleanFromResolutionStore(key: String): Boolean? {\r
+ return getResolutionStore(key).asBoolean()\r
}\r
\r
- override fun getAsBoolean(key: String): Boolean? {\r
- return get(key).asBoolean()\r
+ fun getIntFromResolutionStore(key: String): Int? {\r
+ return getResolutionStore(key).asInt()\r
}\r
\r
- override fun getAsInt(key: String): Int? {\r
- return get(key).asInt()\r
+ fun getDoubleFromResolutionStore(key: String): Double? {\r
+ return getResolutionStore(key).asDouble()\r
}\r
\r
- override fun getAsDouble(key: String): Double? {\r
- return get(key).asDouble()\r
+ fun putDictionaryStore(key: String, value: JsonNode) {\r
+ resourceStore["dictionary-$key"] = value\r
+ }\r
+\r
+ fun getDictionaryStore(key: String): JsonNode {\r
+ return resourceStore["dictionary-$key"]\r
+ ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")\r
+ }\r
+\r
+ fun checkDictionaryStore(key: String): Boolean {\r
+ return resourceStore.containsKey("dictionary-$key")\r
+ }\r
+\r
+ fun getJsonNodeFromDictionaryStore(key: String): JsonNode {\r
+ return getResolutionStore("dictionary-$key")\r
+ }\r
+\r
+ fun getStringFromDictionaryStore(key: String): String? {\r
+ return getResolutionStore("dictionary-$key").asText()\r
+ }\r
+\r
+ fun getBooleanFromDictionaryStore(key: String): Boolean? {\r
+ return getResolutionStore("dictionary-$key").asBoolean()\r
+ }\r
+\r
+ fun getIntFromDictionaryStore(key: String): Int? {\r
+ return getResolutionStore("dictionary-$key").asInt()\r
+ }\r
+\r
+ fun getDoubleFromDictionaryStore(key: String): Double? {\r
+ return getResolutionStore("dictionary-$key").asDouble()\r
}\r
\r
}\r
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
\r
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)\r
?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
\r
- executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)\r
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, templateArtifactName)\r
\r
// Check Template is there\r
val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)\r
}\r
\r
\r
- fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
- resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
- resourceAssignments: MutableList<ResourceAssignment>) {\r
+ private fun executeProcessors(blueprintRuntimeService: BluePrintRuntimeService<*>,\r
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
+ resourceAssignments: MutableList<ResourceAssignment>,\r
+ templateArtifactName: String) {\r
\r
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
+ val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, templateArtifactName)\r
\r
bulkSequenced.map { batchResourceAssignments ->\r
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
"for resource assignment(${resourceAssignment.name})")\r
try {\r
// Set BluePrint Runtime Service\r
- resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService\r
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService\r
// Set Resource Dictionaries\r
resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries\r
// Invoke Apply Method\r
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
return "resource-assignment-processor-capability"
}
- override fun process(executionRequest: ResourceAssignment) {
+ override fun process(resourceAssignment: ResourceAssignment) {
- val resourceDefinition = resourceDictionaries[executionRequest.dictionaryName]
- ?: throw BluePrintProcessorException("couldn't get resource definition for ${executionRequest.dictionaryName}")
+ val resourceDefinition = resourceDictionaries[resourceAssignment.dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ${resourceAssignment.dictionaryName}")
- val resourceSource = resourceDefinition.sources[executionRequest.dictionarySource]
- ?: throw BluePrintProcessorException("couldn't get resource definition ${executionRequest.dictionaryName} source(${executionRequest.dictionarySource})")
+ val resourceSource = resourceDefinition.sources[resourceAssignment.dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition ${resourceAssignment.dictionaryName} source(${resourceAssignment.dictionarySource})")
- checkNotNull(resourceSource.properties) { "failed to get ${executionRequest.dictionarySource} properties" }
-
- val capabilityResourceSourceProperty = ResourceAssignmentUtils.transformResourceSource(resourceSource.properties!!, CapabilityResourceSource::class.java)
+ val resourceSourceProps = checkNotNull(resourceSource.properties) { "failed to get $resourceSource properties" }
+ val capabilityResourceSourceProperty = JacksonUtils.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java)
val instanceType = capabilityResourceSourceProperty.type
val instanceName = capabilityResourceSourceProperty.instanceName
checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
// Assign Current Blueprint runtime and ResourceDictionaries
- componentResourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
componentResourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
// Invoke componentResourceAssignmentProcessor
- componentResourceAssignmentProcessor.apply(executionRequest)
+ componentResourceAssignmentProcessor.apply(resourceAssignment)
}
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
TODO("To Implement")
}
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import com.fasterxml.jackson.databind.node.NullNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.springframework.stereotype.Service
-import com.fasterxml.jackson.databind.node.NullNode
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceAssignmentUtils
/**
* InputResourceAssignmentProcessor
return "resource-assignment-processor-input"
}
- override fun process(executionRequest: ResourceAssignment) {
+ override fun process(resourceAssignment: ResourceAssignment) {
try {
- if (checkNotEmpty(executionRequest.name)) {
- val value = bluePrintRuntimeService!!.getInputValue(executionRequest.name)
+ if (checkNotEmpty(resourceAssignment.name)) {
+ val value = raRuntimeService.getInputValue(resourceAssignment.name)
// if value is null don't call setResourceDataValue to populate the value
if (value != null && value !is NullNode) {
- ResourceAssignmentUtils.setResourceDataValue(executionRequest, value)
+ ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
}
}
// Check the value has populated for mandatory case
- ResourceAssignmentUtils.assertTemplateKeyValueNotNull(executionRequest)
+ ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
- ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message)
- throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with : (${e.message})", e)
+ ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with : (${e.message})", e)
}
}
- override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
}
}
\ No newline at end of file
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
- lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
-
+ lateinit var raRuntimeService: ResourceAssignmentRuntimeService
lateinit var resourceDictionaries: Map<String, ResourceDefinition>
-
open fun resourceDefinition(name: String): ResourceDefinition {
return resourceDictionaries[name]
- ?: throw BluePrintProcessorException("couldn't get resource definition($name)")
+ ?: throw BluePrintProcessorException("couldn't get resource definition for ($name)")
}
override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
--- /dev/null
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.*
+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 java.util.*
+
+class ResourceAssignmentUtils {
+ companion object {
+
+ private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun setResourceDataValue(resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) {
+
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
+ checkNotEmptyOrThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
+
+ if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+ resourceAssignment.dictionaryName = resourceAssignment.name
+ logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
+ }
+
+ try {
+ if (checkNotEmpty(resourceProp.type)) {
+ val convertedValue = convertResourceValue(resourceProp.type, value)
+ logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
+ setResourceValue(resourceAssignment, raRuntimeService, convertedValue)
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS
+ }
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Failed in setting value for template key (${resourceAssignment.name}) and " +
+ "dictionary key (${resourceAssignment.dictionaryName}) of type (${resourceProp.type}) with error message (${e.message})", e)
+ }
+ }
+
+ private fun setResourceValue(resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, value: JsonNode) {
+ raRuntimeService.putResolutionStore(resourceAssignment.name, value)
+ raRuntimeService.putDictionaryStore(resourceAssignment.dictionaryName!!, value)
+ resourceAssignment.property!!.value = value
+ }
+
+ private fun convertResourceValue(type: String, value: Any?): JsonNode {
+
+ return if (value == null || value is NullNode) {
+ logger.info("Returning {} value from convertResourceValue", value)
+ NullNode.instance
+ } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) {
+ JacksonUtils.convertPrimitiveResourceValue(type, value)
+ } else if (value is String) {
+ JacksonUtils.jsonNode(value)
+ } else {
+ JacksonUtils.getJsonNode(value)
+ }
+
+ }
+
+ @Synchronized
+ fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) {
+ if (checkNotEmpty(resourceAssignment.name)) {
+ resourceAssignment.updatedDate = Date()
+ resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
+ resourceAssignment.status = BluePrintConstants.STATUS_FAILURE
+ resourceAssignment.message = message
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) {
+ val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" }
+ if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) {
+ logger.error("failed to populate mandatory resource mapping ($resourceAssignment)")
+ throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)")
+ }
+ }
+
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
+ var result = "{}"
+ try {
+ val mapper = ObjectMapper()
+ val root = mapper.readTree(result)
+
+ assignments.forEach {
+ if (checkNotEmpty(it.name) && it.property != null) {
+ val rName = it.name
+ val type = nullToEmpty(it.property?.type).toLowerCase()
+ val value = it.property?.value
+ logger.info("Generating Resource name ($rName), type ($type), value ($value)")
+
+ when (value) {
+ null -> (root as ObjectNode).set(rName, null)
+ is JsonNode -> (root as ObjectNode).set(rName, value)
+ else -> {
+ when (type) {
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> (root as ObjectNode).put(rName, value as String)
+ BluePrintConstants.DATA_TYPE_STRING -> (root as ObjectNode).put(rName, value as String)
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> (root as ObjectNode).put(rName, value as Boolean)
+ BluePrintConstants.DATA_TYPE_INTEGER -> (root as ObjectNode).put(rName, value as Int)
+ BluePrintConstants.DATA_TYPE_FLOAT -> (root as ObjectNode).put(rName, value as Float)
+ else -> {
+ if (JacksonUtils.getJsonNode(value) != null) {
+ (root as ObjectNode).set(rName, JacksonUtils.getJsonNode(value))
+ } else {
+ (root as ObjectNode).set(rName, null)
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
+ logger.info("Generated Resource Param Data ($result)")
+ } catch (e: Exception) {
+ throw BluePrintProcessorException("Resource Assignment is failed with $e.message", e)
+ }
+
+ return result
+ }
+
+ fun transformToRARuntimeService(blueprintRuntimeService: BluePrintRuntimeService<*>, templateArtifactName: String): ResourceAssignmentRuntimeService {
+ val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService(blueprintRuntimeService.id(), blueprintRuntimeService.bluePrintContext())
+ resourceAssignmentRuntimeService.createUniqueId(templateArtifactName)
+ resourceAssignmentRuntimeService.setExecutionContext(blueprintRuntimeService.getExecutionContext() as MutableMap<String, JsonNode>)
+
+ return resourceAssignmentRuntimeService
+ }
+
+ /*
+ * Populate the Field property type for the Data type
+ */
+ @Synchronized
+ @Throws(BluePrintProcessorException::class)
+ fun getPropertyType(raRuntimeService: ResourceAssignmentRuntimeService, dataTypeName: String, propertyName: String): String {
+ lateinit var type: String
+ try {
+ val dataTypeProps = checkNotNull(raRuntimeService.bluePrintContext().dataTypeByName(dataTypeName)?.properties)
+ val propertyDefinition = checkNotNull(dataTypeProps[propertyName])
+ type = returnNotEmptyOrThrow(propertyDefinition.type) { "Couldn't get data type ($dataTypeName)" }
+ logger.trace("Data type({})'s property ({}) is ({})", dataTypeName, propertyName, type)
+ } catch (e: Exception) {
+ logger.error("couldn't get data type($dataTypeName)'s property ($propertyName), error message $e")
+ throw BluePrintProcessorException("${e.message}", e)
+ }
+ return type
+ }
+ }
+}
\ No newline at end of file