Migrate ccdsk/apps to ccsdk/cds
[ccsdk/apps.git] / ms / controllerblueprints / modules / service / src / main / kotlin / org / onap / ccsdk / apps / controllerblueprints / service / enhancer / ResourceAssignmentEnhancerService.kt
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
deleted file mode 100644 (file)
index 4d1f44a..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.controllerblueprints.service.enhancer\r
-\r
-import com.att.eelf.configuration.EELFLogger\r
-import com.att.eelf.configuration.EELFManager\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.interfaces.BluePrintTypeEnhancerService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
-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.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
- * ResourceAssignmentEnhancerService.\r
- *\r
- * @author Brinda Santh\r
- */\r
-interface ResourceAssignmentEnhancerService {\r
-\r
-    @Throws(BluePrintException::class)\r
-    fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,\r
-                         bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
-                         resourceAssignments: List<ResourceAssignment>)\r
-}\r
-\r
-/**\r
- * ResourceAssignmentEnhancerDefaultService.\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
-\r
-    /**\r
-     * Get the defined source instance from the ResourceAssignment,\r
-     * then get the NodeType of the Sources assigned\r
-     */\r
-    override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,\r
-                                  bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
-                                  resourceAssignments: List<ResourceAssignment>) {\r
-\r
-        val uniqueSourceNodeTypeNames = hashSetOf<String>()\r
-\r
-        // Iterate the Resource Assignment and\r
-        resourceAssignments.map { resourceAssignment ->\r
-            val dictionaryName = resourceAssignment.dictionaryName!!\r
-            val dictionarySource = resourceAssignment.dictionarySource!!\r
-            log.debug("Enriching assignment name(${resourceAssignment.name}), dictionary name($dictionaryName), source($dictionarySource)")\r
-            val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)\r
-\r
-            // Add Unique Node Types\r
-            uniqueSourceNodeTypeNames.add(sourceNodeTypeName)\r
-\r
-            // TODO("Candidate for Optimisation")\r
-            if (checkResourceDefinitionNeeded(resourceAssignment)) {\r
-\r
-                bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name,\r
-                        resourceAssignment.property!!);\r
-\r
-                // Get the Resource Definition from Repo\r
-                val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)\r
-\r
-                val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)\r
-                        ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)")\r
-\r
-                // Enrich as NodeTemplate\r
-                bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)\r
-            }\r
-        }\r
-        // Enrich the ResourceSource NodeTypes\r
-        uniqueSourceNodeTypeNames.map { nodeTypeName ->\r
-            val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)\r
-            bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)\r
-        }\r
-\r
-    }\r
-\r
-    private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {\r
-        return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)\r
-                || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))\r
-                && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!))\r
-    }\r
-\r
-    private fun getResourceDefinition(name: String): ResourceDefinition {\r
-        return resourceDefinitionRepoService.getResourceDefinition(name)\r
-    }\r
-}
\ No newline at end of file