aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core/src/main
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2019-11-22 18:06:08 -0500
committerKAPIL SINGAL <ks220y@att.com>2019-11-26 21:32:38 +0000
commit341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch)
tree113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/controllerblueprints/modules/blueprint-core/src/main
parentd274e5fc552cf9ae25500f504f0434981cf3accf (diff)
Formatting Code base with ktlint
No Business logic change, just the code format. Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3 To format run: mvn process-sources -P format Issue-ID: CCSDK-1947 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core/src/main')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt50
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt100
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt20
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctions.kt31
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContext.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt61
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt61
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt39
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt45
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt (renamed from ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintErrorCode.kt)7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt11
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt210
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt175
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt12
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt71
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt17
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt89
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt161
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt8
-rwxr-xr-xms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt20
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt9
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt11
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt18
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt32
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt40
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt21
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt31
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt38
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt88
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt8
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt108
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt9
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt46
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt28
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt165
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateService.kt (renamed from ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateService.kt)25
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt277
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt18
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt25
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt83
-rwxr-xr-xms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt89
-rwxr-xr-xms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt76
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt11
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt52
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt16
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt19
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt38
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt13
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt12
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtils.kt23
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt2
61 files changed, 1707 insertions, 962 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
index 509b8ca3a..b97cb026a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt
@@ -203,4 +203,4 @@ object BluePrintConstants {
const val MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN = "artifact-script-kotlin"
const val MODEL_TYPE_ARTIFACT_DIRECTED_GRAPH = "artifact-directed-graph"
const val MODEL_TYPE_ARTIFACT_COMPONENT_JAR = "artifact-component-jar"
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
index 22b452ab9..66d54f52e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintError.kt
@@ -26,4 +26,4 @@ class BluePrintError {
fun addError(error: String) {
this.errors.add(error)
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt
index 22be37278..a2435da13 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintException.kt
@@ -15,6 +15,7 @@
*/
package org.onap.ccsdk.cds.controllerblueprints.core
+
/**
*
*
@@ -41,9 +42,8 @@ class BluePrintException : Exception {
this.code = code
}
- constructor(code: Int, cause: Throwable, message: String, vararg args: Any?)
- : super(String.format(message, *args), cause) {
+ constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) :
+ super(String.format(message, *args), cause) {
this.code = code
}
}
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt
index dafd076fb..daf833494 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintExtensionFunctions.kt
@@ -16,12 +16,26 @@
package org.onap.ccsdk.cds.controllerblueprints.core
-import org.onap.ccsdk.cds.controllerblueprints.core.annotations.*
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.ArtifactExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.AttributeExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsConstrain
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsDataType
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.BluePrintsProperty
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.DSLExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.InputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.OperationOutputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.PropertyDefaultValue
+import org.onap.ccsdk.cds.controllerblueprints.core.annotations.PropertyExpression
import org.onap.ccsdk.cds.controllerblueprints.core.data.ConstraintClause
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
-import org.onap.ccsdk.cds.controllerblueprints.core.dsl.*
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.dslExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getInput
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getNodeTemplateArtifact
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getNodeTemplateAttribute
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getNodeTemplateOperationOutput
+import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getNodeTemplateProperty
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1
import kotlin.reflect.KType
@@ -58,7 +72,7 @@ fun <T> KProperty1<T, *>.asPropertyDefinition(): PropertyDefinition {
property.entrySchema = this.returnType.entitySchema()
}
this.annotations.forEach { fieldAnnotation ->
- //println("Field : ${this.name} : Annotation : $fieldAnnotation")
+ // println("Field : ${this.name} : Annotation : $fieldAnnotation")
when (fieldAnnotation) {
is BluePrintsProperty ->
property.description = fieldAnnotation.description
@@ -72,20 +86,28 @@ fun <T> KProperty1<T, *>.asPropertyDefinition(): PropertyDefinition {
property.value = getInput(fieldAnnotation.propertyName)
}
is PropertyExpression -> {
- property.value = getNodeTemplateProperty(fieldAnnotation.modelableEntityName,
- fieldAnnotation.propertyName, fieldAnnotation.subPropertyName)
+ property.value = getNodeTemplateProperty(
+ fieldAnnotation.modelableEntityName,
+ fieldAnnotation.propertyName, fieldAnnotation.subPropertyName
+ )
}
is AttributeExpression -> {
- property.value = getNodeTemplateAttribute(fieldAnnotation.modelableEntityName,
- fieldAnnotation.attributeName, fieldAnnotation.subAttributeName)
+ property.value = getNodeTemplateAttribute(
+ fieldAnnotation.modelableEntityName,
+ fieldAnnotation.attributeName, fieldAnnotation.subAttributeName
+ )
}
is ArtifactExpression -> {
- property.value = getNodeTemplateArtifact(fieldAnnotation.modelableEntityName,
- fieldAnnotation.artifactName)
+ property.value = getNodeTemplateArtifact(
+ fieldAnnotation.modelableEntityName,
+ fieldAnnotation.artifactName
+ )
}
is OperationOutputExpression -> {
- property.value = getNodeTemplateOperationOutput(fieldAnnotation.modelableEntityName,
- fieldAnnotation.interfaceName, fieldAnnotation.propertyName, fieldAnnotation.subPropertyName)
+ property.value = getNodeTemplateOperationOutput(
+ fieldAnnotation.modelableEntityName,
+ fieldAnnotation.interfaceName, fieldAnnotation.propertyName, fieldAnnotation.subPropertyName
+ )
}
is DSLExpression -> {
property.value = dslExpression(fieldAnnotation.propertyName)
@@ -111,16 +133,16 @@ internal fun <T : KType> T.entitySchema(): EntrySchema {
internal fun <T : KType> T.asBluePrintsDataType(propertyName: String): String {
val simpleName = (this.classifier as? KClass<*>)?.java?.simpleName
- ?: throw BluePrintException("filed to get simple name.")
+ ?: throw BluePrintException("filed to get simple name.")
return when (simpleName) {
"String", "Date" -> BluePrintConstants.DATA_TYPE_STRING
"int" -> BluePrintConstants.DATA_TYPE_INTEGER
"Boolean" -> BluePrintConstants.DATA_TYPE_BOOLEAN
"Float" -> BluePrintConstants.DATA_TYPE_FLOAT
"Double" -> BluePrintConstants.DATA_TYPE_DOUBLE
- "List" -> BluePrintConstants.DATA_TYPE_LIST
+ "List" -> BluePrintConstants.DATA_TYPE_LIST
"Map" -> BluePrintConstants.DATA_TYPE_MAP
"Object", "JsonNode", "ObjectNode", "ArrayNode" -> BluePrintConstants.DATA_TYPE_JSON
else -> simpleName
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt
index 0a530708f..b0b217051 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintProcessorException.kt
@@ -23,6 +23,7 @@ package org.onap.ccsdk.cds.controllerblueprints.core
* @author Brinda Santh
*/
class BluePrintProcessorException : RuntimeException {
+
var code: Int = 100
constructor(message: String, cause: Throwable) : super(message, cause)
@@ -42,8 +43,8 @@ class BluePrintProcessorException : RuntimeException {
this.code = code
}
- constructor(code: Int, cause: Throwable, message: String, vararg args: Any?)
- : super(String.format(message, *args), cause) {
+ constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) :
+ super(String.format(message, *args), cause) {
this.code = code
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt
index 30ac68abd..0e4279a3a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintTypes.kt
@@ -28,60 +28,60 @@ object BluePrintTypes {
@JvmStatic
val validNodeTypeDerivedFroms: MutableList<String> = arrayListOf(
- BluePrintConstants.MODEL_TYPE_NODES_ROOT,
- BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
- BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- BluePrintConstants.MODEL_TYPE_NODE_VNF,
- BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON,
- BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT
+ BluePrintConstants.MODEL_TYPE_NODES_ROOT,
+ BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
+ BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ BluePrintConstants.MODEL_TYPE_NODE_VNF,
+ BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON,
+ BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT
)
@JvmStatic
val validArtifactTypeDerivedFroms: MutableList<String> = arrayListOf(
- BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT,
- BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION
+ BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT,
+ BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION
)
@JvmStatic
val validDataTypeDerivedFroms: MutableList<String> = arrayListOf(
- BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT,
- BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
+ BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT,
+ BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
)
@JvmStatic
val validRelationShipDerivedFroms: MutableList<String> = arrayListOf(
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON,
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO,
- BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON,
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO,
+ BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
)
@JvmStatic
val validCapabilityTypes: MutableList<String> = arrayListOf(
- BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH,
- BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP
+ BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH,
+ BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP
)
@JvmStatic
@@ -135,19 +135,21 @@ object BluePrintTypes {
@JvmStatic
fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean {
val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL
- return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type)
- && BluePrintTypes.validPrimitiveTypes().contains(entrySchema)
+ return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type) &&
+ BluePrintTypes.validPrimitiveTypes().contains(entrySchema)
}
@JvmStatic
fun validCommands(): List<String> {
- return listOf(BluePrintConstants.EXPRESSION_DSL_REFERENCE,
- BluePrintConstants.EXPRESSION_GET_INPUT,
- BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
- BluePrintConstants.EXPRESSION_GET_PROPERTY,
- BluePrintConstants.EXPRESSION_GET_ARTIFACT,
- BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT,
- BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE)
+ return listOf(
+ BluePrintConstants.EXPRESSION_DSL_REFERENCE,
+ BluePrintConstants.EXPRESSION_GET_INPUT,
+ BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
+ BluePrintConstants.EXPRESSION_GET_PROPERTY,
+ BluePrintConstants.EXPRESSION_GET_ARTIFACT,
+ BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT,
+ BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE
+ )
}
@JvmStatic
@@ -159,6 +161,4 @@ object BluePrintTypes {
fun rootDataTypes(): List<String> {
return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
index 7aa2fc86c..5189d0758 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt
@@ -18,13 +18,20 @@
package org.onap.ccsdk.cds.controllerblueprints.core
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.*
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.BooleanNode
+import com.fasterxml.jackson.databind.node.DoubleNode
+import com.fasterxml.jackson.databind.node.IntNode
+import com.fasterxml.jackson.databind.node.MissingNode
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.TextNode
import org.apache.commons.lang3.ObjectUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JsonParserUtils
import org.slf4j.LoggerFactory
import org.slf4j.helpers.MessageFormatter
-import java.util.*
+import java.util.UUID
import kotlin.reflect.KClass
/**
@@ -50,8 +57,8 @@ fun <T : Any> T.bpClone(): T {
}
fun String.isJson(): Boolean {
- return ((this.trim().startsWith("{") && this.trim().endsWith("}"))
- || (this.trim().startsWith("[") && this.trim().endsWith("]")))
+ return ((this.trim().startsWith("{") && this.trim().endsWith("}")) ||
+ (this.trim().startsWith("[") && this.trim().endsWith("]")))
}
fun Any.asJsonString(intend: Boolean? = false): String {
@@ -183,7 +190,7 @@ fun ArrayNode.asListOfString(): List<String> {
fun <T> JsonNode.asType(clazzType: Class<T>): T {
return JacksonUtils.readValue(this, clazzType)
- ?: throw BluePrintException("couldn't convert JsonNode of type $clazzType")
+ ?: throw BluePrintException("couldn't convert JsonNode of type $clazzType")
}
fun JsonNode.asListOfString(): List<String> {
@@ -228,7 +235,6 @@ fun JsonNode.removeNullNode() {
}
}
-
fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {
val convertedValue = value.asJsonType()
this[key] = convertedValue
@@ -325,5 +331,3 @@ fun JsonNode.jsonPaths(expression: String): List<String> {
check(this.isComplexType()) { "$this is not complex or array node to apply expression" }
return JsonParserUtils.paths(this, expression)
}
-
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctions.kt
index 793bdc455..5995a8a9e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctions.kt
@@ -50,16 +50,16 @@ fun Graph.toAdjacencyList(): Graph.AdjacencyList<String, EdgeLabel> {
fun Graph.findAllPaths(from: String, to: String, path: List<String> = emptyList()): List<List<String>> {
if (from == to) return listOf(path + to)
return nodes[from]!!.neighbors()
- .filter { !path.contains(it.id) }
- .flatMap { findAllPaths(it.id, to, path + from) }
+ .filter { !path.contains(it.id) }
+ .flatMap { findAllPaths(it.id, to, path + from) }
}
fun Graph.findCycles(node: String): List<List<String>> {
fun findCycles(path: List<String>): List<List<String>> {
if (path.size > 3 && path.first() == path.last()) return listOf(path)
return nodes[path.last()]!!.neighbors()
- .filterNot { path.tail().contains(it.id) }
- .flatMap { findCycles(path + it.id) }
+ .filterNot { path.tail().contains(it.id) }
+ .flatMap { findCycles(path + it.id) }
}
return findCycles(listOf(node))
}
@@ -76,41 +76,40 @@ fun Graph.endNodes(): Set<Graph.Node> = this.nodes.values.filter {
fun Graph.node(node: String) = this.nodes[node]
fun Graph.edge(label: EdgeLabel) =
- this.edges.filter { it.label == label }
+ this.edges.filter { it.label == label }
fun Graph.incomingEdges(node: String) =
- this.edges.filter { it.target.id == node }
+ this.edges.filter { it.target.id == node }
fun Graph.incomingNodes(node: String) =
- this.incomingEdges(node).map { it.source }
+ this.incomingEdges(node).map { it.source }
fun Graph.outgoingEdges(node: String) =
- this.edges.filter { it.source.id == node }
+ this.edges.filter { it.source.id == node }
fun Graph.outgoingNodes(node: String) =
- this.outgoingEdges(node).map { it.target }
+ this.outgoingEdges(node).map { it.target }
fun Graph.outgoingEdges(node: String, label: EdgeLabel) =
- this.edges.filter { it.source.id == node && it.label == label }
+ this.edges.filter { it.source.id == node && it.label == label }
fun Graph.outgoingNodes(node: String, label: EdgeLabel) =
- this.outgoingEdges(node, label).map { it.target }
+ this.outgoingEdges(node, label).map { it.target }
fun Graph.outgoingNodesNotInEdgeLabels(node: String, labels: List<EdgeLabel>) =
- this.outgoingEdgesNotInLabels(node, labels).map { it.target }
+ this.outgoingEdgesNotInLabels(node, labels).map { it.target }
fun Graph.outgoingEdges(node: String, labels: List<EdgeLabel>) =
- this.edges.filter { it.source.id == node && labels.contains(it.label) }
+ this.edges.filter { it.source.id == node && labels.contains(it.label) }
fun Graph.outgoingEdgesNotInLabels(node: String, labels: List<EdgeLabel>) =
- this.edges.filter { it.source.id == node && !labels.contains(it.label) }
+ this.edges.filter { it.source.id == node && !labels.contains(it.label) }
fun Graph.outgoingNodes(node: String, labels: List<EdgeLabel>) =
- this.outgoingEdges(node, labels).map { it.target }
+ this.outgoingEdges(node, labels).map { it.target }
fun Graph.isEndNode(node: Graph.Node): Boolean {
return this.endNodes().contains(node)
}
fun <T> List<T>.tail(): List<T> = drop(1)
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContext.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContext.kt
index 001ec751e..9d81f13e3 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContext.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/MDCContext.kt
@@ -24,7 +24,8 @@ import kotlin.coroutines.CoroutineContext
typealias MDCContextMap = Map<String, String>?
class MDCContext(private val contextMap: MDCContextMap = MDC.getCopyOfContextMap()) :
- ThreadContextElement<MDCContextMap>, AbstractCoroutineContextElement(Key) {
+ ThreadContextElement<MDCContextMap>, AbstractCoroutineContextElement(Key) {
+
/**
* Key of [MDCContext] in [CoroutineContext].
*/
@@ -47,4 +48,4 @@ class MDCContext(private val contextMap: MDCContextMap = MDC.getCopyOfContextMap
MDC.setContextMap(contextMap)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt
index 94392b992..c39442976 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/annotations/BluePrintsAnnotations.kt
@@ -16,16 +16,15 @@
package org.onap.ccsdk.cds.controllerblueprints.core.annotations
-
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import kotlin.reflect.KClass
@Target(AnnotationTarget.CLASS)
annotation class BluePrintsDataType(
- val name: String,
- val version: String = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- val description: String,
- val derivedFrom: String = "tosca.datatypes.root"
+ val name: String,
+ val version: String = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ val description: String,
+ val derivedFrom: String = "tosca.datatypes.root"
)
@Target(AnnotationTarget.CLASS)
@@ -35,13 +34,17 @@ annotation class BluePrintsWorkflowInput
annotation class BluePrintsWorkflowOutput
@Target(AnnotationTarget.CLASS)
-annotation class BluePrintsNodeType(val propertiesType: KClass<*>, val attributesType: KClass<*>,
- val inputsType: KClass<*>, val outputsType: KClass<*>)
+annotation class BluePrintsNodeType(
+ val propertiesType: KClass<*>,
+ val attributesType: KClass<*>,
+ val inputsType: KClass<*>,
+ val outputsType: KClass<*>
+)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class BluePrintsProperty(
- val name: String = "",
- val description: String = ""
+ val name: String = "",
+ val description: String = ""
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
@@ -55,43 +58,43 @@ annotation class PropertyValidValue(val value: String)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class InputExpression(
- val propertyName: String
+ val propertyName: String
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class PropertyExpression(
- val modelableEntityName: String = "SELF",
- val reqOrCapEntityName: String = "",
- val propertyName: String,
- val subPropertyName: String = ""
+ val modelableEntityName: String = "SELF",
+ val reqOrCapEntityName: String = "",
+ val propertyName: String,
+ val subPropertyName: String = ""
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class AttributeExpression(
- val modelableEntityName: String = "SELF",
- val reqOrCapEntityName: String = "",
- val attributeName: String,
- val subAttributeName: String = ""
+ val modelableEntityName: String = "SELF",
+ val reqOrCapEntityName: String = "",
+ val attributeName: String,
+ val subAttributeName: String = ""
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class ArtifactExpression(
- val modelableEntityName: String = "SELF",
- val artifactName: String,
- val location: String = "LOCAL_FILE",
- val remove: Boolean = false
+ val modelableEntityName: String = "SELF",
+ val artifactName: String,
+ val location: String = "LOCAL_FILE",
+ val remove: Boolean = false
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class OperationOutputExpression(
- val modelableEntityName: String = "SELF",
- val interfaceName: String,
- val operationName: String,
- val propertyName: String,
- val subPropertyName: String = ""
+ val modelableEntityName: String = "SELF",
+ val interfaceName: String,
+ val operationName: String,
+ val propertyName: String,
+ val subPropertyName: String = ""
)
@Target(AnnotationTarget.FIELD, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY)
annotation class DSLExpression(
- val propertyName: String
-) \ No newline at end of file
+ val propertyName: String
+)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt
index 10b902f2b..0128f64a5 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt
@@ -17,13 +17,12 @@
package org.onap.ccsdk.cds.controllerblueprints.core.config
-
open class BluePrintLoadConfiguration {
lateinit var blueprintDeployPath: String
lateinit var blueprintArchivePath: String
lateinit var blueprintWorkingPath: String
-
+
var loadBluePrintPaths: String? = null
var loadModeTypePaths: String? = null
var loadResourceDictionaryPaths: String? = null
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
index d3013402b..37c128714 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintExpressionData.kt
@@ -20,59 +20,58 @@ package org.onap.ccsdk.cds.controllerblueprints.core.data
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
+
/**
*
*
* @author Brinda Santh
*/
data class ExpressionData(
- var isExpression: Boolean = false,
- var valueNode: JsonNode,
- var expressionNode: ObjectNode? = null,
- var dslExpression: DSLExpression? = null,
- var inputExpression: InputExpression? = null,
- var propertyExpression: PropertyExpression? = null,
- var attributeExpression: AttributeExpression? = null,
- var artifactExpression: ArtifactExpression? = null,
- var operationOutputExpression: OperationOutputExpression? = null,
- var command: String? = null
+ var isExpression: Boolean = false,
+ var valueNode: JsonNode,
+ var expressionNode: ObjectNode? = null,
+ var dslExpression: DSLExpression? = null,
+ var inputExpression: InputExpression? = null,
+ var propertyExpression: PropertyExpression? = null,
+ var attributeExpression: AttributeExpression? = null,
+ var artifactExpression: ArtifactExpression? = null,
+ var operationOutputExpression: OperationOutputExpression? = null,
+ var command: String? = null
)
data class InputExpression(
- var propertyName: String
+ var propertyName: String
)
data class PropertyExpression(
- var modelableEntityName: String = "SELF",
- var reqOrCapEntityName: String? = null,
- var propertyName: String,
- var subPropertyName: String? = null
+ var modelableEntityName: String = "SELF",
+ var reqOrCapEntityName: String? = null,
+ var propertyName: String,
+ var subPropertyName: String? = null
)
data class AttributeExpression(
- var modelableEntityName: String = "SELF",
- var reqOrCapEntityName: String? = null,
- var attributeName: String,
- var subAttributeName: String? = null
+ var modelableEntityName: String = "SELF",
+ var reqOrCapEntityName: String? = null,
+ var attributeName: String,
+ var subAttributeName: String? = null
)
data class ArtifactExpression(
- val modelableEntityName: String = "SELF",
- val artifactName: String,
- val location: String? = "LOCAL_FILE",
- val remove: Boolean? = false
+ val modelableEntityName: String = "SELF",
+ val artifactName: String,
+ val location: String? = "LOCAL_FILE",
+ val remove: Boolean? = false
)
data class OperationOutputExpression(
- val modelableEntityName: String = "SELF",
- val interfaceName: String,
- val operationName: String,
- val propertyName: String,
- var subPropertyName: String? = null
+ val modelableEntityName: String = "SELF",
+ val interfaceName: String,
+ val operationName: String,
+ val propertyName: String,
+ var subPropertyName: String? = null
)
data class DSLExpression(
- val propertyName: String
+ val propertyName: String
)
-
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt
index fc796c9ed..9c9b1f9bf 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintGraph.kt
@@ -98,7 +98,7 @@ class Graph {
fun neighbors(): List<Node> = edges.map { edge -> edge.target(this) }
fun neighbors(label: EdgeLabel): List<Node> = edges.filter { it.label == label }
- .map { edge -> edge.target(this) }
+ .map { edge -> edge.target(this) }
fun labelEdges(label: EdgeLabel): List<Edge> = edges.filter { it.label == label }
@@ -106,19 +106,20 @@ class Graph {
}
data class Edge(
- val source: Node,
- val target: Node,
- val label: EdgeLabel,
- var status: EdgeStatus = EdgeStatus.NOT_STARTED) {
+ val source: Node,
+ val target: Node,
+ val label: EdgeLabel,
+ var status: EdgeStatus = EdgeStatus.NOT_STARTED
+ ) {
fun target(node: Node): Node = target
fun equivalentTo(other: Edge) =
- (source == other.source && target == other.target)
- || (source == other.target && target == other.source)
+ (source == other.source && target == other.target) ||
+ (source == other.target && target == other.source)
override fun toString() =
- "${source.id}>${target.id}/$label($status)"
+ "${source.id}>${target.id}/$label($status)"
}
data class TermForm(val nodes: Collection<String>, val edges: List<Term>) {
@@ -147,23 +148,27 @@ class Graph {
companion object {
fun labeledDirectedTerms(termForm: TermForm): Graph =
- createFromTerms(termForm) { graph, n1, n2, value -> graph.addEdge(n1, n2, value) }
+ createFromTerms(termForm) { graph, n1, n2, value -> graph.addEdge(n1, n2, value) }
fun labeledDirectedAdjacent(adjacencyList: AdjacencyList<String, EdgeLabel>): Graph =
- fromAdjacencyList(adjacencyList) { graph, n1, n2, value ->
- graph.addEdge(n1, n2, value)
- }
+ fromAdjacencyList(adjacencyList) { graph, n1, n2, value ->
+ graph.addEdge(n1, n2, value)
+ }
- private fun createFromTerms(termForm: TermForm,
- addFunction: (Graph, String, String, EdgeLabel) -> Unit): Graph {
+ private fun createFromTerms(
+ termForm: TermForm,
+ addFunction: (Graph, String, String, EdgeLabel) -> Unit
+ ): Graph {
val graph = Graph()
termForm.nodes.forEach { graph.addNode(it) }
termForm.edges.forEach { addFunction(graph, it.source, it.target, it.label) }
return graph
}
- private fun fromAdjacencyList(adjacencyList: AdjacencyList<String, EdgeLabel>,
- addFunction: (Graph, String, String, EdgeLabel) -> Unit): Graph {
+ private fun fromAdjacencyList(
+ adjacencyList: AdjacencyList<String, EdgeLabel>,
+ addFunction: (Graph, String, String, EdgeLabel) -> Unit
+ ): Graph {
val graph = Graph()
adjacencyList.entries.forEach { graph.addNode(it.node) }
adjacencyList.entries.forEach { (node, links) ->
@@ -172,4 +177,4 @@ class Graph {
return graph
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
index a2cba95d9..71a31dcca 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BluePrintModel.kt
@@ -31,6 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
* @author Brinda Santh
*/
open class EntityType {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -48,6 +49,7 @@ open class EntityType {
authorization credentials used to access network accessible resources.
*/
class Credential {
+
@get:JsonIgnore
var id: String? = null
var protocol: String? = null
@@ -63,6 +65,7 @@ class Credential {
A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities.
*/
class ConstraintClause {
+
var equal: JsonNode? = null
@get:JsonProperty("greater_than")
var greaterThan: JsonNode? = null
@@ -101,6 +104,7 @@ class NodeFilterDefinition {
and implementation artifacts that are referenced within the TOSCA Service Template.
*/
class RepositoryDefinition {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -108,13 +112,13 @@ class RepositoryDefinition {
var credential: Credential? = null
}
-
/*
3.5.6 Artifact definition
An artifact definition defines a named, typed file that can be associated with Node Type
or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations.
*/
class ArtifactDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var type: String
@@ -126,7 +130,6 @@ class ArtifactDefinition {
var properties: MutableMap<String, JsonNode>? = null
}
-
/*
3.5.7 Import definition
An import definition is used within a TOSCA Service Template to locate and uniquely name
@@ -134,6 +137,7 @@ another TOSCA Service Template file which has type and template definitions to b
and referenced within another Service Template.
*/
class ImportDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var file: String
@@ -151,6 +155,7 @@ Properties are used by template authors to provide input values to TOSCA entitie
instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates.
*/
class PropertyDefinition {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -170,7 +175,6 @@ class PropertyDefinition {
var value: JsonNode? = null
}
-
/*
3.5.10 Attribute definition
@@ -203,6 +207,7 @@ class AttributeDefinition {
An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script).
*/
class OperationDefinition {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -216,7 +221,7 @@ class Implementation {
var dependencies: MutableList<String>? = null
@get:JsonProperty("operation_host")
var operationHost: String = BluePrintConstants.PROPERTY_SELF
- //Timeout value in seconds
+ // Timeout value in seconds
var timeout: Int = 180
}
@@ -225,6 +230,7 @@ class Implementation {
An interface definition defines a named interface that can be associated with a Node or Relationship Type
*/
class InterfaceDefinition {
+
@get:JsonIgnore
var id: String? = null
var type: String? = null
@@ -237,6 +243,7 @@ class InterfaceDefinition {
An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities.
*/
class EventFilterDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var node: String
@@ -249,6 +256,7 @@ class EventFilterDefinition {
A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with.
*/
class TriggerDefinition {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -271,6 +279,7 @@ class TriggerDefinition {
· Inline another workflow defined in the topology (to allow reusability)
*/
class Activity {
+
var delegate: String? = null
@get:JsonProperty("set_state")
var setState: String? = null
@@ -284,6 +293,7 @@ class Activity {
A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered.
*/
class PreConditionDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var target: String
@@ -297,6 +307,7 @@ class PreConditionDefinition {
A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow.
*/
class Step {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -333,6 +344,7 @@ class CapabilityDefinition {
The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity. The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly).
*/
class RequirementDefinition {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -347,11 +359,11 @@ class RequirementDefinition {
An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations.
*/
class ArtifactType : EntityType() {
+
@get:JsonProperty("mime_type")
var mimeType: String? = null
@get:JsonProperty("file_ext")
var fileExt: MutableList<String>? = null
-
}
/*
@@ -415,7 +427,6 @@ class GroupType : EntityType() {
var requirements: ArrayList<RequirementDefinition>? = null
var capabilities: MutableMap<String, CapabilityDefinition>? = null
var interfaces: MutableMap<String, InterfaceDefinition>? = null
-
}
/*
@@ -425,6 +436,7 @@ class GroupType : EntityType() {
(i.e., it does not prevent the application or service from being deployed or run if it did not exist).
*/
class PolicyType : EntityType() {
+
lateinit var targets: MutableList<String>
}
@@ -433,6 +445,7 @@ class PolicyType : EntityType() {
A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition.
*/
class CapabilityAssignment {
+
@get:JsonIgnore
var id: String? = null
var attributes: MutableMap<String, JsonNode>? = null
@@ -444,6 +457,7 @@ class CapabilityAssignment {
A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations.
*/
class GroupDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var type: String
@@ -459,6 +473,7 @@ class GroupDefinition {
A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.).
*/
class PolicyDefinition {
+
@get:JsonIgnore
var id: String? = null
lateinit var type: String
@@ -468,12 +483,12 @@ class PolicyDefinition {
var targets: MutableList<String>? = null
}
-
/*
3.8 Topology Template definition
This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively. Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates.
*/
class TopologyTemplate {
+
@get:JsonIgnore
var id: String? = null
var description: String? = null
@@ -520,7 +535,7 @@ open class NodeTemplate {
lateinit var type: String
var metadata: MutableMap<String, String>? = null
var directives: MutableList<String>? = null
- //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
+ // @get:JsonSerialize(using = PropertyDefinitionValueSerializer::class)
var properties: MutableMap<String, JsonNode>? = null
var attributes: MutableMap<String, JsonNode>? = null
var capabilities: MutableMap<String, CapabilityAssignment>? = null
@@ -566,11 +581,10 @@ class RequirementAssignment {
var id: String? = null
var capability: String? = null
var node: String? = null
- //Relationship Type or Relationship Template
+ // Relationship Type or Relationship Template
var relationship: String? = null
}
-
class Workflow {
@get:JsonIgnore
var id: String? = null
@@ -581,7 +595,6 @@ class Workflow {
var outputs: MutableMap<String, PropertyDefinition>? = null
}
-
class ConditionClause {
var and: ArrayList<MutableMap<String, Any>>? = null
var or: ArrayList<MutableMap<String, Any>>? = null
@@ -594,9 +607,12 @@ class ConditionClause {
A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.
*/
-@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
- "topologyTemplate"])
+@JsonPropertyOrder(
+ value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
+ "topologyTemplate"]
+)
class ServiceTemplate : Cloneable {
+
@get:JsonIgnore
var id: String? = null
@get:JsonProperty("tosca_definitions_version")
@@ -620,7 +636,7 @@ class ServiceTemplate : Cloneable {
@get:JsonProperty("topology_template")
var topologyTemplate: TopologyTemplate? = null
- override public fun clone(): ServiceTemplate {
+ public override fun clone(): ServiceTemplate {
return super.clone() as ServiceTemplate
}
}
@@ -634,4 +650,3 @@ class ToscaMetaData {
var templateVersion: String? = null
var templateTags: String? = null
}
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintErrorCode.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt
index 51d088ee1..8bdedd429 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/BlueprintErrorCode.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/data/ErrorCode.kt
@@ -23,11 +23,12 @@ import java.util.HashMap
* @author Steve Siani
* @version 1.0
*/
-enum class ErrorCode (val value: Int, val httpCode: Int) {
+enum class ErrorCode(val value: Int, val httpCode: Int) {
- /// TODO: Add more attribute for each needed application protocol
+ // / TODO: Add more attribute for each needed application protocol
// TODO: Example: INVALID_FILE_EXTENSION(2, 415, 25)
GENERIC_FAILURE(1, 500) {
+
override fun message(detailMsg: String): String {
return "Generic failure. Details : {$detailMsg}"
}
@@ -99,4 +100,4 @@ enum class ErrorCode (val value: Int, val httpCode: Int) {
return if (map.containsKey(value)) map[value] else map[1]
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt
index 182d9a050..13e9f0e5a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/AbstractNodeTemplateOperationImplBuilder.kt
@@ -18,8 +18,11 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
abstract class AbstractNodeTemplateOperationImplBuilder<Prop : PropertiesAssignmentBuilder,
In : PropertiesAssignmentBuilder, Out : PropertiesAssignmentBuilder>(
- id: String, type: String, private val interfaceName: String, description: String
-) : AbstractNodeTemplatePropertyImplBuilder<Prop>(id, type, description) {
+ id: String,
+ type: String,
+ private val interfaceName: String,
+ description: String
+ ) : AbstractNodeTemplatePropertyImplBuilder<Prop>(id, type, description) {
open fun definedOperation(description: String, block: OperationAssignmentBuilder<In, Out>.() -> Unit) {
typedOperation<In, Out>(interfaceName, description, block)
@@ -27,7 +30,9 @@ abstract class AbstractNodeTemplateOperationImplBuilder<Prop : PropertiesAssignm
}
abstract class AbstractNodeTemplatePropertyImplBuilder<Prop : PropertiesAssignmentBuilder>(
- id: String, type: String, description: String
+ id: String,
+ type: String,
+ description: String
) : NodeTemplateBuilder(id, type, description) {
open fun definedProperties(block: Prop.() -> Unit) {
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
index 01c6a13be..9964687a6 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSL.kt
@@ -20,47 +20,87 @@ import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
// CDS DSLs
-fun blueprint(name: String, version: String, author: String, tags: String,
- block: DSLBluePrintBuilder.() -> Unit): DSLBluePrint {
+fun blueprint(
+ name: String,
+ version: String,
+ author: String,
+ tags: String,
+ block: DSLBluePrintBuilder.() -> Unit
+): DSLBluePrint {
return DSLBluePrintBuilder(name, version, author, tags).apply(block).build()
}
// TOSCA DSLs
-fun serviceTemplate(name: String, version: String, author: String, tags: String,
- block: ServiceTemplateBuilder.() -> Unit): ServiceTemplate {
- return ServiceTemplateBuilder(name, version, author, tags).apply(block).build()
+fun serviceTemplate(
+ name: String,
+ version: String,
+ author: String,
+ tags: String,
+ block: BluePrintServiceDSLBuilder.() -> Unit
+): ServiceTemplate {
+ return BluePrintServiceDSLBuilder(name, version, author, tags).apply(block).build()
}
fun workflow(id: String, description: String, block: WorkflowBuilder.() -> Unit): Workflow {
return WorkflowBuilder(id, description).apply(block).build()
}
-fun nodeTemplate(id: String, type: String, description: String,
- block: NodeTemplateBuilder.() -> Unit): NodeTemplate {
+fun nodeTemplate(
+ id: String,
+ type: String,
+ description: String,
+ block: NodeTemplateBuilder.() -> Unit
+): NodeTemplate {
return NodeTemplateBuilder(id, type, description).apply(block).build()
}
-fun nodeType(id: String, version: String, derivedFrom: String, description: String,
- block: NodeTypeBuilder.() -> Unit): NodeType {
+fun nodeType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: NodeTypeBuilder.() -> Unit
+): NodeType {
return NodeTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
-fun dataType(id: String, version: String, derivedFrom: String, description: String,
- block: DataTypeBuilder.() -> Unit): DataType {
+fun dataType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: DataTypeBuilder.() -> Unit
+): DataType {
return DataTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
-fun artifactType(id: String, version: String, derivedFrom: String, description: String,
- block: ArtifactTypeBuilder.() -> Unit): ArtifactType {
+fun artifactType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: ArtifactTypeBuilder.() -> Unit
+): ArtifactType {
return ArtifactTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
-fun relationshipType(id: String, version: String, derivedFrom: String, description: String,
- block: RelationshipTypeBuilder.() -> Unit): RelationshipType {
+fun relationshipType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: RelationshipTypeBuilder.() -> Unit
+): RelationshipType {
return RelationshipTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
@@ -120,106 +160,132 @@ fun getNodeTemplateArtifact(nodeTemplateName: String, artifactId: String): JsonN
// Operation Function
-fun getNodeTemplateOperationOutput(nodeTemplateName: String, interfaceName: String, propertyId: String,
- jsonPath: String? = null): JsonNode {
+fun getNodeTemplateOperationOutput(
+ nodeTemplateName: String,
+ interfaceName: String,
+ propertyId: String,
+ jsonPath: String? = null
+): JsonNode {
return """{"get_operation_output": ["$nodeTemplateName", "$interfaceName", "process","$propertyId","$jsonPath" ]}""".trimMargin().jsonAsJsonType()
}
/** Blueprint Type Extensions */
fun BluePrintTypes.nodeTypeComponent(): NodeType {
- return nodeType(id = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
- description = "This is default Component Node") {
+ return nodeType(
+ id = BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
+ description = "This is default Component Node"
+ ) {
}
}
fun BluePrintTypes.nodeTypeWorkflow(): NodeType {
- return nodeType(id = BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
- description = "This is default Workflow Node") {
+ return nodeType(
+ id = BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
+ description = "This is default Workflow Node"
+ ) {
}
}
fun BluePrintTypes.nodeTypeVnf(): NodeType {
- return nodeType(id = BluePrintConstants.MODEL_TYPE_NODE_VNF,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
- description = "This is default VNF Node") {
+ return nodeType(
+ id = BluePrintConstants.MODEL_TYPE_NODE_VNF,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
+ description = "This is default VNF Node"
+ ) {
}
}
fun BluePrintTypes.nodeTypeResourceSource(): NodeType {
- return nodeType(id = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
- description = "This is default Resource Source Node") {
+ return nodeType(
+ id = BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_NODES_ROOT,
+ description = "This is default Resource Source Node"
+ ) {
}
}
/** Artifacts */
fun BluePrintTypes.artifactTypeTemplateVelocity(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Velocity Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_VELOCITY,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Velocity Artifact"
+ ) {
fileExt("vtl")
}
}
fun BluePrintTypes.artifactTypeTempleJinja(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Jinja Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_TEMPLATE_JINJA,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Jinja Artifact"
+ ) {
fileExt("jinja")
}
}
fun BluePrintTypes.artifactTypeMappingResource(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Mapping Resource Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_MAPPING_RESOURCE,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Mapping Resource Artifact"
+ ) {
fileExt("json")
}
}
fun BluePrintTypes.artifactTypeScriptJython(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_JYTHON,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Jython Script Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_JYTHON,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Jython Script Artifact"
+ ) {
fileExt("py")
}
}
fun BluePrintTypes.artifactTypeScriptKotlin(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Kotlin Script Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_SCRIPT_KOTLIN,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Kotlin Script Artifact"
+ ) {
fileExt("kts")
}
}
fun BluePrintTypes.artifactTypeDirectedGraph(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_DIRECTED_GRAPH,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Directed Graph Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_DIRECTED_GRAPH,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Directed Graph Artifact"
+ ) {
fileExt("xml", "json")
}
}
fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
- return artifactType(id = BluePrintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
- description = "Component Artifact") {
+ return artifactType(
+ id = BluePrintConstants.MODEL_TYPE_ARTIFACT_COMPONENT_JAR,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION,
+ description = "Component Artifact"
+ ) {
fileExt("jar")
}
}
@@ -227,17 +293,21 @@ fun BluePrintTypes.artifactTypeComponentJar(): ArtifactType {
/** Relationship Types */
fun BluePrintTypes.relationshipTypeConnectsTo(): RelationshipType {
- return relationshipType(id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
- description = "Relationship connects to") {
+ return relationshipType(
+ id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
+ description = "Relationship connects to"
+ ) {
}
}
fun BluePrintTypes.relationshipTypeDependsOn(): RelationshipType {
- return relationshipType(id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
- version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
- derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
- description = "Relationship depends on") {
+ return relationshipType(
+ id = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON,
+ version = BluePrintConstants.DEFAULT_VERSION_NUMBER,
+ derivedFrom = BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
+ description = "Relationship depends on"
+ ) {
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt
index d46d478a8..f2e964a1d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLBuilder.kt
@@ -19,15 +19,23 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Step
/**
* @author Brinda Santh
*/
-class DSLBluePrintBuilder(private val name: String,
- private val version: String,
- private val author: String,
- private val tags: String) {
+class DSLBluePrintBuilder(
+ private val name: String,
+ private val version: String,
+ private val author: String,
+ private val tags: String
+) {
private var dslBluePrint = DSLBluePrint()
private var metadata: MutableMap<String, String> = hashMapOf()
@@ -59,8 +67,13 @@ class DSLBluePrintBuilder(private val name: String,
dataTypes[dataType.id!!] = dataType
}
- fun dataType(id: String, version: String, derivedFrom: String, description: String,
- block: DataTypeBuilder.() -> Unit) {
+ fun dataType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: DataTypeBuilder.() -> Unit
+ ) {
dataTypes[id] = DataTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
@@ -68,20 +81,36 @@ class DSLBluePrintBuilder(private val name: String,
artifactTypes[artifactType.id!!] = artifactType
}
- fun artifactType(id: String, version: String, derivedFrom: String, description: String,
- block: ArtifactTypeBuilder.() -> Unit) {
+ fun artifactType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: ArtifactTypeBuilder.() -> Unit
+ ) {
artifactTypes[id] = ArtifactTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
- fun component(id: String, type: String, version: String, description: String,
- block: DSLComponentBuilder.() -> Unit) {
+ fun component(
+ id: String,
+ type: String,
+ version: String,
+ description: String,
+ block: DSLComponentBuilder.() -> Unit
+ ) {
components[id] = DSLComponentBuilder(id, type, version, description).apply(block).build()
}
- fun registryComponent(id: String, type: String, version: String, interfaceName: String, description: String,
- block: DSLRegistryComponentBuilder.() -> Unit) {
+ fun registryComponent(
+ id: String,
+ type: String,
+ version: String,
+ interfaceName: String,
+ description: String,
+ block: DSLRegistryComponentBuilder.() -> Unit
+ ) {
registryComponents[id] = DSLRegistryComponentBuilder(id, type, version, interfaceName, description)
- .apply(block).build()
+ .apply(block).build()
}
fun workflow(id: String, description: String, block: DSLWorkflowBuilder.() -> Unit) {
@@ -101,8 +130,13 @@ class DSLBluePrintBuilder(private val name: String,
}
}
-class DSLComponentBuilder(private val id: String, private val type: String,
- private val version: String, private val description: String) {
+class DSLComponentBuilder(
+ private val id: String,
+ private val type: String,
+ private val version: String,
+ private val description: String
+) {
+
private val dslComponent = DSLComponent()
var properties: MutableMap<String, PropertyDefinition>? = null
var attributes: MutableMap<String, AttributeDefinition>? = null
@@ -119,12 +153,18 @@ class DSLComponentBuilder(private val id: String, private val type: String,
attributes!![id] = attribute
}
- fun attribute(id: String, type: String, required: Boolean, expression: Any, description: String? = "",
- block: DSLAttributeDefinitionBuilder.() -> Unit) {
+ fun attribute(
+ id: String,
+ type: String,
+ required: Boolean,
+ expression: Any,
+ description: String? = "",
+ block: DSLAttributeDefinitionBuilder.() -> Unit
+ ) {
if (attributes == null)
attributes = hashMapOf()
val attribute = DSLAttributeDefinitionBuilder(id, type, required, expression.asJsonType(), description)
- .apply(block).build()
+ .apply(block).build()
attributes!![id] = attribute
}
@@ -135,12 +175,18 @@ class DSLComponentBuilder(private val id: String, private val type: String,
properties!![id] = property
}
- fun property(id: String, type: String, required: Boolean, expression: Any, description: String? = "",
- block: DSLPropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ id: String,
+ type: String,
+ required: Boolean,
+ expression: Any,
+ description: String? = "",
+ block: DSLPropertyDefinitionBuilder.() -> Unit
+ ) {
if (properties == null)
properties = hashMapOf()
val property = DSLPropertyDefinitionBuilder(id, type, required, expression.asJsonType(), description)
- .apply(block).build()
+ .apply(block).build()
properties!![id] = property
}
@@ -163,7 +209,6 @@ class DSLComponentBuilder(private val id: String, private val type: String,
artifacts!![id] = ArtifactDefinitionBuilder(id, type, file).apply(block).build()
}
-
fun input(id: String, type: String, required: Boolean, expression: Any, description: String? = "") {
if (inputs == null)
inputs = hashMapOf()
@@ -171,12 +216,18 @@ class DSLComponentBuilder(private val id: String, private val type: String,
inputs!![id] = property.build()
}
- fun input(id: String, type: String, required: Boolean, expression: Any, description: String? = "",
- block: DSLPropertyDefinitionBuilder.() -> Unit) {
+ fun input(
+ id: String,
+ type: String,
+ required: Boolean,
+ expression: Any,
+ description: String? = "",
+ block: DSLPropertyDefinitionBuilder.() -> Unit
+ ) {
if (inputs == null)
inputs = hashMapOf()
val property = DSLPropertyDefinitionBuilder(id, type, required, expression.asJsonType(), description)
- .apply(block).build()
+ .apply(block).build()
inputs!![id] = property
}
@@ -187,12 +238,18 @@ class DSLComponentBuilder(private val id: String, private val type: String,
outputs!![id] = property.build()
}
- fun output(id: String, type: String, required: Boolean, expression: Any, description: String? = "",
- block: DSLPropertyDefinitionBuilder.() -> Unit) {
+ fun output(
+ id: String,
+ type: String,
+ required: Boolean,
+ expression: Any,
+ description: String? = "",
+ block: DSLPropertyDefinitionBuilder.() -> Unit
+ ) {
if (outputs == null)
outputs = hashMapOf()
val property = DSLPropertyDefinitionBuilder(id, type, required, expression.asJsonType(), description)
- .apply(block).build()
+ .apply(block).build()
outputs!![id] = property
}
@@ -212,10 +269,14 @@ class DSLComponentBuilder(private val id: String, private val type: String,
}
}
-class DSLRegistryComponentBuilder(private val id: String, private val type: String,
- private val version: String,
- private val interfaceName: String,
- private val description: String) {
+class DSLRegistryComponentBuilder(
+ private val id: String,
+ private val type: String,
+ private val version: String,
+ private val interfaceName: String,
+ private val description: String
+) {
+
private val dslComponent = DSLRegistryComponent()
var properties: MutableMap<String, JsonNode>? = null
@@ -289,8 +350,14 @@ class DSLWorkflowBuilder(private val actionName: String, private val description
inputs!![id] = property.build()
}
- fun input(id: String, type: String, required: Boolean, description: String, defaultValue: Any?,
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun input(
+ id: String,
+ type: String,
+ required: Boolean,
+ description: String,
+ defaultValue: Any?,
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
if (inputs == null)
inputs = hashMapOf()
val property = PropertyDefinitionBuilder(id, type, required, description).apply(block).build()
@@ -306,12 +373,18 @@ class DSLWorkflowBuilder(private val actionName: String, private val description
outputs!![id] = property.build()
}
- fun output(id: String, type: String, required: Boolean, expression: Any, description: String? = "",
- block: DSLPropertyDefinitionBuilder.() -> Unit) {
+ fun output(
+ id: String,
+ type: String,
+ required: Boolean,
+ expression: Any,
+ description: String? = "",
+ block: DSLPropertyDefinitionBuilder.() -> Unit
+ ) {
if (outputs == null)
outputs = hashMapOf()
val property = DSLPropertyDefinitionBuilder(id, type, required, expression.asJsonType(), description)
- .apply(block).build()
+ .apply(block).build()
outputs!![id] = property
}
@@ -337,11 +410,13 @@ class DSLWorkflowBuilder(private val actionName: String, private val description
}
}
-class DSLAttributeDefinitionBuilder(private val id: String,
- private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
- private val required: Boolean? = false,
- private val expression: JsonNode,
- private val description: String? = "") {
+class DSLAttributeDefinitionBuilder(
+ private val id: String,
+ private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
+ private val required: Boolean? = false,
+ private val expression: JsonNode,
+ private val description: String? = ""
+) {
private var attributeDefinition = AttributeDefinition()
@@ -368,11 +443,13 @@ class DSLAttributeDefinitionBuilder(private val id: String,
}
}
-class DSLPropertyDefinitionBuilder(private val id: String,
- private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
- private val required: Boolean? = false,
- private val expression: JsonNode,
- private val description: String? = "") {
+class DSLPropertyDefinitionBuilder(
+ private val id: String,
+ private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
+ private val required: Boolean? = false,
+ private val expression: JsonNode,
+ private val description: String? = ""
+) {
private var propertyDefinition: PropertyDefinition = PropertyDefinition()
@@ -397,4 +474,4 @@ class DSLPropertyDefinitionBuilder(private val id: String,
propertyDefinition.description = description
return propertyDefinition
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt
index 61b52a6f9..8b5c4151a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintDSLData.kt
@@ -18,7 +18,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.databind.JsonNode
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Step
/**
* This is simplified version of DSL, which is used for generating the Service template
@@ -26,6 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.*
*/
class DSLBluePrint {
+
var metadata: MutableMap<String, String> = hashMapOf()
var properties: MutableMap<String, JsonNode>? = null
var dataTypes: MutableMap<String, DataType> = hashMapOf()
@@ -59,7 +66,6 @@ class DSLComponent {
var outputs: MutableMap<String, PropertyDefinition>? = null
}
-
class DSLRegistryComponent {
lateinit var id: String
lateinit var type: String
@@ -71,4 +77,4 @@ class DSLRegistryComponent {
var artifacts: MutableMap<String, ArtifactDefinition>? = null
var inputs: MutableMap<String, JsonNode>? = null
var outputs: MutableMap<String, JsonNode>? = null
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt
index 259efbf0b..ca4d56338 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceDSLBuilder.kt
@@ -17,14 +17,28 @@
package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.databind.JsonNode
-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.asBluePrintsDataTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.asPropertyDefinitionMap
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
import kotlin.reflect.KClass
-class ServiceTemplateBuilder(private val name: String,
- private val version: String,
- private val author: String,
- private val tags: String) {
+class BluePrintServiceDSLBuilder(
+ private val name: String,
+ private val version: String,
+ private val author: String,
+ private val tags: String
+) {
+
private var serviceTemplate = ServiceTemplate()
private var topologyTemplate: TopologyTemplate? = null
private var metadata: MutableMap<String, String> = hashMapOf()
@@ -138,36 +152,61 @@ class ServiceTemplateBuilder(private val name: String,
nodeTypes!![nodeType.id!!] = nodeType
}
- fun dataType(id: String, version: String, derivedFrom: String, description: String,
- block: DataTypeBuilder.() -> Unit) {
+ fun dataType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: DataTypeBuilder.() -> Unit
+ ) {
if (dataTypes == null)
dataTypes = hashMapOf()
dataTypes!![id] = DataTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
- fun artifactType(id: String, version: String, derivedFrom: String, description: String,
- block: ArtifactTypeBuilder.() -> Unit) {
+ fun artifactType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: ArtifactTypeBuilder.() -> Unit
+ ) {
if (artifactTypes == null)
artifactTypes = hashMapOf()
artifactTypes!![id] = ArtifactTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
- fun relationshipType(id: String, version: String, derivedFrom: String, description: String,
- block: RelationshipTypeBuilder.() -> Unit) {
+ fun relationshipType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: RelationshipTypeBuilder.() -> Unit
+ ) {
if (relationshipTypes == null)
relationshipTypes = hashMapOf()
relationshipTypes!![id] = RelationshipTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
- fun policyType(id: String, version: String, derivedFrom: String, description: String,
- block: PolicyTypeBuilder.() -> Unit) {
+ fun policyType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: PolicyTypeBuilder.() -> Unit
+ ) {
if (policyTypes == null)
policyTypes = hashMapOf()
policyTypes!![id] = PolicyTypeBuilder(id, version, derivedFrom, description).apply(block).build()
}
- fun nodeType(id: String, version: String, derivedFrom: String, description: String,
- block: NodeTypeBuilder.() -> Unit) {
+ fun nodeType(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String,
+ block: NodeTypeBuilder.() -> Unit
+ ) {
if (nodeTypes == null)
nodeTypes = hashMapOf()
nodeTypes!![id] = NodeTypeBuilder(id, version, derivedFrom, description).apply(block).build()
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt
index a4a5e05ec..d07fc9c71 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintServiceTemplateGenerator.kt
@@ -20,7 +20,19 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.bpClone
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
/**
* Generate Service Template for the simplified DSL.
@@ -88,7 +100,6 @@ class BluePrintServiceTemplateGenerator(private val dslBluePrint: DSLBluePrint)
return nodeTemplates
}
-
private fun populateWorkflow(): MutableMap<String, Workflow>? {
var workflows: MutableMap<String, Workflow>? = null
if (dslBluePrint.workflows.isNotEmpty()) {
@@ -197,4 +208,4 @@ class BluePrintServiceTemplateGenerator(private val dslBluePrint: DSLBluePrint)
}
return assignments
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
index 7f49a99c6..df4d2d849 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTemplateDSLBuilder.kt
@@ -19,7 +19,15 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import kotlin.reflect.KClass
import kotlin.reflect.full.createInstance
import kotlin.reflect.jvm.reflect
@@ -41,9 +49,14 @@ class TopologyTemplateBuilder {
nodeTemplates!![nodeTemplate.id!!] = nodeTemplate
}
- fun nodeTemplateOperation(nodeTemplateName: String, type: String, interfaceName: String, description: String,
- operationBlock: OperationAssignmentBuilder<PropertiesAssignmentBuilder,
- PropertiesAssignmentBuilder>.() -> Unit) {
+ fun nodeTemplateOperation(
+ nodeTemplateName: String,
+ type: String,
+ interfaceName: String,
+ description: String,
+ operationBlock: OperationAssignmentBuilder<PropertiesAssignmentBuilder,
+ PropertiesAssignmentBuilder>.() -> Unit
+ ) {
if (nodeTemplates == null)
nodeTemplates = hashMapOf()
@@ -64,9 +77,13 @@ class TopologyTemplateBuilder {
workflows!![workflow.id!!] = workflow
}
- //TODO("populate inputs, outputs")
- fun workflowNodeTemplate(actionName: String,
- nodeTemplateType: String, description: String, block: NodeTemplateBuilder.() -> Unit) {
+ // TODO("populate inputs, outputs")
+ fun workflowNodeTemplate(
+ actionName: String,
+ nodeTemplateType: String,
+ description: String,
+ block: NodeTemplateBuilder.() -> Unit
+ ) {
if (nodeTemplates == null)
nodeTemplates = hashMapOf()
@@ -88,9 +105,12 @@ class TopologyTemplateBuilder {
}
}
-open class NodeTemplateBuilder(private val id: String,
- private val type: String,
- private val description: String? = "") {
+open class NodeTemplateBuilder(
+ private val id: String,
+ private val type: String,
+ private val description: String? = ""
+) {
+
private var nodeTemplate: NodeTemplate = NodeTemplate()
private var properties: MutableMap<String, JsonNode>? = null
private var interfaces: MutableMap<String, InterfaceAssignment>? = null
@@ -116,8 +136,10 @@ open class NodeTemplateBuilder(private val id: String,
}
open fun <In : PropertiesAssignmentBuilder, Out : PropertiesAssignmentBuilder> typedOperation(
- interfaceName: String, description: String = "",
- block: OperationAssignmentBuilder<In, Out>.() -> Unit) {
+ interfaceName: String,
+ description: String = "",
+ block: OperationAssignmentBuilder<In, Out>.() -> Unit
+ ) {
if (interfaces == null)
interfaces = hashMapOf()
@@ -125,12 +147,15 @@ open class NodeTemplateBuilder(private val id: String,
val defaultOperationName = BluePrintConstants.DEFAULT_STEP_OPERATION
interfaceAssignment.operations = hashMapOf()
interfaceAssignment.operations!![defaultOperationName] =
- OperationAssignmentBuilder<In, Out>(defaultOperationName, description).apply(block).build()
+ OperationAssignmentBuilder<In, Out>(defaultOperationName, description).apply(block).build()
interfaces!![interfaceName] = interfaceAssignment
}
- fun operation(interfaceName: String, description: String,
- block: OperationAssignmentBuilder<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>.() -> Unit) {
+ fun operation(
+ interfaceName: String,
+ description: String,
+ block: OperationAssignmentBuilder<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>.() -> Unit
+ ) {
typedOperation<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>(interfaceName, description, block)
}
@@ -235,9 +260,13 @@ open class CapabilityAssignmentBuilder(private val id: String) {
}
}
-open class RequirementAssignmentBuilder(private val id: String, private val capability: String,
- private val node: String,
- private val relationship: String) {
+open class RequirementAssignmentBuilder(
+ private val id: String,
+ private val capability: String,
+ private val node: String,
+ private val relationship: String
+) {
+
private var requirementAssignment: RequirementAssignment = RequirementAssignment()
fun build(): RequirementAssignment {
@@ -254,12 +283,16 @@ class InterfaceAssignmentBuilder(private val id: String) {
private var interfaceAssignment: InterfaceAssignment = InterfaceAssignment()
private var operations: MutableMap<String, OperationAssignment>? = null
- fun operation(id: String, description: String? = "",
- block: OperationAssignmentBuilder<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>.() -> Unit) {
+ fun operation(
+ id: String,
+ description: String? = "",
+ block: OperationAssignmentBuilder<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>.() -> Unit
+ ) {
if (operations == null)
operations = hashMapOf()
operations!![id] = OperationAssignmentBuilder<PropertiesAssignmentBuilder, PropertiesAssignmentBuilder>(
- id, description).apply(block).build()
+ id, description
+ ).apply(block).build()
}
fun build(): InterfaceAssignment {
@@ -270,8 +303,9 @@ class InterfaceAssignmentBuilder(private val id: String) {
}
class OperationAssignmentBuilder<In : PropertiesAssignmentBuilder, Out : PropertiesAssignmentBuilder>(
- private val id: String,
- private val description: String? = "") {
+ private val id: String,
+ private val description: String? = ""
+) {
private var operationAssignment: OperationAssignment = OperationAssignment()
@@ -286,8 +320,11 @@ class OperationAssignmentBuilder<In : PropertiesAssignmentBuilder, Out : Propert
}
}
- fun implementation(timeout: Int, operationHost: String? = BluePrintConstants.PROPERTY_SELF,
- block: ImplementationBuilder.() -> Unit) {
+ fun implementation(
+ timeout: Int,
+ operationHost: String? = BluePrintConstants.PROPERTY_SELF,
+ block: ImplementationBuilder.() -> Unit
+ ) {
operationAssignment.implementation = ImplementationBuilder(timeout, operationHost!!).apply(block).build()
}
@@ -368,4 +405,4 @@ open class AttributesAssignmentBuilder {
fun build(): MutableMap<String, JsonNode> {
return attributes
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt
index 8d96e7110..e183b8090 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintTypeDSLBuilder.kt
@@ -18,14 +18,34 @@ package org.onap.ccsdk.cds.controllerblueprints.core.dsl
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
-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.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
+import org.onap.ccsdk.cds.controllerblueprints.core.asListOfString
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ConstraintClause
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.EntityType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
+
+open class EntityTypeBuilder(
+ private val id: String,
+ private val version: String,
+ private val derivedFrom: String,
+ private val description: String? = ""
+) {
-
-open class EntityTypeBuilder(private val id: String,
- private val version: String,
- private val derivedFrom: String,
- private val description: String? = "") {
var metadata: MutableMap<String, String>? = null
var properties: MutableMap<String, PropertyDefinition>? = null
var attributes: MutableMap<String, AttributeDefinition>? = null
@@ -43,8 +63,13 @@ open class EntityTypeBuilder(private val id: String,
attributes!![id] = attribute
}
- fun attribute(id: String, type: String, required: Boolean, description: String? = "",
- block: AttributeDefinitionBuilder.() -> Unit) {
+ fun attribute(
+ id: String,
+ type: String,
+ required: Boolean,
+ description: String? = "",
+ block: AttributeDefinitionBuilder.() -> Unit
+ ) {
if (attributes == null)
attributes = hashMapOf()
val attribute = AttributeDefinitionBuilder(id, type, required, description).apply(block).build()
@@ -58,8 +83,13 @@ open class EntityTypeBuilder(private val id: String,
properties!![id] = property
}
- fun property(id: String, type: String, required: Boolean, description: String? = "",
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ id: String,
+ type: String,
+ required: Boolean,
+ description: String? = "",
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
if (properties == null)
properties = hashMapOf()
val property = PropertyDefinitionBuilder(id, type, required, description).apply(block).build()
@@ -77,8 +107,13 @@ open class EntityTypeBuilder(private val id: String,
}
}
-class NodeTypeBuilder(id: String, version: String, derivedFrom: String,
- description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
+class NodeTypeBuilder(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String?
+) : EntityTypeBuilder(id, version, derivedFrom, description) {
+
private var nodeType = NodeType()
private var capabilities: MutableMap<String, CapabilityDefinition>? = null
private var requirements: MutableMap<String, RequirementDefinition>? = null
@@ -97,12 +132,18 @@ class NodeTypeBuilder(id: String, version: String, derivedFrom: String,
requirements!![id] = RequirementDefinitionBuilder(id, capability, node, relationship, description).build()
}
- fun requirement(id: String, capability: String, node: String, relationship: String, description: String,
- block: RequirementDefinitionBuilder.() -> Unit) {
+ fun requirement(
+ id: String,
+ capability: String,
+ node: String,
+ relationship: String,
+ description: String,
+ block: RequirementDefinitionBuilder.() -> Unit
+ ) {
if (requirements == null)
requirements = hashMapOf()
requirements!![id] = RequirementDefinitionBuilder(id, capability, node, relationship, description)
- .apply(block).build()
+ .apply(block).build()
}
fun artifact(id: String, type: String, file: String) {
@@ -125,7 +166,7 @@ class NodeTypeBuilder(id: String, version: String, derivedFrom: String,
val defaultOperationName = "process"
interfaceDefinition.operations = hashMapOf()
interfaceDefinition.operations!![defaultOperationName] =
- OperationDefinitionBuilder(defaultOperationName, description).apply(block).build()
+ OperationDefinitionBuilder(defaultOperationName, description).apply(block).build()
interfaces!![interfaceName] = interfaceDefinition
}
@@ -139,8 +180,13 @@ class NodeTypeBuilder(id: String, version: String, derivedFrom: String,
}
}
-class ArtifactTypeBuilder(id: String, version: String, derivedFrom: String,
- description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
+class ArtifactTypeBuilder(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String?
+) : EntityTypeBuilder(id, version, derivedFrom, description) {
+
private var artifactType = ArtifactType()
private var fileExt: MutableList<String>? = null
@@ -159,8 +205,13 @@ class ArtifactTypeBuilder(id: String, version: String, derivedFrom: String,
}
}
-class PolicyTypeBuilder(id: String, version: String, derivedFrom: String,
- description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
+class PolicyTypeBuilder(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String?
+) : EntityTypeBuilder(id, version, derivedFrom, description) {
+
private var policyType = PolicyType()
fun targets(targetsStr: String) {
@@ -178,9 +229,13 @@ class PolicyTypeBuilder(id: String, version: String, derivedFrom: String,
}
}
-class RelationshipTypeBuilder(private val id: String, private val version: String,
- derivedFrom: String, private val description: String?)
- : EntityTypeBuilder(id, version, derivedFrom, description) {
+class RelationshipTypeBuilder(
+ private val id: String,
+ private val version: String,
+ derivedFrom: String,
+ private val description: String?
+) :
+ EntityTypeBuilder(id, version, derivedFrom, description) {
private var relationshipType = RelationshipType()
@@ -202,8 +257,13 @@ class RelationshipTypeBuilder(private val id: String, private val version: Strin
}
}
-class DataTypeBuilder(id: String, version: String, derivedFrom: String,
- description: String?) : EntityTypeBuilder(id, version, derivedFrom, description) {
+class DataTypeBuilder(
+ id: String,
+ version: String,
+ derivedFrom: String,
+ description: String?
+) : EntityTypeBuilder(id, version, derivedFrom, description) {
+
private var dataType = DataType()
fun constrain(block: ConstraintClauseBuilder.() -> Unit) {
@@ -239,8 +299,14 @@ class CapabilityDefinitionBuilder(private val id: String, private val type: Stri
}
}
-class RequirementDefinitionBuilder(private val id: String, private val capability: String, private val node: String,
- private val relationship: String, private val description: String? = "") {
+class RequirementDefinitionBuilder(
+ private val id: String,
+ private val capability: String,
+ private val node: String,
+ private val relationship: String,
+ private val description: String? = ""
+) {
+
private var requirementDefinition = RequirementDefinition()
fun build(): RequirementDefinition {
@@ -271,8 +337,11 @@ class InterfaceDefinitionBuilder(private val id: String) {
}
}
-class OperationDefinitionBuilder(private val id: String,
- private val description: String? = "") {
+class OperationDefinitionBuilder(
+ private val id: String,
+ private val description: String? = ""
+) {
+
private var operationDefinition: OperationDefinition = OperationDefinition()
fun inputs(block: PropertiesDefinitionBuilder.() -> Unit) {
@@ -290,10 +359,12 @@ class OperationDefinitionBuilder(private val id: String,
}
}
-class AttributeDefinitionBuilder(private val id: String,
- private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
- private val required: Boolean? = false,
- private val description: String? = "") {
+class AttributeDefinitionBuilder(
+ private val id: String,
+ private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
+ private val required: Boolean? = false,
+ private val description: String? = ""
+) {
private var attributeDefinition: AttributeDefinition = AttributeDefinition()
@@ -342,8 +413,13 @@ class PropertiesDefinitionBuilder {
properties[id] = property
}
- fun property(id: String, type: String?, required: Boolean?, description: String? = "",
- block: PropertyDefinitionBuilder.() -> Unit) {
+ fun property(
+ id: String,
+ type: String?,
+ required: Boolean?,
+ description: String? = "",
+ block: PropertyDefinitionBuilder.() -> Unit
+ ) {
val property = PropertyDefinitionBuilder(id, type, required, description).apply(block).build()
properties[id] = property
}
@@ -353,10 +429,12 @@ class PropertiesDefinitionBuilder {
}
}
-class PropertyDefinitionBuilder(private val id: String,
- private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
- private val required: Boolean? = false,
- private val description: String? = "") {
+class PropertyDefinitionBuilder(
+ private val id: String,
+ private val type: String? = BluePrintConstants.DATA_TYPE_STRING,
+ private val required: Boolean? = false,
+ private val description: String? = ""
+) {
private var propertyDefinition: PropertyDefinition = PropertyDefinition()
@@ -485,7 +563,6 @@ class ConstraintClauseBuilder {
}
}
-
class EntrySchemaBuilder(private val type: String) {
private var entrySchema: EntrySchema = EntrySchema()
@@ -501,4 +578,4 @@ class EntrySchemaBuilder(private val type: String) {
entrySchema.type = type
return entrySchema
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt
index 6d46ac7ad..8a1a9d63c 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/dsl/BluePrintWorkflowDSLBuilder.kt
@@ -72,11 +72,13 @@ class WorkflowBuilder(private val id: String, private val description: String) {
workflow.outputs = outputs
return workflow
}
-
}
-class StepBuilder(private val id: String, private val target: String,
- private val description: String) {
+class StepBuilder(
+ private val id: String,
+ private val target: String,
+ private val description: String
+) {
private var step = Step()
private var activities: ArrayList<Activity> = arrayListOf()
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
index 9b4f6b56e..bd45bed06 100755
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
@@ -54,4 +54,4 @@ interface BluePrintCatalogService {
@Throws(BluePrintException::class)
suspend fun deleteFromDatabase(name: String, version: String)
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt
index 8267e5dcc..fcc9bf2d7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintDefinitions.kt
@@ -57,5 +57,4 @@ abstract class AbstractBluePrintDefinitions : BluePrintDefinitions {
override fun otherDefinitions(): MutableMap<String, Any> {
return otherDefinitionMap
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
index d0b5ea743..80c91ca28 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintEnhancer.kt
@@ -18,7 +18,15 @@
package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
@@ -44,7 +52,6 @@ interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer<PropertyDefini
interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer<AttributeDefinition>
-
interface BluePrintEnhancerService {
@Throws(BluePrintException::class)
@@ -132,11 +139,16 @@ interface BluePrintTypeEnhancerService {
}
@Suppress("UNCHECKED_CAST")
- private fun <T> doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List<BluePrintEnhancer<T>>) {
+ private fun <T> doEnhancement(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ name: String,
+ definition: Any,
+ enhancers: List<BluePrintEnhancer<T>>
+ ) {
if (enhancers.isNotEmpty()) {
enhancers.forEach {
it.enhance(bluePrintRuntimeService, name, definition as T)
}
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt
index 3a6d35f4e..8d04e5489 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintRepoService.kt
@@ -18,7 +18,11 @@
package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
import java.io.Serializable
/**
@@ -43,5 +47,4 @@ interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
index 7912e781a..aa61b0c4d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
@@ -23,12 +23,17 @@ interface BluePrintScriptsService {
suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T
- suspend fun <T> scriptInstance(blueprintBasePath: String, artifactName: String, artifactVersion: String,
- scriptClassName: String, reCompile: Boolean): T
+ suspend fun <T> scriptInstance(
+ blueprintBasePath: String,
+ artifactName: String,
+ artifactVersion: String,
+ scriptClassName: String,
+ reCompile: Boolean
+ ): T
suspend fun <T> scriptInstance(blueprintBasePath: String, scriptClassName: String, reCompile: Boolean): T
suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T
suspend fun <T> scriptInstance(scriptClassName: String): T
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt
index 92be6753c..70c797326 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintWorkflowExecutionService.kt
@@ -20,7 +20,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
interface BluePrintWorkflowExecutionService<Input, Output> {
- suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- executionServiceInput: Input,
- properties: MutableMap<String, Any> = hashMapOf()): Output
-} \ No newline at end of file
+ suspend fun executeBluePrintWorkflow(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: Input,
+ properties: MutableMap<String, Any> = hashMapOf()
+ ): Output
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
index 932b9a09f..b56fac541 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
@@ -21,7 +21,6 @@ import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import java.util.function.Function
-
interface BlueprintFunctionNode<T, R> : Function<T, R> {
fun getName(): String
@@ -70,4 +69,4 @@ interface BlueprintFunctionNode<T, R> : Function<T, R> {
@Throws(BluePrintProcessorException::class)
suspend fun applyNB(t: T): R
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt
index 98abf8987..6f6979772 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintTemplateService.kt
@@ -34,18 +34,21 @@ interface BlueprintTemplateService {
* @return Content result
*
**/
- suspend fun generateContent(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- nodeTemplateName: String,
- artifactName: String,
- jsonData: String = "",
- ignoreJsonNull: Boolean = false,
- additionalContext: MutableMap<String, Any> = mutableMapOf()): String
+ suspend fun generateContent(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactName: String,
+ jsonData: String = "",
+ ignoreJsonNull: Boolean = false,
+ additionalContext: MutableMap<String, Any> = mutableMapOf()
+ ): String
}
/**
* Customise JsonNodeFactory and TextNode, Since it introduces quotes for string data.
*/
open class BluePrintJsonNodeFactory : JsonNodeFactory() {
+
override fun textNode(text: String): TextNode {
return BluePrintTextNode(text)
}
@@ -59,5 +62,4 @@ open class BluePrintTextNode(v: String) : TextNode(v) {
CharTypes.appendQuoted(sb, this._value)
return sb.toString()
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt
index 6076f5503..c6339f449 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintValidator.kt
@@ -18,17 +18,23 @@
package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-
interface BluePrintValidator<T> {
fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T)
-
}
-
interface BluePrintServiceTemplateValidator : BluePrintValidator<ServiceTemplate>
interface BluePrintTopologyTemplateValidator : BluePrintValidator<TopologyTemplate>
@@ -61,7 +67,6 @@ interface BluePrintValidatorService {
fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean
}
-
interface BluePrintTypeValidatorService {
fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T?
@@ -100,8 +105,11 @@ interface BluePrintTypeValidatorService {
doValidation(bluePrintRuntimeService, name, artifactType, validators)
}
- fun validateArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
- artifactDefinition: ArtifactDefinition) {
+ fun validateArtifactDefinition(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ name: String,
+ artifactDefinition: ArtifactDefinition
+ ) {
val validators = getArtifactDefinitionsValidators()
doValidation(bluePrintRuntimeService, name, artifactDefinition, validators)
}
@@ -154,12 +162,14 @@ interface BluePrintTypeValidatorService {
}
@Suppress("UNCHECKED_CAST")
- private fun <T> doValidation(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, validators: List<BluePrintValidator<T>>) {
+ private fun <T> doValidation(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ name: String,
+ definition: Any,
+ validators: List<BluePrintValidator<T>>
+ ) {
validators.forEach {
it.validate(bluePrintRuntimeService, name, definition as T)
}
}
}
-
-
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt
index baae3372d..b2857c6ce 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt
@@ -30,12 +30,11 @@ import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists
import org.onap.ccsdk.cds.controllerblueprints.core.logger
import java.io.File
import java.net.URLClassLoader
-import java.util.*
+import java.util.ArrayList
import kotlin.script.experimental.api.SourceCode
import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
import kotlin.system.measureTimeMillis
-
open class BluePrintCompileService {
val log = logger(BluePrintCompileService::class)
@@ -46,8 +45,11 @@ open class BluePrintCompileService {
}
/** Compile the [bluePrintSourceCode] and get the [kClassName] instance for the constructor [args] */
- suspend fun <T> eval(bluePrintSourceCode: BluePrintSourceCode, kClassName: String,
- args: ArrayList<Any?>?): T {
+ suspend fun <T> eval(
+ bluePrintSourceCode: BluePrintSourceCode,
+ kClassName: String,
+ args: ArrayList<Any?>?
+ ): T {
/** Compile the source code */
compile(bluePrintSourceCode)
/** Get the class loader with compiled jar */
@@ -58,15 +60,17 @@ open class BluePrintCompileService {
/** Compile [bluePrintSourceCode] and put into cache */
suspend fun compile(bluePrintSourceCode: BluePrintSourceCode) {
- //TODO("Include Multiple folders")
+ // TODO("Include Multiple folders")
val sourcePath = bluePrintSourceCode.blueprintKotlinSources.first()
val compiledJarFile = bluePrintSourceCode.targetJarFile
/** Check cache is present for the blueprint scripts */
val hasCompiledCache = BluePrintCompileCache.hasClassLoader(bluePrintSourceCode.cacheKey)
- log.debug("Jar Exists : ${compiledJarFile.exists()}, Regenerate : ${bluePrintSourceCode.regenerate}," +
- " Compiled hash(${bluePrintSourceCode.cacheKey}) : $hasCompiledCache")
+ log.debug(
+ "Jar Exists : ${compiledJarFile.exists()}, Regenerate : ${bluePrintSourceCode.regenerate}," +
+ " Compiled hash(${bluePrintSourceCode.cacheKey}) : $hasCompiledCache"
+ )
if (!compiledJarFile.exists() || bluePrintSourceCode.regenerate || !hasCompiledCache) {
log.info("compiling for cache key(${bluePrintSourceCode.cacheKey})")
@@ -94,8 +98,7 @@ open class BluePrintCompileService {
val exitCode: ExitCode = k2jvmCompiler.exec(messageCollector, Services.EMPTY, arguments)
when (exitCode) {
ExitCode.OK -> {
- checkFileExists(compiledJarFile)
- { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" }
+ checkFileExists(compiledJarFile) { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" }
}
else -> {
throw BluePrintException("$exitCode :${messageCollector.errors().joinToString("\n")}")
@@ -112,13 +115,13 @@ open class BluePrintCompileService {
/** create class [kClassName] instance from [classLoader] */
fun <T> instance(classLoader: URLClassLoader, kClassName: String, args: ArrayList<Any?>? = arrayListOf()): T {
val kClazz = classLoader.loadClass(kClassName)
- ?: throw BluePrintException("failed to load class($kClassName) from current class loader.")
+ ?: throw BluePrintException("failed to load class($kClassName) from current class loader.")
val instance = if (args.isNullOrEmpty()) {
kClazz.newInstance()
} else {
kClazz.constructors
- .single().newInstance(*args.toArray())
+ .single().newInstance(*args.toArray())
} ?: throw BluePrintException("failed to create class($kClassName) instance for constructor argument($args).")
return instance as T
}
@@ -126,6 +129,7 @@ open class BluePrintCompileService {
/** Compile source code information */
open class BluePrintSourceCode : SourceCode {
+
lateinit var blueprintKotlinSources: MutableList<String>
lateinit var moduleName: String
lateinit var targetJarFile: File
@@ -143,9 +147,9 @@ open class BluePrintSourceCode : SourceCode {
/** Class to collect compilation Data */
data class CompiledMessageData(
- val severity: CompilerMessageSeverity,
- val message: String,
- val location: CompilerMessageLocation?
+ val severity: CompilerMessageSeverity,
+ val message: String,
+ val location: CompilerMessageLocation?
)
/** Class to collect compilation results */
@@ -160,9 +164,9 @@ class CompilationMessageCollector : MessageCollector {
}
override fun hasErrors() =
- synchronized(compiledMessages) {
- compiledMessages.any { it.severity.isError }
- }
+ synchronized(compiledMessages) {
+ compiledMessages.any { it.severity.isError }
+ }
override fun clear() {
synchronized(compiledMessages) {
@@ -171,4 +175,4 @@ class CompilationMessageCollector : MessageCollector {
}
fun errors(): List<CompiledMessageData> = compiledMessages.filter { it.severity == CompilerMessageSeverity.ERROR }
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt
index f90e27f4d..fbfcfb94f 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt
@@ -25,27 +25,26 @@ import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import java.net.URL
import java.net.URLClassLoader
-
object BluePrintCompileCache {
val log = logger(BluePrintCompileCache::class)
private val classLoaderCache: LoadingCache<String, URLClassLoader> = CacheBuilder.newBuilder()
- .maximumSize(50)
- .build(BluePrintClassLoader)
+ .maximumSize(50)
+ .build(BluePrintClassLoader)
fun classLoader(key: String): URLClassLoader {
return classLoaderCache.get(key)
}
fun cleanClassLoader(key: String) {
- if(hasClassLoader(key)){
+ if (hasClassLoader(key)) {
// Make sure to close all classloader loaded resources before we let go of it.
// This fixes a Delete failure message on filesystem that keeps locks on opened jars;
// like Windows and NFS.
classLoaderCache.get(key).close()
classLoaderCache.invalidate(key)
log.info("Cleaned compiled cache($key)")
- }else{
+ } else {
log.warn("No compiled cache($key) present to clean.")
}
}
@@ -67,11 +66,11 @@ object BluePrintClassLoader : CacheLoader<String, URLClassLoader>() {
}
val urls = arrayListOf<URL>()
keyPath.walkTopDown()
- .filter { it.name.endsWith("cba-kts.jar") }
- .forEach {
- log.debug("Adding (${it.absolutePath}) to cache($key)")
- urls.add(it.toURI().toURL())
- }
+ .filter { it.name.endsWith("cba-kts.jar") }
+ .forEach {
+ log.debug("Adding (${it.absolutePath}) to cache($key)")
+ urls.add(it.toURI().toURL())
+ }
return URLClassLoader(urls.toTypedArray(), this.javaClass.classLoader)
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt
index c067bf3d9..f3eb1a2b9 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt
@@ -23,8 +23,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.logger
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
-import java.util.*
-
+import java.util.ArrayList
open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
@@ -35,8 +34,13 @@ open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
return bluePrintCompileService.eval(bluePrintSourceCode, scriptClassName, null)
}
- override suspend fun <T> scriptInstance(blueprintBasePath: String, artifactName: String, artifactVersion: String,
- scriptClassName: String, reCompile: Boolean): T {
+ override suspend fun <T> scriptInstance(
+ blueprintBasePath: String,
+ artifactName: String,
+ artifactVersion: String,
+ scriptClassName: String,
+ reCompile: Boolean
+ ): T {
val sources: MutableList<String> = arrayListOf()
sources.add(normalizedPathName(blueprintBasePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR))
@@ -50,24 +54,29 @@ open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
return scriptInstance(scriptSource, scriptClassName)
}
- override suspend fun <T> scriptInstance(blueprintBasePath: String, scriptClassName: String,
- reCompile: Boolean): T {
+ override suspend fun <T> scriptInstance(
+ blueprintBasePath: String,
+ scriptClassName: String,
+ reCompile: Boolean
+ ): T {
val toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintBasePath)
checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" }
checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" }
- return scriptInstance(blueprintBasePath, toscaMetaData.templateName!!, toscaMetaData.templateVersion!!,
- scriptClassName, reCompile)
+ return scriptInstance(
+ blueprintBasePath, toscaMetaData.templateName!!, toscaMetaData.templateVersion!!,
+ scriptClassName, reCompile
+ )
}
override suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T {
val args = ArrayList<Any?>()
return BluePrintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors
- .single().newInstance(*args.toArray()) as T
+ .single().newInstance(*args.toArray()) as T
}
override suspend fun <T> scriptInstance(scriptClassName: String): T {
val args = ArrayList<Any?>()
return Thread.currentThread().contextClassLoader.loadClass(scriptClassName).constructors
- .single().newInstance(*args.toArray()) as T
+ .single().newInstance(*args.toArray()) as T
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt
index 159743487..7d85963dc 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintChainedService.kt
@@ -17,16 +17,25 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementDefinition
+
/**
*
*
* @author Brinda Santh
*/
class BluePrintChainedService {
- var bpc : BluePrintContext
- constructor(bpc : BluePrintContext){
+ var bpc: BluePrintContext
+
+ constructor(bpc: BluePrintContext) {
this.bpc = bpc
}
@@ -42,30 +51,30 @@ class BluePrintChainedService {
recNodeTypesChained(nodeTypeName).forEach { nodeType ->
- val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes
+ val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes
if (subAttributes != null) {
attributes.putAll(subAttributes)
}
- val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
+ val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
if (subProperties != null) {
properties.putAll(subProperties)
}
- val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements
+ val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements
if (subRequirements != null) {
requirements.putAll(subRequirements)
}
- val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities
+ val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities
if (subCapabilities != null) {
capabilities.putAll(subCapabilities)
}
- val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces
+ val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces
if (subInterfaces != null) {
interfaces.putAll(subInterfaces)
}
- val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts
+ val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts
if (subArtifacts != null) {
artifacts.putAll(subArtifacts)
}
@@ -80,11 +89,11 @@ class BluePrintChainedService {
}
fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? {
- val nodeType = bpc.nodeTypeByName(nodeTypeName)
+ val nodeType = bpc.nodeTypeByName(nodeTypeName)
val properties = hashMapOf<String, PropertyDefinition>()
recNodeTypesChained(nodeTypeName).forEach { nodeType ->
- val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
+ val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties
if (subProperties != null) {
properties.putAll(subProperties)
}
@@ -93,7 +102,7 @@ class BluePrintChainedService {
}
private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList<NodeType>? = arrayListOf()): MutableList<NodeType> {
- val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName)
+ val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName)
nodeType.id = nodeTypeName
val derivedFrom: String = nodeType.derivedFrom
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
@@ -104,7 +113,7 @@ class BluePrintChainedService {
}
private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList<DataType>? = arrayListOf()): MutableList<DataType> {
- val dataType: DataType = bpc.dataTypeByName(dataTypeName)!!
+ val dataType: DataType = bpc.dataTypeByName(dataTypeName)!!
dataType.id = dataTypeName
val derivedFrom: String = dataType.derivedFrom
if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) {
@@ -113,5 +122,4 @@ class BluePrintChainedService {
dataTypes!!.add(dataType)
return dataTypes
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
index 99c80f8e6..47cd62ea1 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
@@ -21,7 +21,24 @@ package org.onap.ccsdk.cds.controllerblueprints.core.service
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ImportDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Step
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
@@ -67,46 +84,46 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
}
fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME)
- ?: throw BluePrintException("could't get template name from meta data")
+ ?: throw BluePrintException("could't get template name from meta data")
fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION)
- ?: throw BluePrintException("could't get template version from meta data")
+ ?: throw BluePrintException("could't get template version from meta data")
fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR)
- ?: throw BluePrintException("could't get template author from meta data")
+ ?: throw BluePrintException("could't get template author from meta data")
// Workflow
fun workflows(): MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows
fun workflowByName(workFlowName: String): Workflow = workflows()?.get(workFlowName)
- ?: throw BluePrintException("could't get workflow($workFlowName)")
+ ?: throw BluePrintException("could't get workflow($workFlowName)")
fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs
fun workflowStepByName(workFlowName: String, stepName: String): Step {
return workflowByName(workFlowName).steps?.get(stepName)
- ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")
+ ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")
}
fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String {
return workflowStepByName(workFlowName, stepName).target
- ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)")
+ ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)")
}
fun workflowFirstStepNodeTemplate(workFlowName: String): String {
val firstStepName = workflowByName(workFlowName).steps?.keys?.first()
- ?: throw BluePrintException("could't get first step for workflow($workFlowName)")
+ ?: throw BluePrintException("could't get first step for workflow($workFlowName)")
return workflowStepNodeTemplate(workFlowName, firstStepName)
}
fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String {
return workflowStepByName(workFlowName, stepName).activities?.filter { it.callOperation != null }?.single()?.callOperation
- ?: throw BluePrintException("couldn't get first callOperation for WorkFlow($workFlowName) ")
+ ?: throw BluePrintException("couldn't get first callOperation for WorkFlow($workFlowName) ")
}
// DSL
fun dslPropertiesByName(name: String): JsonNode = dslDefinitions()?.get(name)
- ?: throw BluePrintException("couldn't get policy type for the dsl($name)")
+ ?: throw BluePrintException("couldn't get policy type for the dsl($name)")
// Data Type
fun dataTypeByName(name: String): DataType? = dataTypes()?.get(name)
@@ -118,7 +135,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun policyTypes(): MutableMap<String, PolicyType>? = serviceTemplate.policyTypes
fun policyTypeByName(policyName: String) = policyTypes()?.get(policyName)
- ?: throw BluePrintException("could't get policy type for the name($policyName)")
+ ?: throw BluePrintException("could't get policy type for the name($policyName)")
fun policyTypesDerivedFrom(name: String): MutableMap<String, PolicyType>? {
return policyTypes()?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap()
@@ -138,8 +155,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTypes(): MutableMap<String, NodeType>? = serviceTemplate.nodeTypes
fun nodeTypeByName(name: String): NodeType =
- nodeTypes()?.get(name)
- ?: throw BluePrintException("could't get node type for the name($name)")
+ nodeTypes()?.get(name)
+ ?: throw BluePrintException("could't get node type for the name($name)")
fun nodeTypeDerivedFrom(name: String): MutableMap<String, NodeType>? {
return nodeTypes()?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap()
@@ -147,24 +164,32 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition {
return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName)
- ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)")
+ ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)")
}
fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition {
return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName)
- ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)")
+ ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)")
}
fun interfaceNameForNodeType(nodeTypeName: String): String {
return nodeTypeByName(nodeTypeName).interfaces?.keys?.first()
- ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name")
+ ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name")
}
- fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {
+ fun nodeTypeInterfaceOperationInputs(
+ nodeTypeName: String,
+ interfaceName: String,
+ operationName: String
+ ): MutableMap<String, PropertyDefinition>? {
return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).inputs
}
- fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap<String, PropertyDefinition>? {
+ fun nodeTypeInterfaceOperationOutputs(
+ nodeTypeName: String,
+ interfaceName: String,
+ operationName: String
+ ): MutableMap<String, PropertyDefinition>? {
return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).outputs
}
@@ -172,7 +197,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTemplates(): MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates
fun nodeTemplateByName(name: String): NodeTemplate =
- nodeTemplates()?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
+ nodeTemplates()?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {
return nodeTemplates()?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()
@@ -193,31 +218,31 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition {
return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)")
}
fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition {
return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)")
}
fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment {
return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first()
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment")
}
fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String {
return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first()
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name")
}
fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String {
return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first()
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name")
}
- fun nodeTemplateOperationImplementation(nodeTemplateName: String, interfaceName: String, operationName: String)
- : Implementation? {
+ fun nodeTemplateOperationImplementation(nodeTemplateName: String, interfaceName: String, operationName: String):
+ Implementation? {
return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).implementation
}
@@ -231,27 +256,27 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment {
return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)")
}
fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment {
return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)")
}
fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment {
return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)")
}
fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment {
return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)
- ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)")
+ ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)")
}
fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate {
val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node
- ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ")
+ ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ")
return nodeTemplateByName(filteredNodeTemplateName)
}
@@ -268,5 +293,4 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap<String, PropertyDefinition>? {
return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName)
}
-
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
index 776e0411e..df3bde1b4 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintDependencyService.kt
@@ -38,16 +38,16 @@ object BluePrintDependencyService {
inline fun <reified T> instance(name: String): T {
return applicationContext.getBean(name) as? T
- ?: throw BluePrintProcessorException("failed to get instance($name)")
+ ?: throw BluePrintProcessorException("failed to get instance($name)")
}
inline fun <reified T> instance(type: Class<T>): T {
return applicationContext.getBean(type)
- ?: throw BluePrintProcessorException("failed to get instance($type)")
+ ?: throw BluePrintProcessorException("failed to get instance($type)")
}
inline fun <reified T> instance(type: KClass<*>): T {
return applicationContext.getBean(type.java) as? T
- ?: throw BluePrintProcessorException("failed to get instance($type)")
+ ?: throw BluePrintProcessorException("failed to get instance($type)")
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
index fbf911664..6a3c64650 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
@@ -25,7 +24,14 @@ 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.data.*
+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
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ExpressionData
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationOutputExpression
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyExpression
+import org.slf4j.LoggerFactory
/**
*
@@ -33,16 +39,16 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.*
* @author Brinda Santh
*/
object BluePrintExpressionService {
- val log= LoggerFactory.getLogger(this::class.toString())
+
+ val log = LoggerFactory.getLogger(this::class.toString())
@JvmStatic
fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean {
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))
-
+ return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT) ||
+ json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE) ||
+ json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY))
}
@JvmStatic
@@ -74,8 +80,9 @@ object BluePrintExpressionService {
}
}
}
- } else if (propertyAssignmentNode is TextNode
- && propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)) {
+ } else if (propertyAssignmentNode is TextNode &&
+ propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
+ ) {
expressionData.isExpression = true
expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE
expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode)
@@ -85,8 +92,10 @@ object BluePrintExpressionService {
@JvmStatic
fun populateDSLExpression(jsonNode: TextNode): DSLExpression {
- return DSLExpression(propertyName = jsonNode.textValue()
- .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE))
+ return DSLExpression(
+ propertyName = jsonNode.textValue()
+ .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE)
+ )
}
@JvmStatic
@@ -98,9 +107,13 @@ object BluePrintExpressionService {
fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BluePrintException(String.format("missing property expression, " +
- "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +
- "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode))
+ throw BluePrintException(
+ String.format(
+ "missing property expression, " +
+ "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, " +
+ "<nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] , but present {}", jsonNode
+ )
+ )
}
var reqOrCapEntityName: String? = null
var propertyName = ""
@@ -121,10 +134,11 @@ object BluePrintExpressionService {
}
}
- return PropertyExpression(modelableEntityName = arrayNode[0].asText(),
- reqOrCapEntityName = reqOrCapEntityName,
- propertyName = propertyName,
- subPropertyName = subProperty
+ return PropertyExpression(
+ modelableEntityName = arrayNode[0].asText(),
+ reqOrCapEntityName = reqOrCapEntityName,
+ propertyName = propertyName,
+ subPropertyName = subProperty
)
}
@@ -132,9 +146,13 @@ object BluePrintExpressionService {
fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BluePrintException(String.format("missing attribute expression, " +
- "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +
- " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode))
+ throw BluePrintException(
+ String.format(
+ "missing attribute expression, " +
+ "it should be [ <modelable_entity_name>, <optional_req_or_cap_name>, <attribute_name>," +
+ " <nested_attribute_name_or_index_1>, ..., <nested_attribute_name_or_index_n> ] , but present {}", jsonNode
+ )
+ )
}
var reqOrCapEntityName: String? = null
@@ -155,10 +173,11 @@ object BluePrintExpressionService {
subAttributeName = propertyPaths.joinToString("/")
}
}
- return AttributeExpression(modelableEntityName = arrayNode[0].asText(),
- reqOrCapEntityName = reqOrCapEntityName,
- attributeName = attributeName,
- subAttributeName = subAttributeName
+ return AttributeExpression(
+ modelableEntityName = arrayNode[0].asText(),
+ reqOrCapEntityName = reqOrCapEntityName,
+ attributeName = attributeName,
+ subAttributeName = subAttributeName
)
}
@@ -167,19 +186,25 @@ object BluePrintExpressionService {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 4) {
- throw BluePrintException(String.format("missing operation output expression, " +
- "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}", jsonNode))
+ throw BluePrintException(
+ String.format(
+ "missing operation output expression, " +
+ "it should be (<modelable_entity_name>, <interface_name>, <operation_name>, <output_variable_name>) , but present {}",
+ jsonNode
+ )
+ )
}
var subPropertyName: String? = null
if (arrayNode.size() == 5)
subPropertyName = arrayNode[4].asText()
- return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(),
- interfaceName = arrayNode[1].asText(),
- operationName = arrayNode[2].asText(),
- propertyName = arrayNode[3].asText(),
- subPropertyName = subPropertyName
+ return OperationOutputExpression(
+ modelableEntityName = arrayNode[0].asText(),
+ interfaceName = arrayNode[1].asText(),
+ operationName = arrayNode[2].asText(),
+ propertyName = arrayNode[3].asText(),
+ subPropertyName = subPropertyName
)
}
@@ -188,13 +213,18 @@ object BluePrintExpressionService {
val arrayNode: ArrayNode = jsonNode.first() as ArrayNode
check(arrayNode.size() >= 2) {
- throw BluePrintException(String.format("missing artifact expression, " +
- "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode))
+ throw BluePrintException(
+ String.format(
+ "missing artifact expression, " +
+ "it should be [ <modelable_entity_name>, <artifact_name>, <location>, <remove> ] , but present {}", jsonNode
+ )
+ )
}
- return ArtifactExpression(modelableEntityName = arrayNode[0].asText(),
- artifactName = arrayNode[1].asText(),
- location = arrayNode[2]?.asText() ?: "LOCAL_FILE",
- remove = arrayNode[3]?.asBoolean() ?: false
+ return ArtifactExpression(
+ modelableEntityName = arrayNode[0].asText(),
+ artifactName = arrayNode[1].asText(),
+ location = arrayNode[2]?.asText() ?: "LOCAL_FILE",
+ remove = arrayNode[3]?.asBoolean() ?: false
)
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt
index 5f6505309..24b7e261c 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintImportService.kt
@@ -37,7 +37,6 @@ class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate,
private var importServiceTemplateMap: MutableMap<String, ServiceTemplate> = hashMapOf()
-
suspend fun getImportResolvedServiceTemplate(): ServiceTemplate {
// Populate Imported Service Templates
traverseSchema(PARENT_SERVICE_TEMPLATE, parentServiceTemplate)
@@ -70,13 +69,13 @@ class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate,
val decodedSystemId: String = URLDecoder.decode(file, Charset.defaultCharset().toString())
log.trace("file ({}), decodedSystemId ({}) ", file, decodedSystemId)
try {
- if (decodedSystemId.startsWith("http", true)
- || decodedSystemId.startsWith("https", true)) {
+ if (decodedSystemId.startsWith("http", true) ||
+ decodedSystemId.startsWith("https", true)
+ ) {
val givenUrl: String = URL(decodedSystemId).toString()
val systemUrl: String = File(".").toURI().toURL().toString()
log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl)
if (givenUrl.startsWith(systemUrl)) {
-
}
} else {
if (!decodedSystemId.startsWith("/")) {
@@ -92,6 +91,4 @@ class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate,
}
return serviceTemplate
}
-
-
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
index 78997fe52..fdc348bf7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintJinjaTemplateService.kt
@@ -39,41 +39,56 @@ object BluePrintJinjaTemplateService {
/**
* To enable inheritance within CBA, we need Jinja runtime to know where to load the templates.
*/
- class BlueprintRelatedTemplateLocator(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
- private val artifactName: String,
- private val artifactVersion: String) : ResourceLocator {
+ class BlueprintRelatedTemplateLocator(
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val artifactName: String,
+ private val artifactVersion: String
+ ) : ResourceLocator {
@Throws(IOException::class)
override fun getString(fullName: String, encoding: Charset, interpreter: JinjavaInterpreter): String {
try {
val deployFile =
- normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath,
+ normalizedPathName(
+ bluePrintLoadConfiguration.blueprintDeployPath,
artifactName,
artifactVersion,
- fullName)
+ fullName
+ )
return String(readAllBytes(Paths.get(deployFile)))
} catch (var5: IllegalArgumentException) {
throw ResourceNotFoundException("Couldn't find resource: $fullName")
}
-
}
}
- fun generateContent(template: String, json: String, ignoreJsonNull: Boolean,
- additionalContext: MutableMap<String, Any>,
- bluePrintLoadConfiguration: BluePrintLoadConfiguration, artifactName: String,
- artifactVersion: String): String {
-
- return generateContent(template,
+ fun generateContent(
+ template: String,
+ json: String,
+ ignoreJsonNull: Boolean,
+ additionalContext: MutableMap<String, Any>,
+ bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ artifactName: String,
+ artifactVersion: String
+ ): String {
+
+ return generateContent(
+ template,
json,
ignoreJsonNull,
additionalContext,
- BlueprintRelatedTemplateLocator(bluePrintLoadConfiguration, artifactName, artifactVersion))
+ BlueprintRelatedTemplateLocator(bluePrintLoadConfiguration, artifactName, artifactVersion)
+ )
}
- fun generateContent(template: String, json: String, ignoreJsonNull: Boolean,
- additionalContext: MutableMap<String, Any>, resourceLocator: ResourceLocator? = null): String {
+ fun generateContent(
+ template: String,
+ json: String,
+ ignoreJsonNull: Boolean,
+ additionalContext: MutableMap<String, Any>,
+ resourceLocator: ResourceLocator? = null
+ ): String {
val jinJava = Jinjava(JinjavaConfig())
if (resourceLocator != null) {
jinJava.resourceLocator = resourceLocator
@@ -98,4 +113,3 @@ object BluePrintJinjaTemplateService {
return jinJava.render(template, additionalContext)
}
}
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt
index 4b02492da..1f71495a3 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt
@@ -16,27 +16,33 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
-import org.slf4j.LoggerFactory
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RelationshipType
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService {
- private val log= LoggerFactory.getLogger(BluePrintRepoFileService::class.toString())
+ private val log = LoggerFactory.getLogger(BluePrintRepoFileService::class.toString())
private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE)
- private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
- private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
+ private val capabilityTypePath =
+ modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE)
+ private val relationshipTypePath =
+ modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
override fun getDataType(dataTypeName: String): DataType {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(dataTypeName).plus(extension)
+ .plus(dataTypeName).plus(extension)
return getModelType(fileName, DataType::class.java)
}
@@ -47,24 +53,24 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic
override fun getArtifactType(artifactTypeName: String): ArtifactType {
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(artifactTypeName).plus(extension)
+ .plus(artifactTypeName).plus(extension)
return getModelType(fileName, ArtifactType::class.java)
}
override fun getRelationshipType(relationshipTypeName: String): RelationshipType {
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(relationshipTypeName).plus(extension)
+ .plus(relationshipTypeName).plus(extension)
return getModelType(fileName, RelationshipType::class.java)
}
override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(capabilityDefinitionName).plus(extension)
+ .plus(capabilityDefinitionName).plus(extension)
return getModelType(fileName, CapabilityDefinition::class.java)
}
private fun <T> getModelType(fileName: String, valueType: Class<T>): T {
return JacksonUtils.readValueFromFile(fileName, valueType)
- ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}")
+ ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}")
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
index f7b512153..a6d2de476 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -17,15 +17,20 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
-
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.returnNullIfMissing
+import org.onap.ccsdk.cds.controllerblueprints.core.rootFieldsToMap
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
import java.io.File
@@ -68,11 +73,11 @@ interface BluePrintRuntimeService<T> {
propertyAssignments: MutableMap<String, JsonNode>
): MutableMap<String, JsonNode>
- fun resolvePropertyDefinitions(name: String, propertyDefinitions: MutableMap<String, PropertyDefinition>)
- : MutableMap<String, JsonNode>
+ fun resolvePropertyDefinitions(name: String, propertyDefinitions: MutableMap<String, PropertyDefinition>):
+ MutableMap<String, JsonNode>
- fun resolvePropertyAssignments(name: String, propertyAssignments: MutableMap<String, JsonNode>)
- : MutableMap<String, JsonNode>
+ fun resolvePropertyAssignments(name: String, propertyAssignments: MutableMap<String, JsonNode>):
+ MutableMap<String, JsonNode>
fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap<String, JsonNode>
@@ -80,12 +85,14 @@ interface BluePrintRuntimeService<T> {
JsonNode>
fun resolveNodeTemplateInterfaceOperationInputs(
- nodeTemplateName: String, interfaceName: String,
+ nodeTemplateName: String,
+ interfaceName: String,
operationName: String
): MutableMap<String, JsonNode>
fun resolveNodeTemplateInterfaceOperationOutputs(
- nodeTemplateName: String, interfaceName: String,
+ nodeTemplateName: String,
+ interfaceName: String,
operationName: String
): MutableMap<String, JsonNode>
@@ -98,7 +105,9 @@ interface BluePrintRuntimeService<T> {
fun setInputValue(propertyName: String, value: JsonNode)
fun setWorkflowInputValue(
- workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition,
+ workflowName: String,
+ propertyName: String,
+ propertyDefinition: PropertyDefinition,
value: JsonNode
)
@@ -107,25 +116,36 @@ interface BluePrintRuntimeService<T> {
fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode)
fun setNodeTemplateOperationPropertyValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String, value: JsonNode
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
+ value: JsonNode
)
fun setNodeTemplateOperationInputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String, value: JsonNode
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
+ value: JsonNode
)
fun setNodeTemplateOperationOutputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String, value: JsonNode
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
+ value: JsonNode
)
fun getInputValue(propertyName: String): JsonNode
fun getNodeTemplateOperationOutputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String
): JsonNode
fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode?
@@ -163,7 +183,6 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
val absoluteEnvFilePath = bluePrintContext.rootPath.plus(File.separator)
.plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
loadEnvironments(BluePrintConstants.PROPERTY_BPP, absoluteEnvFilePath)
-
}
override fun id(): String {
@@ -240,8 +259,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
nodeTemplateName: String,
propertyDefinitions: MutableMap<String, PropertyDefinition>,
propertyAssignments: MutableMap<String, JsonNode>
- )
- : MutableMap<String, JsonNode> {
+ ):
+ MutableMap<String, JsonNode> {
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
@@ -254,7 +273,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
// Resolve the Expressing
val propertyAssignmentExpression = PropertyAssignmentService(this)
resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(
- nodeTemplateName, nodeTypePropertyName, propertyAssignment)
+ nodeTemplateName, nodeTypePropertyName, propertyAssignment
+ )
}
// Set default value if null
@@ -268,8 +288,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return propertyAssignmentValue
}
- override fun resolvePropertyDefinitions(name: String, propertyDefinitions: MutableMap<String, PropertyDefinition>)
- : MutableMap<String, JsonNode> {
+ override fun resolvePropertyDefinitions(name: String, propertyDefinitions: MutableMap<String, PropertyDefinition>):
+ MutableMap<String, JsonNode> {
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
propertyDefinitions.forEach { propertyName, propertyDefinition ->
@@ -283,8 +303,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return propertyAssignmentValue
}
- override fun resolvePropertyAssignments(name: String, propertyAssignments: MutableMap<String, JsonNode>)
- : MutableMap<String, JsonNode> {
+ override fun resolvePropertyAssignments(name: String, propertyAssignments: MutableMap<String, JsonNode>):
+ MutableMap<String, JsonNode> {
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
propertyAssignments.forEach { (propertyName, propertyExpression) ->
@@ -333,8 +353,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
interfaceName: String,
operationName: String
): MutableMap<String, JsonNode> {
- log.info("resolveNodeTemplateInterfaceOperationInputs for node template ($nodeTemplateName), " +
- "interface name($interfaceName), operationName($operationName)")
+ log.info(
+ "resolveNodeTemplateInterfaceOperationInputs for node template ($nodeTemplateName), " +
+ "interface name($interfaceName), operationName($operationName)"
+ )
val propertyAssignments: MutableMap<String, JsonNode> =
bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
@@ -352,10 +374,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
* Resolve the Property Input Assignment Values.
*/
return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypeInterfaceOperationInputs, propertyAssignments)
-
}
-
override fun resolveNodeTemplateInterfaceOperationOutputs(
nodeTemplateName: String,
interfaceName: String,
@@ -379,7 +399,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
* Resolve the Property Output Assignment Values.
*/
val propertyAssignmentValue =
- resolveNodeTemplatePropertyAssignments(nodeTemplateName,nodeTypeInterfaceOperationOutputs, propertyAssignments)
+ resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypeInterfaceOperationOutputs, propertyAssignments)
// Store operation output values into context
propertyAssignmentValue.forEach { (key, value) ->
@@ -403,7 +423,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
return nodeTemplate.artifacts?.get(artifactName)
?: throw BluePrintProcessorException(
- "failed to get artifact definition($artifactName) from the node template")
+ "failed to get artifact definition($artifactName) from the node template"
+ )
}
/**
@@ -412,8 +433,9 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
*/
override fun resolveDSLExpression(dslPropertyName: String): JsonNode {
val propertyAssignments = bluePrintContext.dslPropertiesByName(dslPropertyName)
- return if (BluePrintExpressionService.checkContainsExpression(propertyAssignments)
- && propertyAssignments is ObjectNode) {
+ return if (BluePrintExpressionService.checkContainsExpression(propertyAssignments) &&
+ propertyAssignments is ObjectNode
+ ) {
val rootKeyMap = propertyAssignments.rootFieldsToMap()
val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
@@ -429,14 +451,16 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun setInputValue(propertyName: String, value: JsonNode) {
- val path = """${BluePrintConstants.PATH_INPUTS}${BluePrintConstants.PATH_DIVIDER}${propertyName}"""
+ val path = """${BluePrintConstants.PATH_INPUTS}${BluePrintConstants.PATH_DIVIDER}$propertyName"""
log.trace("setting input path ({}), values ({})", path, value)
put(path, value)
}
override fun setWorkflowInputValue(
- workflowName: String, propertyName: String,
- propertyDefinition: PropertyDefinition, value: JsonNode
+ workflowName: String,
+ propertyName: String,
+ propertyDefinition: PropertyDefinition,
+ value: JsonNode
) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS)
.append(BluePrintConstants.PATH_DIVIDER).append(workflowName)
@@ -463,8 +487,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun setNodeTemplateOperationPropertyValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String,
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
value: JsonNode
) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES)
@@ -480,8 +506,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun setNodeTemplateOperationInputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String,
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
value: JsonNode
) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES)
@@ -497,8 +525,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun setNodeTemplateOperationOutputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String,
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String,
value: JsonNode
) {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES)
@@ -513,7 +543,6 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
put(path, value)
}
-
override fun getInputValue(propertyName: String): JsonNode {
val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
@@ -521,8 +550,10 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun getNodeTemplateOperationOutputValue(
- nodeTemplateName: String, interfaceName: String,
- operationName: String, propertyName: String
+ nodeTemplateName: String,
+ interfaceName: String,
+ operationName: String,
+ propertyName: String
): JsonNode {
val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES)
.append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName)
@@ -563,31 +594,31 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {
- log.info("For workflow ($workflowName) driving input data from (${jsonNode})")
+ log.info("For workflow ($workflowName) driving input data from ($jsonNode)")
val dynamicInputPropertiesName = "$workflowName-properties"
- bluePrintContext.workflowByName(workflowName).inputs?.
- forEach { propertyName, property ->
- if (propertyName != dynamicInputPropertiesName) {
- val valueNode: JsonNode =
- jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName).returnNullIfMissing()
- ?: property.defaultValue
- ?: NullNode.getInstance()
- log.trace("Setting input data - attribute:($propertyName) value:($valueNode)")
- setInputValue(propertyName, valueNode)
+ bluePrintContext.workflowByName(workflowName).inputs
+ ?.forEach { propertyName, property ->
+ if (propertyName != dynamicInputPropertiesName) {
+ val valueNode: JsonNode =
+ jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName).returnNullIfMissing()
+ ?: property.defaultValue
+ ?: NullNode.getInstance()
+ log.trace("Setting input data - attribute:($propertyName) value:($valueNode)")
+ setInputValue(propertyName, valueNode)
+ }
}
- }
// Load Dynamic data Types
jsonNode.get(dynamicInputPropertiesName)?.let {
- bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.
- forEach { propertyName, property ->
- val valueNode: JsonNode =
- it.at(BluePrintConstants.PATH_DIVIDER + propertyName).returnNullIfMissing()
- ?: property.defaultValue
- ?: NullNode.getInstance()
- log.trace("Setting input data - attribute:($propertyName) value:($valueNode)")
- setInputValue(propertyName, valueNode)
- }
+ bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties
+ ?.forEach { propertyName, property ->
+ val valueNode: JsonNode =
+ it.at(BluePrintConstants.PATH_DIVIDER + propertyName).returnNullIfMissing()
+ ?: property.defaultValue
+ ?: NullNode.getInstance()
+ log.trace("Setting input data - attribute:($propertyName) value:($valueNode)")
+ setInputValue(propertyName, valueNode)
+ }
}
}
@@ -615,6 +646,4 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
return jsonNode
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateService.kt
index 2c928e288..db733bda1 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BlueprintTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintTemplateService.kt
@@ -25,9 +25,14 @@ import org.springframework.stereotype.Service
class BluePrintTemplateService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration) :
BlueprintTemplateService {
- override suspend fun generateContent(bluePrintRuntimeService: BluePrintRuntimeService<*>,
- nodeTemplateName: String, artifactName: String, jsonData: String,
- ignoreJsonNull: Boolean, additionalContext: MutableMap<String, Any>): String {
+ override suspend fun generateContent(
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ nodeTemplateName: String,
+ artifactName: String,
+ jsonData: String,
+ ignoreJsonNull: Boolean,
+ additionalContext: MutableMap<String, Any>
+ ): String {
val artifactDefinition =
bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
@@ -36,21 +41,25 @@ class BluePrintTemplateService(private val bluePrintLoadConfiguration: BluePrint
return when (templateType) {
BluePrintConstants.ARTIFACT_JINJA_TYPE_NAME -> {
- BluePrintJinjaTemplateService.generateContent(template,
+ BluePrintJinjaTemplateService.generateContent(
+ template,
jsonData,
ignoreJsonNull,
additionalContext,
bluePrintLoadConfiguration,
bluePrintRuntimeService.bluePrintContext().name(),
- bluePrintRuntimeService.bluePrintContext().version())
+ bluePrintRuntimeService.bluePrintContext().version()
+ )
}
BluePrintConstants.ARTIFACT_VELOCITY_TYPE_NAME -> {
BluePrintVelocityTemplateService.generateContent(template, jsonData, ignoreJsonNull, additionalContext)
}
else -> {
- throw BluePrintProcessorException("Unknown Artifact type, expecting ${BluePrintConstants.ARTIFACT_JINJA_TYPE_NAME}" +
- "or ${BluePrintConstants.ARTIFACT_VELOCITY_TYPE_NAME}")
+ throw BluePrintProcessorException(
+ "Unknown Artifact type, expecting ${BluePrintConstants.ARTIFACT_JINJA_TYPE_NAME}" +
+ "or ${BluePrintConstants.ARTIFACT_VELOCITY_TYPE_NAME}"
+ )
}
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt
index d3dd30224..f492c2bc6 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt
@@ -17,13 +17,33 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.google.common.base.Preconditions
import org.apache.commons.lang3.StringUtils
-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.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.CapabilityDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementAssignment
+import org.onap.ccsdk.cds.controllerblueprints.core.data.RequirementDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.cds.controllerblueprints.core.format
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
import java.io.Serializable
/**
@@ -43,7 +63,7 @@ interface BluePrintValidatorService : Serializable {
@Deprecated("Decomposed implementation moved to blueprint-validation module")
open class BluePrintValidatorDefaultService : BluePrintValidatorService {
- val log= LoggerFactory.getLogger(BluePrintValidatorDefaultService::class.toString())
+ val log = LoggerFactory.getLogger(BluePrintValidatorDefaultService::class.toString())
lateinit var bluePrintContext: BluePrintContext
lateinit var serviceTemplate: ServiceTemplate
@@ -72,9 +92,10 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
} catch (e: Exception) {
log.error("validation failed in the path : {}", paths.joinToString(separator), e)
log.error("validation trace message :{} ", message)
- throw BluePrintException(e,
- format("failed to validate blueprint on path ({}) with message {}"
- , paths.joinToString(separator), e.message))
+ throw BluePrintException(
+ e,
+ format("failed to validate blueprint on path ({}) with message {}", paths.joinToString(separator), e.message)
+ )
}
}
@@ -133,13 +154,17 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
paths.add(nodeTypeName)
message.appendln("--> Node Type :" + paths.joinToString(separator))
val derivedFrom: String = nodeType.derivedFrom
- //Check Derived From
+ // Check Derived From
checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom)
if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
serviceTemplate.nodeTypes?.get(derivedFrom)
- ?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ",
- derivedFrom, nodeTypeName))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get derivedFrom NodeType({})'s for NodeType({}) ",
+ derivedFrom, nodeTypeName
+ )
+ )
}
nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) }
@@ -190,7 +215,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
val type: String = nodeTemplate.type
val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type)
- ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName))
+ ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName))
nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }
nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
@@ -207,12 +232,12 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
paths.add(artifactDefinitionName)
message.appendln("Validating artifact " + paths.joinToString(separator))
val type: String = artifactDefinition.type
- ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName))
+ ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName))
// Check Artifact Type
checkValidArtifactType(artifactDefinitionName, type)
val file: String = artifactDefinition.file
- ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName))
+ ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName))
paths.removeAt(paths.lastIndex)
}
@@ -258,7 +283,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
BluePrintTypes.validCollectionTypes().contains(dataType) -> {
val entrySchemaType: String = propertyDefinition.entrySchema?.type
- ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName))
+ ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName))
checkPrimitiveOrComplex(entrySchemaType, propertyName)
}
else -> checkPropertyDataType(dataType, propertyName)
@@ -270,20 +295,24 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
@Throws(BluePrintException::class)
- open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
- properties: MutableMap<String, JsonNode>) {
+ open fun validatePropertyAssignments(
+ nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+ properties: MutableMap<String, JsonNode>
+ ) {
properties.forEach { propertyName, propertyAssignment ->
val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
- ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))
+ ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))
validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
-
}
}
@Throws(BluePrintException::class)
- open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
- propertyAssignment: JsonNode) {
+ open fun validatePropertyAssignment(
+ propertyName: String,
+ propertyDefinition: PropertyDefinition,
+ propertyAssignment: JsonNode
+ ) {
// Check and Validate if Expression Node
val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
if (!expressionData.isExpression) {
@@ -299,8 +328,12 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
paths.add(capabilityName)
val capabilityDefinition = nodeType.capabilities?.get(capabilityName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) capability definition ({}) " +
- "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) capability definition ({}) " +
+ "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type
+ )
+ )
validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment)
@@ -310,11 +343,14 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
@Throws(BluePrintException::class)
- open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String,
- capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) {
+ open fun validateCapabilityAssignment(
+ nodeTemplateName: String,
+ capabilityName: String,
+ capabilityDefinition: CapabilityDefinition,
+ capabilityAssignment: CapabilityAssignment
+ ) {
capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) }
-
}
@Throws(BluePrintException::class)
@@ -324,38 +360,55 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
requirements?.forEach { requirementName, requirementAssignment ->
paths.add(requirementName)
val requirementDefinition = nodeType.requirements?.get(requirementName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) requirement definition ({}) from" +
- " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) requirement definition ({}) from" +
+ " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type
+ )
+ )
// Validate Requirement Assignment
validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment)
paths.removeAt(paths.lastIndex)
}
paths.removeAt(paths.lastIndex)
-
}
@Throws(BluePrintException::class)
- open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String,
- requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) {
+ open fun validateRequirementAssignment(
+ nodeTemplateName: String,
+ requirementAssignmentName: String,
+ requirementDefinition: RequirementDefinition,
+ requirementAssignment: RequirementAssignment
+ ) {
log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName)
val requirementNodeTemplateName = requirementAssignment.node!!
val capabilityName = requirementAssignment.capability
val relationship = requirementAssignment.relationship!!
check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) {
- throw BluePrintException(format("Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ",
- relationship, nodeTemplateName, requirementAssignmentName))
+ throw BluePrintException(
+ format(
+ "Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ",
+ relationship, nodeTemplateName, requirementAssignmentName
+ )
+ )
}
val relationShipNodeTemplate = serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName)
- ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ",
- requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ",
+ requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName
+ )
+ )
relationShipNodeTemplate.capabilities?.get(capabilityName)
- ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ",
- requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName))
-
-
+ ?: throw BluePrintException(
+ format(
+ "Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ",
+ requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName
+ )
+ )
}
@Throws(BluePrintException::class)
@@ -366,70 +419,93 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
interfaces?.forEach { interfaceAssignmentName, interfaceAssignment ->
paths.add(interfaceAssignmentName)
val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) interface definition ({}) from" +
- " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type))
-
- validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
- interfaceAssignment)
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) interface definition ({}) from" +
+ " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type
+ )
+ )
+
+ validateInterfaceAssignment(
+ nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
+ interfaceAssignment
+ )
paths.removeAt(paths.lastIndex)
}
paths.removeAt(paths.lastIndex)
-
-
}
@Throws(BluePrintException::class)
- open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String,
- interfaceDefinition: InterfaceDefinition,
- interfaceAssignment: InterfaceAssignment) {
+ open fun validateInterfaceAssignment(
+ nodeTemplateName: String,
+ interfaceAssignmentName: String,
+ interfaceDefinition: InterfaceDefinition,
+ interfaceAssignment: InterfaceAssignment
+ ) {
val operations = interfaceAssignment.operations
operations?.let {
- validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
- interfaceAssignment)
+ validateInterfaceOperationsAssignment(
+ nodeTemplateName, interfaceAssignmentName, interfaceDefinition,
+ interfaceAssignment
+ )
}
-
}
@Throws(BluePrintException::class)
- open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String,
- interfaceDefinition: InterfaceDefinition,
- interfaceAssignment: InterfaceAssignment) {
+ open fun validateInterfaceOperationsAssignment(
+ nodeTemplateName: String,
+ interfaceAssignmentName: String,
+ interfaceDefinition: InterfaceDefinition,
+ interfaceAssignment: InterfaceAssignment
+ ) {
val operations = interfaceAssignment.operations
operations?.let {
it.forEach { operationAssignmentName, operationAssignments ->
val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) ",
- nodeTemplateName, operationAssignmentName))
-
- log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName,
- interfaceAssignmentName, operationAssignmentName)
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) operation definition ({}) ",
+ nodeTemplateName, operationAssignmentName
+ )
+ )
+
+ log.info(
+ "Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName,
+ interfaceAssignmentName, operationAssignmentName
+ )
val inputs = operationAssignments.inputs
val outputs = operationAssignments.outputs
inputs?.forEach { propertyName, propertyAssignment ->
val propertyDefinition = operationDefinition.inputs?.get(propertyName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " +
- "property definition({})", nodeTemplateName, operationAssignmentName, propertyName))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) operation definition ({}) " +
+ "property definition({})", nodeTemplateName, operationAssignmentName, propertyName
+ )
+ )
// Check the property values with property definition
validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
outputs?.forEach { propertyName, propertyAssignment ->
val propertyDefinition = operationDefinition.outputs?.get(propertyName)
- ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " +
- "output property definition({})", nodeTemplateName, operationAssignmentName,
- propertyName))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get NodeTemplate({}) operation definition ({}) " +
+ "output property definition({})", nodeTemplateName, operationAssignmentName,
+ propertyName
+ )
+ )
// Check the property values with property definition
validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
-
}
}
-
}
@Throws(BluePrintException::class)
@@ -447,12 +523,20 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
@Throws(BluePrintException::class)
- open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String,
- capabilityDefinition: CapabilityDefinition) {
+ open fun validateCapabilityDefinition(
+ nodeTypeName: String,
+ nodeType: NodeType,
+ capabilityName: String,
+ capabilityDefinition: CapabilityDefinition
+ ) {
val capabilityType = capabilityDefinition.type
check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) {
- throw BluePrintException(format("Failed to get CapabilityType({}) for NodeType({})",
- capabilityType, nodeTypeName))
+ throw BluePrintException(
+ format(
+ "Failed to get CapabilityType({}) for NodeType({})",
+ capabilityType, nodeTypeName
+ )
+ )
}
}
@@ -471,8 +555,12 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
@Throws(BluePrintException::class)
- open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String,
- requirementDefinition: RequirementDefinition) {
+ open fun validateRequirementDefinition(
+ nodeTypeName: String,
+ nodeType: NodeType,
+ requirementDefinitionName: String,
+ requirementDefinition: RequirementDefinition
+ ) {
log.info("Validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName)
val requirementNodeTypeName = requirementDefinition.node!!
@@ -480,21 +568,31 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
val relationship = requirementDefinition.relationship!!
check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) {
- throw BluePrintException(format("Failed to get relationship({}) for NodeType({})'s requirement({}) ",
- relationship, nodeTypeName, requirementDefinitionName))
+ throw BluePrintException(
+ format(
+ "Failed to get relationship({}) for NodeType({})'s requirement({}) ",
+ relationship, nodeTypeName, requirementDefinitionName
+ )
+ )
}
val relationShipNodeType = serviceTemplate.nodeTypes?.get(requirementNodeTypeName)
- ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s for requirement({}) ",
- requirementNodeTypeName, requirementDefinitionName))
+ ?: throw BluePrintException(
+ format(
+ "Failed to get requirement NodeType({})'s for requirement({}) ",
+ requirementNodeTypeName, requirementDefinitionName
+ )
+ )
relationShipNodeType.capabilities?.get(capabilityName)
- ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ",
- requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName))
-
+ ?: throw BluePrintException(
+ format(
+ "Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ",
+ requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName
+ )
+ )
}
-
@Throws(BluePrintException::class)
open fun validateInterfaceDefinitions(interfaces: MutableMap<String, InterfaceDefinition>) {
paths.add("interfaces")
@@ -530,7 +628,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
+ ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
}
@@ -562,11 +660,10 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
-
} else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
val entrySchemaType = propertyDefinition.entrySchema?.type
- ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
+ ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
checkPropertyDataType(entrySchemaType, propertyName)
@@ -578,18 +675,21 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
}
check(isValid) {
- throw BluePrintException(format("property({}) defined of type({}) is not comptable with the value ({})",
- propertyName, propertyType, propertyAssignment))
+ throw BluePrintException(
+ format(
+ "property({}) defined of type({}) is not comptable with the value ({})",
+ propertyName, propertyType, propertyAssignment
+ )
+ )
}
}
private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
- ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
+ ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
-
}
private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean {
@@ -603,5 +703,4 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService {
private fun checkDataType(key: String): Boolean {
return serviceTemplate.dataTypes?.containsKey(key) ?: false
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
index 2d3c35de7..43e27d047 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintVelocityTemplateService.kt
@@ -34,8 +34,12 @@ object BluePrintVelocityTemplateService {
/**
* Generate Content from Velocity Template and JSON Content with injected API
*/
- fun generateContent(template: String, json: String, ignoreJsonNull: Boolean = false,
- additionalContext: MutableMap<String, Any> = mutableMapOf()): String {
+ fun generateContent(
+ template: String,
+ json: String,
+ ignoreJsonNull: Boolean = false,
+ additionalContext: MutableMap<String, Any> = mutableMapOf()
+ ): String {
// Customized Object Mapper to remove String double quotes
val mapper = ObjectMapper()
@@ -44,7 +48,7 @@ object BluePrintVelocityTemplateService {
val jsonNode: JsonNode? = if (json.isNotEmpty()) {
mapper.readValue(json, JsonNode::class.java)
- ?: throw BluePrintProcessorException("couldn't get json node from json")
+ ?: throw BluePrintProcessorException("couldn't get json node from json")
} else {
null
}
@@ -54,8 +58,12 @@ object BluePrintVelocityTemplateService {
/**
* Generate Content from Velocity Template and JSON Node with injected API
*/
- fun generateContent(template: String, jsonNode: JsonNode?, ignoreJsonNull: Boolean = false,
- additionalContext: MutableMap<String, Any> = mutableMapOf()): String {
+ fun generateContent(
+ template: String,
+ jsonNode: JsonNode?,
+ ignoreJsonNull: Boolean = false,
+ additionalContext: MutableMap<String, Any> = mutableMapOf()
+ ): String {
/*
* create a new instance of the velocity engine
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt
index 5cec3c947..98e5e5aec 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt
@@ -16,15 +16,27 @@
package org.onap.ccsdk.cds.controllerblueprints.core.service
-import kotlinx.coroutines.*
+import kotlinx.coroutines.CancellationException
+import kotlinx.coroutines.CompletableDeferred
+import kotlinx.coroutines.CoroutineName
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import kotlinx.coroutines.launch
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeStatus
import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeStatus
+import org.onap.ccsdk.cds.controllerblueprints.core.incomingEdges
+import org.onap.ccsdk.cds.controllerblueprints.core.isEndNode
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.outgoingEdges
+import org.onap.ccsdk.cds.controllerblueprints.core.outgoingEdgesNotInLabels
+import org.onap.ccsdk.cds.controllerblueprints.core.startNodes
import kotlin.coroutines.CoroutineContext
interface BluePrintWorkFlowService<In, Out> {
@@ -49,7 +61,6 @@ interface BluePrintWorkFlowService<In, Out> {
suspend fun cancelNode(node: Graph.Node, nodeInput: In, nodeOutput: Out): EdgeLabel
suspend fun restartNode(node: Graph.Node, nodeInput: In, nodeOutput: Out): EdgeLabel
-
}
/** Workflow Message Types */
@@ -155,7 +166,6 @@ abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BlueP
}
}
-
private suspend fun nodeActor() = actor<NodeMessage<In, Out>>(coroutineContext, Channel.UNLIMITED) {
/** Send message to process from one state to other state */
@@ -225,8 +235,9 @@ abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BlueP
suspend fun executeNodeWorker(message: NodeExecuteMessage<In, Out>) {
val node = message.node
node.status = NodeStatus.EXECUTING
- val nodeState = if (node.id == BluePrintConstants.GRAPH_START_NODE_NAME
- || node.id == BluePrintConstants.GRAPH_END_NODE_NAME) {
+ val nodeState = if (node.id == BluePrintConstants.GRAPH_START_NODE_NAME ||
+ node.id == BluePrintConstants.GRAPH_END_NODE_NAME
+ ) {
EdgeLabel.SUCCESS
} else {
log.debug("##### Processing workflow($workflowId) node($node) #####")
@@ -339,4 +350,4 @@ abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BlueP
}
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
index e5788a936..2dc8b5cf7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -17,14 +17,25 @@
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
/**
*
@@ -32,19 +43,23 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
* @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)
@@ -84,7 +99,6 @@ If Property Assignment is Expression.
valueNode = bluePrintRuntimeService.resolveDSLExpression(expressionData.dslExpression!!.propertyName)
}
BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> {
-
}
else -> {
throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command))
@@ -122,7 +136,7 @@ If Property Assignment is Expression.
}
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)) {
@@ -130,13 +144,12 @@ If Property Assignment is Expression.
}
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())
@@ -162,11 +175,22 @@ If Property Assignment is Expression.
}
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)
@@ -187,9 +211,11 @@ If Property Assignment is Expression.
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) {
@@ -209,9 +235,13 @@ If Property Assignment is Expression.
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))
}
@@ -227,4 +257,3 @@ If Property Assignment is Expression.
return ""
}
}
-
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
index 097967313..9ccf856b5 100755
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
@@ -21,12 +21,23 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
import com.google.common.base.Predicates
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.slf4j.LoggerFactory
-import java.io.*
-import java.nio.charset.*
-import java.nio.file.*
-import java.nio.file.attribute.*
-import java.util.function.*
-import java.util.zip.*
+import java.io.BufferedInputStream
+import java.io.ByteArrayOutputStream
+import java.io.File
+import java.io.FileOutputStream
+import java.io.IOException
+import java.io.OutputStream
+import java.nio.charset.Charset
+import java.nio.file.FileVisitResult
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.SimpleFileVisitor
+import java.nio.file.attribute.BasicFileAttributes
+import java.util.function.Predicate
+import java.util.zip.Deflater
+import java.util.zip.ZipEntry
+import java.util.zip.ZipFile
+import java.util.zip.ZipOutputStream
class BluePrintArchiveUtils {
@@ -42,7 +53,7 @@ class BluePrintArchiveUtils {
*/
fun compress(source: File, destination: File): Boolean {
try {
- if(!destination.parentFile.exists()) {
+ if (!destination.parentFile.exists()) {
destination.parentFile.mkdirs()
}
destination.createNewFile()
@@ -62,7 +73,7 @@ class BluePrintArchiveUtils {
*/
fun compressToBytes(baseDir: Path, compressionLevel: Int = Deflater.NO_COMPRESSION): ByteArray {
return compressFolder(baseDir, ByteArrayOutputStream(), compressionLevel = compressionLevel)
- .toByteArray()
+ .toByteArray()
}
/**
@@ -75,42 +86,45 @@ class BluePrintArchiveUtils {
* @param fixedModificationTime to force every entry to have this modification time.
* Useful for reproducible operations, like tests, for example.
*/
- private fun <T> compressFolder(baseDir: Path, output: T,
- pathFilter: Predicate<Path> = Predicates.alwaysTrue(),
- compressionLevel: Int = Deflater.DEFAULT_COMPRESSION,
- fixedModificationTime: Long? = null): T
+ private fun <T> compressFolder(
+ baseDir: Path,
+ output: T,
+ pathFilter: Predicate<Path> = Predicates.alwaysTrue(),
+ compressionLevel: Int = Deflater.DEFAULT_COMPRESSION,
+ fixedModificationTime: Long? = null
+ ): T
where T : OutputStream {
ZipOutputStream(output)
- .apply { setLevel(compressionLevel) }
- .use { zos ->
- Files.walkFileTree(baseDir, object : SimpleFileVisitor<Path>() {
- @Throws(IOException::class)
- override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
- if (pathFilter.test(file)) {
- val zipEntry = ZipEntry(baseDir.relativize(file).toString())
- fixedModificationTime?.let {
- zipEntry.time = it
- }
- zipEntry.time = 0;
- zos.putNextEntry(zipEntry)
- Files.copy(file, zos)
- zos.closeEntry()
- }
- return FileVisitResult.CONTINUE
- }
-
- @Throws(IOException::class)
- override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
- val zipEntry = ZipEntry(baseDir.relativize(dir).toString() + "/")
+ .apply { setLevel(compressionLevel) }
+ .use { zos ->
+ Files.walkFileTree(baseDir, object : SimpleFileVisitor<Path>() {
+ @Throws(IOException::class)
+ override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
+ if (pathFilter.test(file)) {
+ val zipEntry = ZipEntry(baseDir.relativize(file).toString())
fixedModificationTime?.let {
zipEntry.time = it
}
+ zipEntry.time = 0
zos.putNextEntry(zipEntry)
+ Files.copy(file, zos)
zos.closeEntry()
- return FileVisitResult.CONTINUE
}
- })
- }
+ return FileVisitResult.CONTINUE
+ }
+
+ @Throws(IOException::class)
+ override fun preVisitDirectory(dir: Path, attrs: BasicFileAttributes): FileVisitResult {
+ val zipEntry = ZipEntry(baseDir.relativize(dir).toString() + "/")
+ fixedModificationTime?.let {
+ zipEntry.time = it
+ }
+ zos.putNextEntry(zipEntry)
+ zos.closeEntry()
+ return FileVisitResult.CONTINUE
+ }
+ })
+ }
return output
}
@@ -141,5 +155,4 @@ class BluePrintArchiveUtils {
return destinationDir
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
index 06f6f1d17..6605e8eca 100755
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
@@ -32,8 +32,10 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.slf4j.LoggerFactory
import java.io.File
import java.io.FileFilter
-import java.nio.file.*
-
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.nio.file.StandardOpenOption
class BluePrintFileUtils {
companion object {
@@ -50,8 +52,12 @@ class BluePrintFileUtils {
val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR))
Files.createDirectories(metaDataDir.toPath())
- val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants
- .TOSCA_METADATA_ENTRY_DEFINITION_FILE))
+ val metaFile = File(
+ blueprintDir.absolutePath.plus(File.separator).plus(
+ BluePrintConstants
+ .TOSCA_METADATA_ENTRY_DEFINITION_FILE
+ )
+ )
Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW)
val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR))
@@ -65,7 +71,6 @@ class BluePrintFileUtils {
val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR))
Files.createDirectories(templatesDir.toPath())
-
}
fun copyBluePrint(sourcePath: String, targetPath: String) {
@@ -95,7 +100,6 @@ class BluePrintFileUtils {
populateDefaultImports(blueprintContext)
// Rewrite the Entry Definition Files
writeEntryDefinitionFile(blueprintContext)
-
}
fun writeBluePrintTypes(blueprintContext: BluePrintContext) {
@@ -105,8 +109,10 @@ class BluePrintFileUtils {
val definitionDir = File(definitionPath)
check(definitionDir.exists()) {
- throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " +
- "path(${definitionDir.absolutePath})")
+ throw BluePrintException(
+ ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " +
+ "path(${definitionDir.absolutePath})"
+ )
}
blueprintContext.serviceTemplate.dataTypes?.let {
@@ -137,9 +143,11 @@ class BluePrintFileUtils {
private fun populateDefaultImports(blueprintContext: BluePrintContext) {
// Get the Default Types
- val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES,
- BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES,
- BluePrintConstants.PATH_POLICY_TYPES)
+ val types = arrayListOf(
+ BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES,
+ BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES,
+ BluePrintConstants.PATH_POLICY_TYPES
+ )
// Clean Type Imports
cleanImportTypes(blueprintContext.serviceTemplate)
@@ -193,8 +201,10 @@ class BluePrintFileUtils {
Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW)
check(definitionFile.exists()) {
- throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " +
- "path(${definitionFile.absolutePath})")
+ throw BluePrintException(
+ ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " +
+ "path(${definitionFile.absolutePath})"
+ )
}
}
@@ -203,8 +213,10 @@ class BluePrintFileUtils {
Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW)
check(typeFile.exists()) {
- throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " +
- "path(${typeFile.absolutePath})")
+ throw BluePrintException(
+ ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " +
+ "path(${typeFile.absolutePath})"
+ )
}
}
@@ -213,26 +225,29 @@ class BluePrintFileUtils {
"\nCSAR-Version: <VERSION>" +
"\nCreated-By: <AUTHOR NAME>" +
"\nEntry-Definitions: Definitions/<BLUEPRINT_NAME>.json" +
- "\nTemplate-Name: <BLUEPRINT_NAME>"+
- "\nTemplate-Tags: <BLUEPRINT_VERSION>"+
+ "\nTemplate-Name: <BLUEPRINT_NAME>" +
+ "\nTemplate-Tags: <BLUEPRINT_VERSION>" +
"\nTemplate-Tags: <TAGS>"
}
-
fun getBluePrintFile(fileName: String, targetPath: Path): File {
val filePath = targetPath.resolve(fileName).toString()
val file = File(filePath)
check(file.exists()) {
- throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " +
- "path(${file.absolutePath})")
+ throw BluePrintException(
+ ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " +
+ "path(${file.absolutePath})"
+ )
}
return file
}
fun getCbaStorageDirectory(path: String): Path {
check(StringUtils.isNotBlank(path)) {
- throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " +
- "Blueprint folder under path($path)")
+ throw BluePrintException(
+ ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " +
+ "Blueprint folder under path($path)"
+ )
}
val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize()
@@ -252,13 +267,19 @@ class BluePrintFileUtils {
}
fun compileJarFilePathName(basePath: String, artifactName: String, artifactVersion: String): String {
- return normalizedPathName(basePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR,
- compileJarFileName(artifactName, artifactVersion))
+ return normalizedPathName(
+ basePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR,
+ compileJarFileName(artifactName, artifactVersion)
+ )
}
fun compileJarFile(basePath: String, artifactName: String, artifactVersion: String): File {
- return normalizedFile(compileJarFilePathName(basePath,
- artifactName, artifactVersion))
+ return normalizedFile(
+ compileJarFilePathName(
+ basePath,
+ artifactName, artifactVersion
+ )
+ )
}
fun stripFileExtension(fileName: String): String {
@@ -267,6 +288,5 @@ class BluePrintFileUtils {
// In case dot is in first position, we are dealing with a hidden file rather than an extension
return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName
}
-
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt
index 226c62d48..d29fed0d9 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintIOUtils.kt
@@ -18,8 +18,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
object BluePrintIOUtils {
- suspend fun <T> retry(times: Int = 1, initialDelay: Long = 0, delay: Long = 1000,
- block: suspend (Int) -> T, exceptionBlock: (e: Exception) -> Unit): T {
+ suspend fun <T> retry(
+ times: Int = 1,
+ initialDelay: Long = 0,
+ delay: Long = 1000,
+ block: suspend (Int) -> T,
+ exceptionBlock: (e: Exception) -> Unit
+ ): T {
var currentDelay = initialDelay
val currentTimes = times - 1
repeat(currentTimes) { count ->
@@ -33,4 +38,4 @@ object BluePrintIOUtils {
}
return block(currentTimes)
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
index 55424ada8..4d7647f47 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
@@ -17,12 +17,16 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-
import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.runBlocking
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintDefinitions
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines
import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService
@@ -30,28 +34,27 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.slf4j.LoggerFactory
import java.io.File
-import java.util.*
+import java.util.Properties
class BluePrintMetadataUtils {
companion object {
private val log = LoggerFactory.getLogger(this::class.toString())
-
suspend fun toscaMetaData(basePath: String): ToscaMetaData {
val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
+ .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
return toscaMetaDataFromMetaFile(toscaMetaPath)
}
suspend fun entryDefinitionFile(basePath: String): String {
val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
- .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
+ .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions
}
fun bluePrintEnvProperties(basePath: String): Properties {
val blueprintsEnvFilePath = basePath.plus(File.separator)
- .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
+ .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
return environmentFileProperties(blueprintsEnvFilePath)
}
@@ -60,14 +63,14 @@ class BluePrintMetadataUtils {
val envDir = normalizedFile(pathName)
// Verify if the environment directory exists
if (envDir.exists() && envDir.isDirectory) {
- //Find all available environment files
+ // Find all available environment files
envDir.listFiles()!!
- .filter { it.name.endsWith(".properties") }
- .forEach {
- val istream = it.inputStream()
- properties.load(istream)
- istream.close()
- }
+ .filter { it.name.endsWith(".properties") }
+ .forEach {
+ val istream = it.inputStream()
+ properties.load(istream)
+ istream.close()
+ }
}
return properties
}
@@ -91,19 +94,18 @@ class BluePrintMetadataUtils {
}
}
}
-
}
return toscaMetaData
}
- fun getBluePrintRuntime(id: String, blueprintBasePath: String)
- : BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ fun getBluePrintRuntime(id: String, blueprintBasePath: String):
+ BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
return getBluePrintRuntime(id, bluePrintContext)
}
- fun getBluePrintRuntime(id: String, bluePrintContext: BluePrintContext)
- : BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ fun getBluePrintRuntime(id: String, bluePrintContext: BluePrintContext):
+ BluePrintRuntimeService<MutableMap<String, JsonNode>> {
checkNotEmpty(bluePrintContext.rootPath) { "blueprint context root path is missing." }
checkNotEmpty(bluePrintContext.entryDefinition) { "blueprint context entry definition is missing." }
val blueprintBasePath = bluePrintContext.rootPath
@@ -113,8 +115,8 @@ class BluePrintMetadataUtils {
return bluePrintRuntimeService
}
- suspend fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String)
- : BluePrintRuntimeService<MutableMap<String, JsonNode>> {
+ suspend fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String):
+ BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath)
@@ -191,8 +193,10 @@ class BluePrintMetadataUtils {
val bluePrintScriptsService = BluePrintScriptsServiceImpl()
val bluePrintDefinitions = bluePrintScriptsService
- .scriptInstance<BluePrintDefinitions>(normalizedBasePath, toscaMetaData.templateName!!,
- toscaMetaData.templateVersion!!, definitionClassName, false)
+ .scriptInstance<BluePrintDefinitions>(
+ normalizedBasePath, toscaMetaData.templateName!!,
+ toscaMetaData.templateVersion!!, definitionClassName, false
+ )
// Get the Service Template
val serviceTemplate = bluePrintDefinitions.serviceTemplate()
@@ -206,4 +210,4 @@ class BluePrintMetadataUtils {
return blueprintContext
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
index 3dd756763..c44355070 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
@@ -16,11 +16,11 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.slf4j.LoggerFactory
/**
*
@@ -28,15 +28,20 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
* @author Brinda Santh
*/
object BluePrintRuntimeUtils {
- private val log= LoggerFactory.getLogger(this::class.toString())
+
+ private val log = LoggerFactory.getLogger(this::class.toString())
fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) {
val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName)
return assignInputs(bluePrintContext, jsonNode, context)
}
- fun assignInputsFromClassPathFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String,
- JsonNode>) {
+ fun assignInputsFromClassPathFile(
+ bluePrintContext: BluePrintContext,
+ fileName: String,
+ context: MutableMap<String,
+ JsonNode>
+ ) {
val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName)
return assignInputs(bluePrintContext, jsonNode, context)
}
@@ -56,5 +61,4 @@ object BluePrintRuntimeUtils {
context[path] = valueNode
}
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt
index 9fbc38507..6645ff7b4 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt
@@ -17,34 +17,36 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.slf4j.LoggerFactory
import java.io.File
import java.nio.charset.Charset
class JacksonReactorUtils {
companion object {
- private val log= LoggerFactory.getLogger(this::class.toString())
+ private val log = LoggerFactory.getLogger(this::class.toString())
suspend fun getContent(fileName: String): String {
- //log.info("Reading File($fileName)")
+ // log.info("Reading File($fileName)")
return getContent(normalizedFile(fileName))
}
- suspend fun getContent(file: File): String = withContext(Dispatchers.IO) {
+ suspend fun getContent(file: File): String = withContext(Dispatchers.IO) {
// log.info("Reading File(${file.absolutePath})")
file.readText(Charsets.UTF_8)
}
suspend fun getClassPathFileContent(fileName: String): String = withContext(Dispatchers.IO) {
- //log.trace("Reading Classpath File($fileName)")
- IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
+ // log.trace("Reading Classpath File($fileName)")
+ IOUtils.toString(
+ JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset()
+ )
}
suspend fun <T> readValueFromFile(fileName: String, valueType: Class<T>): T? {
@@ -86,6 +88,5 @@ class JacksonReactorUtils {
val content: String = getClassPathFileContent(fileName)
return JacksonUtils.getMapFromJson(content, valueType)
}
-
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
index 1f1345327..945f300af 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
@@ -19,13 +19,26 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
-import com.fasterxml.jackson.databind.node.*
+import com.fasterxml.jackson.databind.node.ArrayNode
+import com.fasterxml.jackson.databind.node.BooleanNode
+import com.fasterxml.jackson.databind.node.DoubleNode
+import com.fasterxml.jackson.databind.node.FloatNode
+import com.fasterxml.jackson.databind.node.IntNode
+import com.fasterxml.jackson.databind.node.MissingNode
+import com.fasterxml.jackson.databind.node.NullNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.TextNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
import java.io.File
import java.io.InputStream
import java.nio.charset.Charset
@@ -36,15 +49,16 @@ import java.nio.charset.Charset
* @author Brinda Santh
*/
class JacksonUtils {
+
companion object {
val objectMapper = jacksonObjectMapper()
inline fun <reified T : Any> readValue(content: String): T =
- objectMapper.readValue(content, T::class.java)
+ objectMapper.readValue(content, T::class.java)
inline fun <reified T : Any> readValue(stream: InputStream): T =
- objectMapper.readValue(stream, T::class.java)
+ objectMapper.readValue(stream, T::class.java)
fun <T> readValue(content: String, valueType: Class<T>): T? {
return objectMapper.readValue(content, valueType)
@@ -69,8 +83,10 @@ class JacksonUtils {
fun getClassPathFileContent(fileName: String): String {
return runBlocking {
withContext(Dispatchers.Default) {
- IOUtils.toString(JacksonUtils::class.java.classLoader
- .getResourceAsStream(fileName), Charset.defaultCharset())
+ IOUtils.toString(
+ JacksonUtils::class.java.classLoader
+ .getResourceAsStream(fileName), Charset.defaultCharset()
+ )
}
}
}
@@ -170,7 +186,7 @@ class JacksonUtils {
fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
return readValue(getJson(properties), classType)
- ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
+ ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
}
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
@@ -265,14 +281,14 @@ class JacksonUtils {
}
fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
- val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) ?:
- throw BluePrintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)")
+ val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType)
+ ?: throw BluePrintException("populatePrimitiveDefaultValues expected only primitive values! Received type ($primitiveType)")
objectNode.set(key, defaultValue)
}
fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
- val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType) ?:
- throw BluePrintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)")
+ val defaultValue = getDefaultValueOfPrimitiveAsJsonNode(primitiveType)
+ ?: throw BluePrintException("populatePrimitiveDefaultValuesForArrayNode expected only primitive values! Received type ($primitiveType)")
arrayNode.add(defaultValue)
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
index 19686b5df..0e3d4f93d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JsonParserUtils.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-
import com.fasterxml.jackson.databind.JsonNode
import com.jayway.jsonpath.Configuration
import com.jayway.jsonpath.JsonPath
@@ -29,9 +28,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString
class JsonParserUtils {
companion object {
- //TODO("Optimise this")
+ // TODO("Optimise this")
val JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder()
- .mappingProvider(JacksonMappingProvider()).jsonProvider(JacksonJsonNodeJsonProvider()).build()
+ .mappingProvider(JacksonMappingProvider()).jsonProvider(JacksonJsonNodeJsonProvider()).build()
val PATH_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST).build()
@@ -60,4 +59,4 @@ class JsonParserUtils {
return parseNSet(jsonNode.asJsonString(), expression, valueNode)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt
index f06cc107d..c0204af8d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt
@@ -29,19 +29,20 @@ import java.net.URL
* @author Brinda Santh
*/
object ResourceResolverUtils {
- private val log= LoggerFactory.getLogger(this::class.toString())
+
+ private val log = LoggerFactory.getLogger(this::class.toString())
fun getFileContent(filename: String, basePath: String?): String {
log.trace("file ({}), basePath ({}) ", filename, basePath)
try {
var resolvedFileName: String = filename
- if (filename.startsWith("http", true)
- || filename.startsWith("https", true)) {
+ if (filename.startsWith("http", true) ||
+ filename.startsWith("https", true)
+ ) {
val givenUrl: String = URL(filename).toString()
val systemUrl: String = File(".").toURI().toURL().toString()
log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl)
if (givenUrl.startsWith(systemUrl)) {
-
}
} else {
if (!filename.startsWith("/")) {
@@ -52,10 +53,10 @@ object ResourceResolverUtils {
}
}
}
- //FIXME("Convert into reactive")
+ // FIXME("Convert into reactive")
return JacksonUtils.getContent(resolvedFileName)
} catch (e: Exception) {
throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath)
}
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt
index 091e85659..a74722f31 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ServiceTemplateUtils.kt
@@ -76,33 +76,33 @@ object ServiceTemplateUtils {
toMerge.topologyTemplate?.inputs?.let {
parentServiceTemplate.topologyTemplate?.inputs = parentServiceTemplate.topologyTemplate?.inputs
- ?: hashMapOf()
+ ?: hashMapOf()
parentServiceTemplate.topologyTemplate?.inputs?.putAll(parentServiceTemplate.topologyTemplate?.inputs as MutableMap)
}
toMerge.topologyTemplate?.nodeTemplates?.let {
parentServiceTemplate.topologyTemplate?.nodeTemplates = parentServiceTemplate.topologyTemplate?.nodeTemplates
- ?: hashMapOf()
+ ?: hashMapOf()
parentServiceTemplate.topologyTemplate?.nodeTemplates?.putAll(parentServiceTemplate.topologyTemplate?.nodeTemplates as MutableMap)
}
toMerge.topologyTemplate?.relationshipTemplates?.let {
parentServiceTemplate.topologyTemplate?.relationshipTemplates = parentServiceTemplate.topologyTemplate?.relationshipTemplates
- ?: hashMapOf()
+ ?: hashMapOf()
parentServiceTemplate.topologyTemplate?.relationshipTemplates?.putAll(parentServiceTemplate.topologyTemplate?.relationshipTemplates as MutableMap)
}
toMerge.topologyTemplate?.policies?.let {
parentServiceTemplate.topologyTemplate?.policies = parentServiceTemplate.topologyTemplate?.policies
- ?: hashMapOf()
+ ?: hashMapOf()
parentServiceTemplate.topologyTemplate?.policies?.putAll(parentServiceTemplate.topologyTemplate?.policies as MutableMap)
}
toMerge.topologyTemplate?.workflows?.let {
parentServiceTemplate.topologyTemplate?.workflows = parentServiceTemplate.topologyTemplate?.workflows
- ?: hashMapOf()
+ ?: hashMapOf()
parentServiceTemplate.topologyTemplate?.workflows?.putAll(parentServiceTemplate.topologyTemplate?.workflows as MutableMap)
}
return parentServiceTemplate
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtils.kt
index 0b76130a3..fb990c486 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtils.kt
@@ -16,7 +16,10 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-import java.util.*
+import java.util.ArrayList
+import java.util.HashMap
+import java.util.LinkedList
+import java.util.Stack
/**
*
@@ -70,14 +73,13 @@ class TopologicalSortingUtils<V> {
return result
}
-
fun inDegree(): MutableMap<V, Int> {
val result = HashMap<V, Int>()
for (v in neighbors.keys)
- result[v] = 0 // All in-degrees are 0
+ result[v] = 0 // All in-degrees are 0
for (from in neighbors.keys) {
for (to in neighbors[from]!!) {
- result[to] = result[to]!! + 1 // Increment in-degree
+ result[to] = result[to]!! + 1 // Increment in-degree
}
}
return result
@@ -86,15 +88,15 @@ class TopologicalSortingUtils<V> {
fun topSort(): List<V>? {
val degree = inDegree()
// Determine all vertices with zero in-degree
- val zeroVerts = Stack<V>() // Stack as good as any here
+ val zeroVerts = Stack<V>() // Stack as good as any here
for (v in degree.keys) {
if (degree[v] == 0) zeroVerts.push(v)
}
// Determine the topological order
val result = ArrayList<V>()
while (!zeroVerts.isEmpty()) {
- val v = zeroVerts.pop() // Choose a vertex with zero in-degree
- result.add(v) // Vertex v is next in topol order
+ val v = zeroVerts.pop() // Choose a vertex with zero in-degree
+ result.add(v) // Vertex v is next in topol order
// "Remove" vertex v by updating its neighbors
for (neighbor in neighbors[v]!!) {
degree[neighbor] = degree[neighbor]!! - 1
@@ -106,7 +108,6 @@ class TopologicalSortingUtils<V> {
return if (result.size != neighbors.size) null else result
}
-
fun bfsDistance(start: V): Map<*, *> {
val distance: MutableMap<V, Int> = hashMapOf()
// Initially, all distance are infinity, except start node
@@ -115,17 +116,17 @@ class TopologicalSortingUtils<V> {
distance[start] = 0
// Process nodes in queue order
val queue = LinkedList<V>()
- queue.offer(start) // Place start node in queue
+ queue.offer(start) // Place start node in queue
while (!queue.isEmpty()) {
val v = queue.remove()
val vDist = distance[v]!!
// Update neighbors
for (neighbor in neighbors[v]!!) {
- if (distance[neighbor] != null) continue // Ignore if already done
+ if (distance[neighbor] != null) continue // Ignore if already done
distance[neighbor] = vDist + 1
queue.offer(neighbor)
}
}
return distance
}
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt
index ef765ab86..fea637f61 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/WorkflowGraphUtils.kt
@@ -43,4 +43,4 @@ object WorkflowGraphUtils {
}
return graph
}
-} \ No newline at end of file
+}