diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-12-11 19:40:51 -0500 |
---|---|---|
committer | Brinda Santh Muthuramalingam <bs2796@att.com> | 2018-12-12 00:55:13 +0000 |
commit | a490a2830aaa1345fd506df5dd4d913c67784da6 (patch) | |
tree | e7ea8440e27091fed94b9dee6826c497afcf253e /ms/controllerblueprints/modules/service/src/main/kotlin | |
parent | 48ad27be38076542c22ef672937edd2f7edc2627 (diff) |
Implement Enhancer Framework Interfaces
Change-Id: Iff85dc50f87ab6d6f7d9ceb4a309ea6e4d55e362
Issue-ID: CCSDK-803
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/main/kotlin')
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt (renamed from ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt) | 47 | ||||
-rw-r--r-- | ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt | 54 |
2 files changed, 36 insertions, 65 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt index 2c13d864c..d2a7d226f 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt @@ -23,44 +23,15 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import java.io.Serializable
-/**
- * BluePrintEnhancerService
- * @author Brinda Santh
- *
- */
-interface BluePrintEnhancerService : Serializable {
-
- @Throws(BluePrintException::class)
- fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext
-
- /**
- * Read Blueprint from CBA structure Directory
- */
- @Throws(BluePrintException::class)
- fun enhance(basePath: String): BluePrintContext
-
- @Throws(BluePrintException::class)
- fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
-
- @Throws(BluePrintException::class)
- fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate)
-
- @Throws(BluePrintException::class)
- fun enrichNodeType(nodeTypeName: String, nodeType: NodeType)
-
- @Throws(BluePrintException::class)
- fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition)
-}
-
-open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
+open class BluePrintEnhancerServiceImpl(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
lateinit var serviceTemplate: ServiceTemplate
@@ -124,7 +95,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
@Throws(BluePrintException::class)
- override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+ open fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
val nodeType = populateNodeType(nodeTypeName)
@@ -137,7 +108,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
@Throws(BluePrintException::class)
- override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
+ fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
log.debug("Enriching NodeType({})", nodeTypeName)
val derivedFrom = nodeType.derivedFrom
@@ -222,7 +193,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe }
@Throws(BluePrintException::class)
- override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
+ fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
val propertyType = propertyDefinition.type
if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
@@ -253,7 +224,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateNodeType(nodeTypeName: String): NodeType {
val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName).block()
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
return nodeType
@@ -261,7 +232,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateArtifactType(artifactTypeName: String): ArtifactType {
val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName).block()
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)
?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
return artifactType
@@ -269,7 +240,7 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe open fun populateDataTypes(dataTypeName: String): DataType {
val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
- ?: bluePrintRepoService.getDataType(dataTypeName).block()
+ ?: bluePrintRepoService.getDataType(dataTypeName)
?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
serviceTemplate.dataTypes?.put(dataTypeName, dataType)
return dataType
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt index de6f82ffe..d3bc636b5 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt @@ -17,16 +17,17 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
import com.att.eelf.configuration.EELFLogger
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
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.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService
import org.springframework.stereotype.Service
@@ -38,11 +39,9 @@ import org.springframework.stereotype.Service interface ResourceAssignmentEnhancerService {
@Throws(BluePrintException::class)
- fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintContext: BluePrintContext, error: BluePrintError,
resourceAssignments: List<ResourceAssignment>)
-
- @Throws(BluePrintException::class)
- fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate
}
/**
@@ -51,15 +50,16 @@ interface ResourceAssignmentEnhancerService { * @author Brinda Santh
*/
@Service
-open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
+open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
: ResourceAssignmentEnhancerService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceImpl::class.java)
/**
* Get the defined source instance from the ResourceAssignment,
* then get the NodeType of the Sources assigned
*/
- override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintContext: BluePrintContext, error: BluePrintError,
resourceAssignments: List<ResourceAssignment>) {
val uniqueSourceNodeTypeNames = hashSetOf<String>()
@@ -78,7 +78,8 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti // TODO("Candidate for Optimisation")
if (checkResourceDefinitionNeeded(resourceAssignment)) {
- bluePrintEnhancerService.enrichPropertyDefinition(resourceAssignment.name, resourceAssignment.property!!);
+ bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintContext, error, resourceAssignment.name,
+ resourceAssignment.property!!);
// Get the Resource Definition from Repo
val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
@@ -87,26 +88,26 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName))
// Enrich as NodeTemplate
- bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate)
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, dictionarySource, sourceNodeTemplate)
}
}
// Enrich the ResourceSource NodeTypes
uniqueSourceNodeTypeNames.map { nodeTypeName ->
- resourceDefinitionRepoService.getNodeType(nodeTypeName).subscribe { nodeType ->
- bluePrintEnhancerService.enrichNodeType(nodeTypeName, nodeType)
- }
+ val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)
}
}
- override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
- val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService)
- bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
- bluePrintEnhancerService.initialCleanUp()
- enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
- return bluePrintEnhancerService.serviceTemplate
- }
-
+ /*
+ override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
+ val bluePrintEnhancerService = BluePrintEnhancerServiceImpl(resourceDefinitionRepoService)
+ bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
+ bluePrintEnhancerService.initialCleanUp()
+ enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
+ return bluePrintEnhancerService.serviceTemplate
+ }
+ */
private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
|| resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
@@ -114,7 +115,6 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti }
private fun getResourceDefinition(name: String): ResourceDefinition {
- return resourceDefinitionRepoService.getResourceDefinition(name).block()
- ?: throw BluePrintException(format("failed to get dictionary definition({})", name))
+ return resourceDefinitionRepoService.getResourceDefinition(name)
}
}
\ No newline at end of file |