aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/resource-dict/src/main/kotlin
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-31 19:52:48 +0000
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-08-31 19:52:48 +0000
commit5dbc79162b53a0e97be4561719ae0e181944d2c8 (patch)
tree966a543d62a21df9d902f41ce47a0a464920235a /ms/controllerblueprints/modules/resource-dict/src/main/kotlin
parenta6575b730739bc3e6a44e426758ca676d1f972b0 (diff)
Controller Blueprints Microservice
Add resource assignment enhancer, resource definition repo functions and code improvements. Change-Id: I751bf8149a36f80c20d48b86344cd6bd3054ed21 Issue-ID: CCSDK-431 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict/src/main/kotlin')
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt86
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt61
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt5
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt5
7 files changed, 161 insertions, 8 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
index 9b89f6f40..aa6a9fb65 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
@@ -25,6 +25,8 @@ object ResourceDictionaryConstants {
const val SOURCE_DEFAULT = "default"
const val SOURCE_DB = "db"
+ const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary"
+
const val PROPERTY_TYPE = "type"
const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping"
const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping"
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt
new file mode 100644
index 000000000..c5a78a9c9
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentEnhancerService.kt
@@ -0,0 +1,86 @@
+/*
+ * 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.resource.dict.service
+
+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.core.service.BluePrintEnhancerDefaultService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import com.att.eelf.configuration.EELFManager
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceAssignmentEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>)
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate
+}
+
+/**
+ * ResourceAssignmentEnhancerDefaultService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
+ : ResourceAssignmentEnhancerService {
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
+
+ /**
+ * Get the defined source instance from the ResourceAssignment,
+ * then get the NodeType of the Sources assigned
+ */
+ override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService,
+ resourceAssignments: List<ResourceAssignment>) {
+
+ // Iterate the Resource Assignment and
+ resourceAssignments.map { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName!!
+ val dictionarySource = resourceAssignment.dictionarySource!!
+ log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name,
+ dictionaryName, dictionarySource)
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+
+ val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource)
+
+ // Enrich as NodeTemplate
+ bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!)
+ }
+ }
+
+ override fun enhanceBluePrint(resourceAssignments: List<ResourceAssignment>): ServiceTemplate {
+ val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService)
+ bluePrintEnhancerService.serviceTemplate = ServiceTemplate()
+ bluePrintEnhancerService.initialCleanUp()
+ enhanceBluePrint(bluePrintEnhancerService, resourceAssignments)
+ return bluePrintEnhancerService.serviceTemplate
+ }
+
+ private fun getResourceDefinition(name: String): ResourceDefinition {
+ return resourceDefinitionRepoService.getResourceDefinition(name)!!.block()!!
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
index 4578aca7d..228b39e29 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -16,13 +16,14 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+import com.att.eelf.configuration.EELFLogger
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
import java.io.Serializable
/**
@@ -42,7 +43,7 @@ interface ResourceAssignmentValidationService : Serializable {
* @author Brinda Santh
*/
open class ResourceAssignmentValidationDefaultService : ResourceAssignmentValidationService {
- private val log = LoggerFactory.getLogger(ResourceAssignmentValidationDefaultService::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java)
open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf()
open val validationMessage = StrBuilder()
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
new file mode 100644
index 000000000..d51338caf
--- /dev/null
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionRepoService.kt
@@ -0,0 +1,61 @@
+/*
+ * 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.resource.dict.service
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import reactor.core.publisher.Mono
+/**
+ * ResourceDefinitionRepoService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceDefinitionRepoService : BluePrintRepoService {
+
+ fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>?
+}
+
+/**
+ * ResourceDefinitionFileRepoService.
+ *
+ * @author Brinda Santh
+ */
+open class ResourceDefinitionFileRepoService : BluePrintRepoFileService,
+ ResourceDefinitionRepoService {
+
+ private var resourceDefinitionPath: String
+ private val extension = ".json"
+
+ constructor(basePath: String) : this(basePath,
+ basePath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(BluePrintConstants.MODEL_DIR_MODEL_TYPE))
+
+ constructor(basePath: String, modelTypePath: String) : super(modelTypePath) {
+ resourceDefinitionPath = basePath.plus("/resource_dictionary")
+ }
+
+ override fun getResourceDefinition(resourceDefinitionName: String): Mono<ResourceDefinition>? {
+
+ val fileName = resourceDefinitionPath.plus(BluePrintConstants.PATH_DIVIDER)
+ .plus(resourceDefinitionName).plus(extension)
+
+ return JacksonReactorUtils.readValueFromFile(fileName, ResourceDefinition::class.java)
+ }
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
index 1defa538c..14855d4b6 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
+import com.att.eelf.configuration.EELFLogger
import com.fasterxml.jackson.databind.JsonNode
import com.google.common.base.Preconditions
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
@@ -29,7 +30,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpression
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.ResourceDefinition
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
import java.io.Serializable
/**
* ResourceDefinitionValidationService.
@@ -49,7 +50,7 @@ interface ResourceDefinitionValidationService : Serializable {
*/
open class ResourceDefinitionDefaultValidationService(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService {
- private val log = LoggerFactory.getLogger(ResourceDefinitionValidationService::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java)
override fun validate(resourceDefinition: ResourceDefinition) {
Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
index 82fbd3ac1..747639c89 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
@@ -16,10 +16,11 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+import com.att.eelf.configuration.EELFLogger
import org.apache.commons.collections.CollectionUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
import java.util.ArrayList
/**
* BulkResourceSequencingUtils.
@@ -27,7 +28,7 @@ import java.util.ArrayList
* @author Brinda Santh
*/
object BulkResourceSequencingUtils {
- private val log = LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java)
@JvmStatic
fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> {
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
index 733a443fd..a3456cd43 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
@@ -16,6 +16,7 @@
package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils
+import com.att.eelf.configuration.EELFLogger
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.apache.commons.collections.MapUtils
@@ -25,11 +26,11 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
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.slf4j.LoggerFactory
+import com.att.eelf.configuration.EELFManager
object ResourceDictionaryUtils {
- private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java)
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java)
@JvmStatic
fun populateSourceMapping(resourceAssignment: ResourceAssignment,