import org.onap.ccsdk.apps.controllerblueprints.core.data.*;\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;\r
-import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerServiceImpl;\r
import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;\r
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;\r
-import org.springframework.context.annotation.Scope;\r
-import org.springframework.stereotype.Service;\r
\r
import java.util.HashMap;\r
import java.util.List;\r
*/\r
\r
@Deprecated\r
-@Service\r
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
-public class BluePrintEnhancerService extends BluePrintEnhancerServiceImpl {\r
+public class BluePrintEnhancerService {\r
\r
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);\r
\r
\r
private Map<String, DataType> recipeDataTypes = new HashMap<>();\r
\r
- public BluePrintEnhancerService(ResourceDefinitionRepoService resourceDefinitionRepoService,\r
- ResourceAssignmentEnhancerService resourceAssignmentEnhancerService) {\r
- super(resourceDefinitionRepoService);\r
- this.resourceAssignmentEnhancerService = resourceAssignmentEnhancerService;\r
- }\r
-\r
- @Override\r
- public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException {\r
- super.enrichTopologyTemplate(serviceTemplate);\r
-\r
- // Update the Recipe Inputs and DataTypes\r
- populateRecipeInputs(serviceTemplate);\r
- }\r
-\r
-\r
- @Override\r
- public void enrichNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate) throws BluePrintException {\r
- super.enrichNodeTemplate(nodeTemplateName, nodeTemplate);\r
-\r
- String nodeTypeName = nodeTemplate.getType();\r
- log.info("*** Enriching NodeType: {}", nodeTypeName);\r
- // Get NodeType from Repo and Update Service Template\r
- NodeType nodeType = super.populateNodeType(nodeTypeName);\r
-\r
- // Enrich NodeType\r
- super.enrichNodeType(nodeTypeName, nodeType);\r
-\r
- // Custom for Artifact Population\r
- if (StringUtils.isNotBlank(nodeType.getDerivedFrom())\r
- && ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT.equalsIgnoreCase(nodeType.getDerivedFrom())) {\r
- populateArtifactTemplateMappingDataType(nodeTemplateName, nodeTemplate);\r
- }\r
-\r
- //Enrich Node Template Artifacts\r
- super.enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate);\r
-\r
- }\r
-\r
\r
private void populateArtifactTemplateMappingDataType(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)\r
throws BluePrintException {\r
private ResourceDictionaryRepository dataDictionaryRepository;\r
\r
private ConfigModelCreateService configModelCreateService;\r
- private BluePrintEnhancerService bluePrintEnhancerService;\r
private ResourceAssignmentValidationService resourceAssignmentValidationService;\r
\r
/**\r
*\r
* @param dataDictionaryRepository dataDictionaryRepository\r
* @param configModelCreateService configModelCreateService\r
- * @param bluePrintEnhancerService bluePrintEnhancerService\r
* @param resourceAssignmentValidationService resourceAssignmentValidationService\r
*/\r
public ServiceTemplateService(ResourceDictionaryRepository dataDictionaryRepository,\r
ConfigModelCreateService configModelCreateService,\r
- BluePrintEnhancerService bluePrintEnhancerService,\r
ResourceAssignmentValidationService resourceAssignmentValidationService) {\r
this.dataDictionaryRepository = dataDictionaryRepository;\r
this.configModelCreateService = configModelCreateService;\r
- this.bluePrintEnhancerService = bluePrintEnhancerService;\r
this.resourceAssignmentValidationService = resourceAssignmentValidationService;\r
}\r
\r
* @return ServiceTemplate\r
*/\r
public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {\r
- this.bluePrintEnhancerService.enhance(serviceTemplate);\r
+ //FIXME("Connect New Enrichment service")\r
return serviceTemplate;\r
}\r
\r
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
+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.BluePrintRepoService
+
+class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintAttributeDefinitionEnhancer {
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: AttributeDefinition) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
\r
import com.att.eelf.configuration.EELFLogger\r
import com.att.eelf.configuration.EELFManager\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes\r
-import org.onap.ccsdk.apps.controllerblueprints.core.data.*\r
-import org.onap.ccsdk.apps.controllerblueprints.core.format\r
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils\r
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils\r
\r
-open class BluePrintEnhancerServiceImpl(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService {\r
+open class BluePrintEnhancerServiceImpl(private val bluePrintRepoService: BluePrintRepoService,\r
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintEnhancerService {\r
\r
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())\r
\r
- lateinit var serviceTemplate: ServiceTemplate\r
-\r
override fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {\r
BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath)\r
BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)\r
@Throws(BluePrintException::class)\r
override fun enhance(basePath: String): BluePrintContext {\r
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(basePath)\r
- enhance(bluePrintContext.serviceTemplate)\r
+ val error = BluePrintError()\r
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",\r
+ bluePrintContext.serviceTemplate)\r
return bluePrintContext\r
}\r
\r
@Throws(BluePrintException::class)\r
override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate {\r
- this.serviceTemplate = serviceTemplate\r
- initialCleanUp()\r
- enrichTopologyTemplate(serviceTemplate)\r
-\r
- // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true))\r
- return this.serviceTemplate\r
- }\r
-\r
- open fun initialCleanUp() {\r
- serviceTemplate.artifactTypes?.clear()\r
- serviceTemplate.nodeTypes?.clear()\r
- serviceTemplate.dataTypes?.clear()\r
- serviceTemplate.policyTypes?.clear()\r
-\r
- serviceTemplate.artifactTypes = mutableMapOf()\r
- serviceTemplate.nodeTypes = mutableMapOf()\r
- serviceTemplate.dataTypes = mutableMapOf()\r
- serviceTemplate.policyTypes = mutableMapOf()\r
-\r
- }\r
-\r
- @Throws(BluePrintException::class)\r
- open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) {\r
- serviceTemplate.topologyTemplate?.let { topologyTemplate ->\r
- enrichTopologyTemplateInputs(topologyTemplate)\r
- enrichTopologyTemplateNodeTemplates(topologyTemplate)\r
- }\r
- }\r
-\r
- @Throws(BluePrintException::class)\r
- open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {\r
- topologyTemplate.inputs?.let { inputs ->\r
- enrichPropertyDefinitions(inputs)\r
- }\r
- }\r
-\r
- open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {\r
- topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->\r
- enrichNodeTemplate(nodeTemplateName, nodeTemplate)\r
- }\r
- }\r
-\r
- @Throws(BluePrintException::class)\r
- open fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) {\r
- val nodeTypeName = nodeTemplate.type\r
- // Get NodeType from Repo and Update Service Template\r
- val nodeType = populateNodeType(nodeTypeName)\r
-\r
- // Enrich NodeType\r
- enrichNodeType(nodeTypeName, nodeType)\r
-\r
- //Enrich Node Template Artifacts\r
- enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate)\r
- }\r
-\r
- @Throws(BluePrintException::class)\r
- fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) {\r
- log.debug("Enriching NodeType({})", nodeTypeName)\r
- val derivedFrom = nodeType.derivedFrom\r
-\r
- if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {\r
- val derivedFromNodeType = populateNodeType(nodeTypeName)\r
- // Enrich NodeType\r
- enrichNodeType(derivedFrom, derivedFromNodeType)\r
- }\r
-\r
- // NodeType Property Definitions\r
- enrichNodeTypeProperties(nodeTypeName, nodeType)\r
-\r
- //NodeType Requirement\r
- enrichNodeTypeRequirements(nodeTypeName, nodeType)\r
-\r
- //NodeType Capability\r
- enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType)\r
-\r
- //NodeType Interface\r
- enrichNodeTypeInterfaces(nodeTypeName, nodeType)\r
- }\r
-\r
- open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {\r
- nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) }\r
- }\r
-\r
- open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {\r
-\r
- nodeType.requirements?.forEach { _, requirementDefinition ->\r
- // Populate Requirement Node\r
- requirementDefinition.node?.let { requirementNodeTypeName ->\r
- // Get Requirement NodeType from Repo and Update Service Template\r
- val requirementNodeType = populateNodeType(requirementNodeTypeName)\r
-\r
- enrichNodeType(requirementNodeTypeName, requirementNodeType)\r
- }\r
- }\r
+ val bluePrintContext = BluePrintContext(serviceTemplate)\r
+ val error = BluePrintError()\r
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(bluePrintContext, error, "service_template",\r
+ bluePrintContext.serviceTemplate)\r
+ return bluePrintContext.serviceTemplate\r
}\r
-\r
- open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {\r
- nodeType.capabilities?.forEach { _, capabilityDefinition ->\r
- capabilityDefinition.properties?.let { properties ->\r
- enrichPropertyDefinitions(properties)\r
- }\r
- }\r
- }\r
-\r
- open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) {\r
- nodeType.interfaces?.forEach { interfaceName, interfaceObj ->\r
- // Populate Node type Interface Operation\r
- log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName)\r
- populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj)\r
-\r
- }\r
- }\r
-\r
- open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) {\r
-\r
- interfaceObj.operations?.forEach { operationName, operation ->\r
- enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation)\r
- enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation)\r
- }\r
- }\r
-\r
- open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {\r
- operation.inputs?.let { inputs ->\r
- enrichPropertyDefinitions(inputs)\r
- }\r
- }\r
-\r
- open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {\r
- operation.outputs?.let { inputs ->\r
- enrichPropertyDefinitions(inputs)\r
- }\r
- }\r
-\r
- open fun enrichPropertyDefinitions(properties: MutableMap<String, PropertyDefinition>) {\r
-\r
- properties.forEach { propertyName, propertyDefinition ->\r
- enrichPropertyDefinition(propertyName, propertyDefinition)\r
- }\r
- }\r
-\r
- @Throws(BluePrintException::class)\r
- fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) {\r
- val propertyType = propertyDefinition.type\r
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {\r
-\r
- } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {\r
- val entrySchema = propertyDefinition.entrySchema\r
- ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName))\r
-\r
- if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {\r
- populateDataTypes(entrySchema.type)\r
- }\r
- } else {\r
- populateDataTypes(propertyType)\r
- }\r
-\r
- }\r
-\r
- open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {\r
-\r
- nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->\r
- val artifactTypeName = artifactDefinition.type\r
- ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName))\r
-\r
- // Populate Artifact Type\r
- populateArtifactType(artifactTypeName)\r
- }\r
- }\r
-\r
- open fun populateNodeType(nodeTypeName: String): NodeType {\r
-\r
- val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName)\r
- ?: bluePrintRepoService.getNodeType(nodeTypeName)\r
- ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))\r
- serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)\r
- return nodeType\r
- }\r
-\r
- open fun populateArtifactType(artifactTypeName: String): ArtifactType {\r
- val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName)\r
- ?: bluePrintRepoService.getArtifactType(artifactTypeName)\r
- ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName))\r
- serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)\r
- return artifactType\r
- }\r
-\r
- open fun populateDataTypes(dataTypeName: String): DataType {\r
- val dataType = serviceTemplate.dataTypes?.get(dataTypeName)\r
- ?: bluePrintRepoService.getDataType(dataTypeName)\r
- ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))\r
- serviceTemplate.dataTypes?.put(dataTypeName, dataType)\r
- return dataType\r
- }\r
-\r
}\r
\r
--- /dev/null
+/*
+ * 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 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
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
+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.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintNodeTemplateEnhancer {
+
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeTemplate: NodeTemplate) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ val nodeTypeName = nodeTemplate.type
+ // Get NodeType from Repo and Update Service Template
+ val nodeType = populateNodeType(nodeTypeName)
+
+ // Enrich NodeType
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintContext, error, nodeTypeName, nodeType)
+
+ //Enrich Node Template Artifacts
+ enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
+ }
+
+
+ open fun populateNodeType(nodeTypeName: String): NodeType {
+
+ val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
+ ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
+ bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
+ return nodeType
+ }
+
+ 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)
+ }
+ }
+
+ 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
--- /dev/null
+/*
+ * 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.BluePrintError
+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
+import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
+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.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTypeEnhancer {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTypeEnhancerImpl::class.toString())
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, nodeType: NodeType) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ val derivedFrom = nodeType.derivedFrom
+
+ if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
+ val derivedFromNodeType = populateNodeType(name)
+ // Enrich NodeType
+ enhance(bluePrintContext, error, derivedFrom, derivedFromNodeType)
+ }
+
+ // NodeType Property Definitions
+ enrichNodeTypeProperties(name, nodeType)
+
+ //NodeType Requirement
+ enrichNodeTypeRequirements(name, nodeType)
+
+ //NodeType Capability
+ enrichNodeTypeCapabilityProperties(name, nodeType)
+
+ //NodeType Interface
+ enrichNodeTypeInterfaces(name, nodeType)
+
+ }
+
+ open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.properties?.let {
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, 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)
+ // Enhanypece Node T
+ enhance(bluePrintContext, error, requirementNodeTypeName, requirementNodeType)
+ }
+ }
+ }
+
+ open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.capabilities?.forEach { _, capabilityDefinition ->
+ capabilityDefinition.properties?.let { properties ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, 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 ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ }
+ }
+
+ open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ operation.outputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ }
+ }
+
+ open fun populateNodeType(nodeTypeName: String): NodeType {
+
+ val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
+ ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
+ bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
+ return nodeType
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
+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.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class BluePrintPolicyTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintPolicyTypeEnhancer {
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: PolicyType) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 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.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionEnhancer
+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.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintPropertyDefinitionEnhancer {
+
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, propertyDefinition: PropertyDefinition) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ val propertyType = propertyDefinition.type
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+ val entrySchema = propertyDefinition.entrySchema
+ ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
+
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
+ populateDataTypes(entrySchema.type)
+ }
+ } else {
+ populateDataTypes(propertyType)
+ }
+ }
+
+ open fun populateDataTypes(dataTypeName: String): DataType {
+ val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: bluePrintRepoService.getDataType(dataTypeName)
+ ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName))
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType)
+ return dataType
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+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
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintServiceTemplateEnhancer {
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: ServiceTemplate) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+ initialCleanUp()
+ enhanceTopologyTemplate()
+ }
+
+ open fun initialCleanUp() {
+ bluePrintContext.serviceTemplate.artifactTypes?.clear()
+ bluePrintContext.serviceTemplate.nodeTypes?.clear()
+ bluePrintContext.serviceTemplate.dataTypes?.clear()
+ bluePrintContext.serviceTemplate.policyTypes?.clear()
+
+ bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
+
+ }
+
+ open fun enhanceTopologyTemplate() {
+ bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
+ bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintContext, error, "default", topologyTemplate)
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer
+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.BluePrintRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintTopologyTemplateEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintTopologyTemplateEnhancer {
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, type: TopologyTemplate) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ enhanceTopologyTemplateInputs(type)
+ enhanceTopologyTemplateNodeTemplates(type)
+ }
+
+ open fun enhanceTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.inputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ }
+ }
+
+ open fun enhanceTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintContext, error, nodeTemplateName, nodeTemplate)
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer
+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.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
+ : BluePrintWorkflowEnhancer {
+
+ lateinit var bluePrintContext: BluePrintContext
+ lateinit var error: BluePrintError
+
+ private val workflowDataTypes: MutableMap<String, DataType> = hashMapOf()
+
+ override fun enhance(bluePrintContext: BluePrintContext, error: BluePrintError, name: String, workflow: Workflow) {
+ this.bluePrintContext = bluePrintContext
+ this.error = error
+
+ // Enrich Only for Resource Assignment and Dynamic Input Properties if any
+ enhanceStepTargets(workflow)
+
+ // Enrich Workflow Inputs
+ enhanceWorkflowInputs(name, workflow)
+ }
+
+ open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
+ val dynamicPropertyName = "$name-properties"
+ workflow.inputs?.let { inputs ->
+ // TODO("Filter Dynamic Properties")
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintContext, error, inputs)
+ }
+ }
+
+ private fun enhanceStepTargets(workflow: Workflow) {
+
+ val workflowNodeTemplates = workflowTargets(workflow)
+
+ workflowNodeTemplates.forEach { nodeTemplate ->
+ val artifactFiles = bluePrintContext.nodeTemplateByName(nodeTemplate).artifacts?.filter {
+ it.value.type == "artifact-mapping-resource"
+ }?.map {
+ it.value.file
+ }
+
+ artifactFiles?.let { fileName ->
+ val absoluteFilePath = "${bluePrintContext.rootPath}/$fileName"
+ // Enhance Resource Assignment File
+ enhanceResourceAssignmentFile(absoluteFilePath)
+
+ }
+ }
+ }
+
+ private fun workflowTargets(workflow: Workflow): List<String> {
+ return workflow.steps?.map {
+ it.value.target
+ }?.filterNotNull() ?: arrayListOf()
+ }
+
+ open fun enhanceResourceAssignmentFile(filePath: String) {
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintContext, error, resourceAssignments)
+ }
+}
\ No newline at end of file
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService\r
+import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
+import org.springframework.context.annotation.Scope\r
import org.springframework.stereotype.Service\r
\r
/**\r
* @author Brinda Santh\r
*/\r
@Service\r
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)\r
: ResourceAssignmentEnhancerService {\r
private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceImpl::class.java)\r