summaryrefslogtreecommitdiffstats
path: root/components/core
diff options
context:
space:
mode:
Diffstat (limited to 'components/core')
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt10
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt45
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt271
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt20
-rw-r--r--components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt41
5 files changed, 20 insertions, 367 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
index e25b3eea9..a971898d3 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
@@ -16,6 +16,8 @@
package org.onap.ccsdk.apps.controllerblueprints.core
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+
/**
*
*
@@ -104,6 +106,7 @@ object BluePrintTypes {
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
+ validTypes.add(BluePrintConstants.DATA_TYPE_MAP)
return validTypes
}
@@ -128,6 +131,13 @@ 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)
+ }
+
+ @JvmStatic
fun validCommands(): List<String> {
return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,
BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt
deleted file mode 100644
index d796597be..000000000
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintEnhancerFactory.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.core.factory
-
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-
-
-/**
- * BluePrintEnhancerFactory
- * @author Brinda Santh
- *
- */
-
-object BluePrintEnhancerFactory {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- var bluePrintEnhancerServices: MutableMap<String, BluePrintEnhancerService> = HashMap()
-
- fun register(key: String, bluePrintEnhancerService: BluePrintEnhancerService) {
- bluePrintEnhancerServices[key] = bluePrintEnhancerService
- }
-
- /**
- * Called by clients to get a Blueprint Parser for the Blueprint parser type
- */
- fun instance(key: String): BluePrintEnhancerService? {
- return bluePrintEnhancerServices.get(key)
- }
-}
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
deleted file mode 100644
index b125c594c..000000000
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerService.kt
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.core.service
-
-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 com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
-import java.io.Serializable
-
-/**
- * BluePrintEnhancerService
- * @author Brinda Santh
- *
- */
-interface BluePrintEnhancerService : Serializable {
-
- @Throws(BluePrintException::class)
- fun enhance(content: String): ServiceTemplate
-
- /**
- * Read Blueprint from CSAR structure Directory
- */
- @Throws(BluePrintException::class)
- fun enhance(fileName: String, basePath: String): ServiceTemplate
-
- @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 {
-
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString())
-
- lateinit var serviceTemplate: ServiceTemplate
-
- @Throws(BluePrintException::class)
- override fun enhance(content: String): ServiceTemplate {
- return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->
- enhance(serviceTemplate!!)
- }.block()!!
- }
-
- @Throws(BluePrintException::class)
- override fun enhance(fileName: String, basePath: String): ServiceTemplate {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- @Throws(BluePrintException::class)
- override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {
- this.serviceTemplate = serviceTemplate
- initialCleanUp()
- enrichTopologyTemplate(serviceTemplate)
-
- // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))
- return this.serviceTemplate
- }
-
- open fun initialCleanUp() {
- serviceTemplate.artifactTypes?.clear()
- serviceTemplate.nodeTypes?.clear()
- serviceTemplate.dataTypes?.clear()
-
- serviceTemplate.artifactTypes = HashMap()
- serviceTemplate.nodeTypes = HashMap()
- serviceTemplate.dataTypes = HashMap()
-
- }
-
- @Throws(BluePrintException::class)
- open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {
- serviceTemplate.topologyTemplate?.let { topologyTemplate ->
- enrichTopologyTemplateInputs(topologyTemplate)
- enrichTopologyTemplateNodeTemplates(topologyTemplate)
- }
- }
-
- @Throws(BluePrintException::class)
- open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
- topologyTemplate.inputs?.let { inputs ->
- enrichPropertyDefinitions(inputs)
- }
- }
-
- open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
- topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
- enrichNodeTemplate(nodeTemplateName, nodeTemplate)
- }
- }
-
- @Throws(BluePrintException::class)
- override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
- val nodeTypeName = nodeTemplate.type
- // Get NodeType from Repo and Update Service Template
- val nodeType = populateNodeType(nodeTypeName)
-
- // Enrich NodeType
- enrichNodeType(nodeTypeName, nodeType)
-
- //Enrich Node Template Artifacts
- enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)
- }
-
- @Throws(BluePrintException::class)
- override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {
- log.debug("Enriching NodeType({})", nodeTypeName)
- val derivedFrom = nodeType.derivedFrom
-
- if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
- val derivedFromNodeType = populateNodeType(nodeTypeName)
- // Enrich NodeType
- enrichNodeType(derivedFrom, derivedFromNodeType)
- }
-
- // NodeType Property Definitions
- enrichNodeTypeProperties(nodeTypeName, nodeType)
-
- //NodeType Requirement
- enrichNodeTypeRequirements(nodeTypeName, nodeType)
-
- //NodeType Capability
- enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType)
-
- //NodeType Interface
- enrichNodeTypeInterfaces(nodeTypeName, nodeType)
- }
-
- open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
- nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) }
- }
-
- open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
-
- nodeType.requirements?.forEach { _, requirementDefinition ->
- // Populate Requirement Node
- requirementDefinition.node?.let { requirementNodeTypeName ->
- // Get Requirement NodeType from Repo and Update Service Template
- val requirementNodeType = populateNodeType(requirementNodeTypeName)
-
- enrichNodeType(requirementNodeTypeName, requirementNodeType)
- }
- }
- }
-
- open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
- nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition ->
- capabilityDefinition.properties?.let { properties ->
- enrichPropertyDefinitions(properties)
- }
- }
- }
-
- open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) {
- nodeType.interfaces?.forEach { interfaceName, interfaceObj ->
- // Populate Node type Interface Operation
- log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName)
- populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj)
-
- }
- }
-
- open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) {
-
- interfaceObj.operations?.forEach { operationName, operation ->
- enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)
- enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)
- }
- }
-
- open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
- operation.inputs?.let { inputs ->
- enrichPropertyDefinitions(inputs)
- }
- }
-
- open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
- operation.outputs?.let { inputs ->
- enrichPropertyDefinitions(inputs)
- }
- }
-
- open fun enrichPropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) {
-
- properties.forEach { propertyName, propertyDefinition ->
- enrichPropertyDefinition(propertyName, propertyDefinition)
- }
- }
-
- @Throws(BluePrintException::class)
- override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {
- val propertyType = propertyDefinition.type
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
-
- } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
- val entrySchema = propertyDefinition.entrySchema
- ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName))
-
- if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
- populateDataTypes(entrySchema.type)
- }
- } else {
- populateDataTypes(propertyType)
- }
-
- }
-
- open fun enrichNodeTemplateArtifactDefinition(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)
- }
- }
-
- open fun populateNodeType(nodeTypeName: String): NodeType {
-
- val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block()
- ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
- serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
- return nodeType
- }
-
- open fun populateArtifactType(artifactTypeName: String): ArtifactType {
- val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block()
- ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))
- serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
- return artifactType
- }
-
- open fun populateDataTypes(dataTypeName: String): DataType {
- val dataType = serviceTemplate.dataTypes?.get(dataTypeName)
- ?: bluePrintRepoService.getDataType(dataTypeName)?.block()
- ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
- serviceTemplate.dataTypes?.put(dataTypeName, dataType)
- return dataType
- }
-
-}
-
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
index a7c14adfe..dec7a50df 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoService.kt
@@ -35,19 +35,19 @@ import java.io.Serializable
interface BluePrintRepoService : Serializable {
@Throws(BluePrintException::class)
- fun getNodeType(nodeTypeName: String): Mono<NodeType>?
+ fun getNodeType(nodeTypeName: String): Mono<NodeType>
@Throws(BluePrintException::class)
- fun getDataType(dataTypeName: String): Mono<DataType>?
+ fun getDataType(dataTypeName: String): Mono<DataType>
@Throws(BluePrintException::class)
- fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>?
+ fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>
@Throws(BluePrintException::class)
- fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>?
+ fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>
@Throws(BluePrintException::class)
- fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>?
+ fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>
}
@@ -63,30 +63,30 @@ open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoServic
private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE)
private val extension = ".json"
- override fun getDataType(dataTypeName: String): Mono<DataType>? {
+ override fun getDataType(dataTypeName: String): Mono<DataType> {
val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(dataTypeName).plus(extension)
return getModelType(fileName, DataType::class.java)
}
- override fun getNodeType(nodeTypeName: String): Mono<NodeType>? {
+ override fun getNodeType(nodeTypeName: String): Mono<NodeType> {
val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension)
return getModelType(fileName, NodeType::class.java)
}
- override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType>? {
+ override fun getArtifactType(artifactTypeName: String): Mono<ArtifactType> {
val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(artifactTypeName).plus(extension)
return getModelType(fileName, ArtifactType::class.java)
}
- override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType>? {
+ override fun getRelationshipType(relationshipTypeName: String): Mono<RelationshipType> {
val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(relationshipTypeName).plus(extension)
return getModelType(fileName, RelationshipType::class.java)
}
- override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition>? {
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): Mono<CapabilityDefinition> {
val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(capabilityDefinitionName).plus(extension)
return getModelType(fileName, CapabilityDefinition::class.java)
diff --git a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt b/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
deleted file mode 100644
index 8e6d5efdf..000000000
--- a/components/core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintEnhancerServiceTest.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.core.service
-
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils
-
-/**
- * BluePrintEnhancerServiceTest
- * @author Brinda Santh
- *
- */
-
-class BluePrintEnhancerServiceTest {
- val basePath = "load/model_type"
-
- @Test
- fun testEnrichBlueprint() {
- val bluePrintEnhancerRepoFileService = BluePrintRepoFileService(basePath)
- val bluePrintEnhancerService: BluePrintEnhancerService = BluePrintEnhancerDefaultService(bluePrintEnhancerRepoFileService)
-
- val serviceTemplate = ServiceTemplateUtils.getServiceTemplate("load/blueprints/simple-baseconfig/Definitions/simple-baseconfig.json")
- bluePrintEnhancerService.enhance(serviceTemplate)
-
- }
-} \ No newline at end of file