summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <bs2796@att.com>2019-01-08 20:59:31 -0500
committerBrinda Santh Muthuramalingam <bs2796@att.com>2019-01-10 19:59:45 +0000
commit2ff2075d4a7035516cab7b04ac71d6c9eaad3c74 (patch)
treec7a8a6f49516df6eb68d96feb0126fd5bf60cf2c /ms/controllerblueprints/modules
parent1393e526211aa64852ff27d322af411e205c35a4 (diff)
Add relationships type enhancement logic.
Change-Id: If8f072f49ccc74502052055bce0c90dd43ebd495 Issue-ID: CCSDK-920 Signed-off-by: Muthuramalingam, Brinda Santh <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules')
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt27
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt7
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt14
4 files changed, 38 insertions, 14 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index d78959576..d4e4a24cb 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -21,7 +21,6 @@ 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.interfaces.BluePrintEnhancerService
-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
@@ -31,8 +30,7 @@ import org.springframework.stereotype.Service
import java.util.*
@Service
-open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
index 4e226b2e2..6ff0b39be 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
@@ -18,6 +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.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.InterfaceDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
@@ -57,7 +58,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
// NodeType Attribute Definitions
- enrichNodeTypeAtributes(name, nodeType)
+ enrichNodeTypeAttributes(name, nodeType)
// NodeType Property Definitions
enrichNodeTypeProperties(name, nodeType)
@@ -73,7 +74,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
- open fun enrichNodeTypeAtributes(nodeTypeName: String, nodeType: NodeType) {
+ open fun enrichNodeTypeAttributes(nodeTypeName: String, nodeType: NodeType) {
nodeType.attributes?.let {
bluePrintTypeEnhancerService.enhanceAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
}
@@ -87,14 +88,20 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
- nodeType.requirements?.forEach { _, requirementDefinition ->
+ nodeType.requirements?.forEach { requirementName, requirementDefinition ->
// Populate Requirement Node
requirementDefinition.node?.let { requirementNodeTypeName ->
// Get Requirement NodeType from Repo and Update Service Template
val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext,
bluePrintRepoService, requirementNodeTypeName)
- // Enhanypece Node T
+ // Enhance Node Type
enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
+
+ // Enhance Relationship Type
+ val relationShipTypeName = requirementDefinition.relationship
+ ?: throw BluePrintException("couldn't get relationship name for the NodeType($nodeTypeName) " +
+ "Requirement($requirementName)")
+ enrichRelationShipType(relationShipTypeName)
}
}
}
@@ -120,7 +127,7 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
interfaceObj.operations?.forEach { operationName, operation ->
enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)
- enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)
+ enrichNodeTypeInterfaceOperationOutputs(nodeTypeName, operationName, operation)
}
}
@@ -130,10 +137,18 @@ open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
- open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ open fun enrichNodeTypeInterfaceOperationOutputs(nodeTypeName: String, operationName: String,
+ operation: OperationDefinition) {
operation.outputs?.let { inputs ->
bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
}
}
+ /**
+ * Get the Relationship Type from database and add to Blueprint Context
+ */
+ open fun enrichRelationShipType(relationshipName: String) {
+ BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, relationshipName)
+ }
+
} \ 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 51064bb43..8c269e546 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
@@ -19,7 +19,6 @@ 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.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
@@ -30,8 +29,7 @@ import org.springframework.stereotype.Service
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
- private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
: BluePrintServiceTemplateEnhancer {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString())
@@ -52,11 +50,14 @@ open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService
bluePrintContext.serviceTemplate.nodeTypes?.clear()
bluePrintContext.serviceTemplate.dataTypes?.clear()
bluePrintContext.serviceTemplate.policyTypes?.clear()
+ bluePrintContext.serviceTemplate.relationshipTypes?.clear()
bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf()
+ log.info("reinitialized all type definitions")
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
index 2f18abfdd..c2d6f6aa5 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
@@ -21,7 +21,7 @@ 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.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
-import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.data.RelationshipType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.springframework.http.codec.multipart.FilePart
@@ -45,13 +45,23 @@ class BluePrintEnhancerUtils {
return dataType
}
+ fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ relationshipName: String): RelationshipType {
+
+ val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName)
+ ?: bluePrintRepoService.getRelationshipType(relationshipName)
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.")
+ bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType)
+ return relationshipType
+ }
+
fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
nodeTypeName: String): NodeType {
val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
?: bluePrintRepoService.getNodeType(nodeTypeName)
- ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.")
bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
}