aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/resource-dict/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/resource-dict/src/main')
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt1
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt3
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt26
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt19
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt18
6 files changed, 37 insertions, 33 deletions
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
index f1e0d2c86..10930ffab 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinition.kt
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import java.io.Serializable
-import java.util.*
+import java.util.Date
open class ResourceDefinition {
@@ -103,7 +103,6 @@ open class ResourceAssignment {
*/
interface ResourceSource : Serializable
-
open class ResourceSourceMapping {
lateinit var resourceSourceMappings: MutableMap<String, String>
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
index 25b161e47..366a4dcd4 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
@@ -22,6 +22,7 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict
* @author Brinda Santh
*/
object ResourceDictionaryConstants {
+
const val SOURCE_INPUT = "input"
const val SOURCE_DEFAULT = "default"
const val PROCESSOR_DB = "processor-db"
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt
index 6f2b9bae7..f8dea9871 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt
@@ -35,7 +35,7 @@ object ResourceSourceMappingFactory {
fun getRegisterSourceMapping(sourceInstance: String): String {
return resourceSourceMappings[sourceInstance]
- ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance))
+ ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance))
}
fun getRegisterSourceMapping(): ResourceSourceMapping {
@@ -44,4 +44,3 @@ object ResourceSourceMappingFactory {
return resourceSourceMapping
}
}
-
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
index 08b9d0560..a5171d25c 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -17,13 +17,13 @@
package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service
-import org.slf4j.LoggerFactory
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import org.slf4j.LoggerFactory
import java.io.Serializable
/**
@@ -43,7 +43,8 @@ interface ResourceAssignmentValidationService : Serializable {
* @author Brinda Santh
*/
open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService {
- private val log= LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java)
+
+ private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java)
open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf()
open val validationMessage = StrBuilder()
@@ -61,15 +62,14 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
return true
}
-
open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) {
resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap()
// Check the Resource Assignment has Duplicate Key Names
val duplicateKeyNames = resourceAssignments.groupBy { it.name }
- .filter { it.value.size > 1 }
- .map { it.key }
+ .filter { it.value.size > 1 }
+ .map { it.key }
if (duplicateKeyNames.isNotEmpty()) {
validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames))
@@ -120,21 +120,23 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
if (v.name == "*") {
s.append("\n * -> [")
for (resourceAssignment in vs) {
- s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name
- + "),")
+ s.append(
+ "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name +
+ "),"
+ )
}
s.append("]")
} else {
s.append("\n (" + v.dictionaryName + ":" + v.name + ") -> [")
for (resourceAssignment in vs) {
- s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name
- + "),")
+ s.append(
+ "(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name +
+ "),"
+ )
}
s.append("]")
}
}
return s.toString()
}
-
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
index cd887bf54..9a5523113 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
@@ -21,7 +21,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asListOfString
import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
-import java.util.*
+import java.util.ArrayList
/**
* BulkResourceSequencingUtils.
@@ -29,6 +29,7 @@ import java.util.*
* @author Brinda Santh
*/
object BulkResourceSequencingUtils {
+
private val log = LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java)
@JvmStatic
@@ -83,12 +84,15 @@ object BulkResourceSequencingUtils {
dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies)
}
- log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name,
- batchAssignmentName, resourceAssignment.dependencies, dependencyPresence)
+ log.trace(
+ "({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name,
+ batchAssignmentName, resourceAssignment.dependencies, dependencyPresence
+ )
- if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null
- && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true)
- && !dependencyPresence) {
+ if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null &&
+ resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) &&
+ !dependencyPresence
+ ) {
batchResourceAssignment!!.add(resourceAssignment)
batchAssignmentName!!.add(resourceAssignment.name)
} else {
@@ -112,5 +116,4 @@ object BulkResourceSequencingUtils {
return sequenceBatchResourceAssignment
}
-
-} \ No newline at end of file
+}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
index cd5470953..f26c5098f 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
@@ -16,7 +16,6 @@
package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils
-import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.apache.commons.collections.MapUtils
@@ -29,15 +28,17 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.slf4j.LoggerFactory
import java.io.File
-
object ResourceDictionaryUtils {
- private val log= LoggerFactory.getLogger(ResourceDictionaryUtils::class.java)
+ private val log = LoggerFactory.getLogger(ResourceDictionaryUtils::class.java)
@JvmStatic
- fun populateSourceMapping(resourceAssignment: ResourceAssignment,
- resourceDefinition: ResourceDefinition) {
+ fun populateSourceMapping(
+ resourceAssignment: ResourceAssignment,
+ resourceDefinition: ResourceDefinition
+ ) {
if (StringUtils.isBlank(resourceAssignment.dictionarySource)) {
@@ -81,19 +82,18 @@ object ResourceDictionaryUtils {
fun getResourceAssignmentFromFile(filePath: String): List<ResourceAssignment> {
return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
- ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
}
fun writeResourceDefinitionTypes(basePath: String, resourceDefinitions: List<ResourceDefinition>) {
val resourceDefinitionMap = resourceDefinitions.map { it.name to it }.toMap()
writeResourceDefinitionTypes(basePath, resourceDefinitionMap)
-
}
fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map<String, ResourceDefinition>) {
val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)
- .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
+ .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true)
BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent)
}
-} \ No newline at end of file
+}