aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt101
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt19
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTypeEnhancerServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt51
5 files changed, 141 insertions, 36 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
new file mode 100644
index 00000000..986ce986
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionEnhancer
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
+ : BluePrintArtifactDefinitionEnhancer {
+
+ companion object {
+ const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
+ }
+
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionEnhancerImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) {
+ log.info("enhancing ArtifactDefinition($name)")
+
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val artifactTypeName = artifactDefinition.type
+ ?: throw BluePrintException("Artifact type is missing for ArtifactDefinition($name)")
+
+ // Populate Artifact Type
+ populateArtifactType(artifactTypeName)
+
+ when (artifactTypeName) {
+ ARTIFACT_TYPE_MAPPING_SOURCE -> {
+ enhanceMappingType(name, artifactDefinition)
+ }
+ }
+ }
+
+ // Enhance Resource Mapping
+ open fun enhanceMappingType(name: String, artifactDefinition: ArtifactDefinition) {
+
+ val artifactFilePath = "${bluePrintContext.rootPath}/${artifactDefinition.file}"
+
+ val alreadyEnhancedKey = "enhanced-${artifactDefinition.file}"
+ val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey)
+
+ log.info("enhancing resource mapping file(${artifactDefinition.file}) already enhanced($alreadyEnhanced)")
+
+ if (!alreadyEnhanced) {
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(artifactFilePath, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)")
+
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+
+ bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive())
+ }
+ }
+
+ open fun populateArtifactType(artifactTypeName: String): ArtifactType {
+
+ val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
+ bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
+ return artifactType
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
index cfbfab71..fb6c06af 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
@@ -18,9 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
import org.onap.ccsdk.apps.controllerblueprints.core.format
@@ -46,7 +44,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
- log.info("Enhancing NodeTemplate($name)")
+ log.info("***** Enhancing NodeTemplate($name)")
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -75,20 +73,9 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
- val artifactTypeName = artifactDefinition.type
- ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName))
-
- // Populate Artifact Type
- populateArtifactType(artifactTypeName)
+ // Enhance Artifacct Definitions
+ bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)
}
}
- open fun populateArtifactType(artifactTypeName: String): ArtifactType {
- val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)
- ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
- bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
- return artifactType
- }
-
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
index 6a4f6232..2ad0583e 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Service
open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintServiceTemplateEnhancer {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString())
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTypeEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTypeEnhancerServiceImpl.kt
index 3128b6c6..02a19c3f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTypeEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintTypeEnhancerServiceImpl.kt
@@ -47,6 +47,10 @@ open class BluePrintTypeEnhancerServiceImpl : BluePrintTypeEnhancerService {
return context.getBeansOfType(BluePrintNodeTypeEnhancer::class.java).map { it.value }
}
+ override fun getArtifactDefinitionEnhancers(): List<BluePrintArtifactDefinitionEnhancer> {
+ return context.getBeansOfType(BluePrintArtifactDefinitionEnhancer::class.java).map { it.value }
+ }
+
override fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer> {
return context.getBeansOfType(BluePrintPolicyTypeEnhancer::class.java).map { it.value }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
index e3a8f222..a620e9bf 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -21,6 +21,7 @@ import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
@@ -41,19 +42,21 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
: BluePrintWorkflowEnhancer {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintWorkflowEnhancerImpl::class.toString())
+
+ companion object {
+ const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
+ const val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
+ }
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
- val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
-
-
private val workflowDataTypes: MutableMap<String, DataType> = hashMapOf()
override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
- log.info("Enhancing Workflow($name)")
- this.bluePrintRuntimeService = bluePrintRuntimeService
+ log.info("##### Enhancing Workflow($name)")
+ this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val dynamicPropertyName = "$name-properties"
@@ -94,10 +97,11 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
// Check and Get Resource Assignment File
val resourceAssignmentArtifacts = dependencyNodeTemplates?.mapNotNull { componentNodeTemplateName ->
- log.info("Identified workflow($name) targets($componentNodeTemplateName")
+ log.info("identified workflow($name) targets($componentNodeTemplateName)")
+
val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName)
.artifacts?.filter {
- it.value.type == "artifact-mapping-resource"
+ it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE
}?.map {
log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})")
it.value.file
@@ -105,7 +109,7 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
resourceAssignmentArtifacts
}?.flatten()
- log.info("Workflow($name) resource assignment files($resourceAssignmentArtifacts")
+ log.info("workflow($name) resource assignment files($resourceAssignmentArtifacts")
if (resourceAssignmentArtifacts != null && resourceAssignmentArtifacts.isNotEmpty()) {
@@ -113,19 +117,20 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
addWorkFlowDynamicPropertyDefinitions(name, workflow)
resourceAssignmentArtifacts.forEach { fileName ->
-
- val absoluteFilePath = "${bluePrintContext.rootPath}/$fileName"
-
- log.info("enriching workflow($name) artifacts file(${absoluteFilePath}")
// Enhance Resource Assignment File
- val resourceAssignmentProperties = enhanceResourceAssignmentFile(absoluteFilePath)
+ val resourceAssignmentProperties = enhanceResourceAssignmentFile(fileName!!)
// Add Workflow Dynamic DataType
addWorkFlowDynamicDataType(name, resourceAssignmentProperties)
}
}
}
- private fun enhanceResourceAssignmentFile(filePath: String): MutableMap<String, PropertyDefinition> {
+ // Enhancement for Dynamic Properties, Resource Assignment Properties, Resource Sources
+ private fun enhanceResourceAssignmentFile(fileName: String): MutableMap<String, PropertyDefinition> {
+
+ val filePath = "${bluePrintContext.rootPath}/$fileName"
+
+ log.info("enriching artifacts file(${filePath}")
val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
@@ -133,8 +138,16 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
as? MutableList<ResourceAssignment>
?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
- // Call Resource Assignment Enhancer
- resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+ val alreadyEnhancedKey = "enhanced-$fileName"
+ val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey)
+
+ log.info("enhancing workflow resource mapping file($fileName) already enhanced($alreadyEnhanced)")
+
+ if (!alreadyEnhanced) {
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+ bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive())
+ }
resourceAssignments.forEach { resourceAssignment ->
resourceAssignmentProperties[resourceAssignment.name] = resourceAssignment.property!!
@@ -159,7 +172,7 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
var recipeDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
if (recipeDataType == null) {
- log.info("DataType not present for the recipe({})", dataTypeName)
+ log.info("dataType not present for the recipe({})", dataTypeName)
recipeDataType = DataType()
recipeDataType.version = "1.0.0"
recipeDataType.description = "Dynamic DataType definition for workflow($workflowName)."
@@ -172,7 +185,7 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, recipeDataType)
} else {
- log.info("Dynamic dataType($dataTypeName) already present for workflow($workflowName).")
+ log.info("dynamic dataType($dataTypeName) already present for workflow($workflowName).")
}
// Merge all the Recipe Properties
mappingProperties.forEach { propertyName, propertyDefinition ->