summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt109
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt56
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt58
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt69
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt38
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt37
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt97
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt94
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt92
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt55
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt79
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt69
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt153
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt43
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt62
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt68
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt61
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt65
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt227
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt110
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt144
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt332
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt122
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt147
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt70
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt83
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt146
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt111
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt76
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt85
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt66
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt54
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/AutoResourceMappingService.kt174
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt105
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt164
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt83
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt223
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt27
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt123
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt49
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt126
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt138
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt53
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt110
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt99
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt66
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidatorTest.kt39
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties41
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-resource-assignment.json62
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-template.json351
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhanced-template.json327
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml39
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/model_type/data_type/datatype-property.json27
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/automap.json14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/default_definition.json17
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml17
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt10
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt10
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt6
64 files changed, 5602 insertions, 52 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml
index 6d2596024..f34a1ec4b 100644
--- a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml
@@ -43,10 +43,5 @@
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>blueprint-core</artifactId>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml
index 2586be255..8f6d32ee2 100644
--- a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml
@@ -23,17 +23,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>designer-api</artifactId>
<packaging>jar</packaging>
- <name>Blueprints Designer API</name>
- <description>Blueprints Designer API</description>
+ <name>Blueprints Processor Designer API</name>
+ <description>Blueprints Processor Designer API</description>
- <properties>
- <sonar.skip>true</sonar.skip>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <artifactId>service</artifactId>
- </dependency>
- </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
new file mode 100644
index 000000000..f67ed25c3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.BluePrintModelHandler
+import org.springframework.core.io.Resource
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.http.codec.multipart.FilePart
+import org.springframework.web.bind.annotation.*
+
+/**
+ * BlueprintModelController Purpose: Handle controllerBlueprint API request
+ *
+ * @author Vinal Patel
+ * @version 1.0
+ */
+@RestController
+@RequestMapping("/api/v1/blueprint-model")
+open class BlueprintModelController(private val bluePrintModelHandler: BluePrintModelHandler) {
+
+ @PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveBlueprint(@RequestPart("file") filePart: FilePart): BlueprintModelSearch = runBlocking {
+ bluePrintModelHandler.saveBlueprintModel(filePart)
+ }
+
+ @GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun allBlueprintModel(): List<BlueprintModelSearch> {
+ return this.bluePrintModelHandler.allBlueprintModel()
+ }
+
+ @DeleteMapping("/{id}")
+ @Throws(BluePrintException::class)
+ fun deleteBlueprint(@PathVariable(value = "id") id: String) {
+ this.bluePrintModelHandler.deleteBlueprintModel(id)
+ }
+
+ @GetMapping("/by-name/{name}/version/{version}", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun getBlueprintByNameAndVersion(@PathVariable(value = "name") name: String,
+ @PathVariable(value = "version") version: String): BlueprintModelSearch {
+ return this.bluePrintModelHandler.getBlueprintModelSearchByNameAndVersion(name, version)
+ }
+
+ @GetMapping("/download/by-name/{name}/version/{version}", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun downloadBlueprintByNameAndVersion(@PathVariable(value = "name") name: String,
+ @PathVariable(value = "version") version: String): ResponseEntity<Resource> {
+ return this.bluePrintModelHandler.downloadBlueprintModelFileByNameAndVersion(name, version)
+ }
+
+ @GetMapping("/{id}", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun getBlueprintModel(@PathVariable(value = "id") id: String): BlueprintModelSearch {
+ return this.bluePrintModelHandler.getBlueprintModelSearch(id)
+ }
+
+ @GetMapping("/download/{id}", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun downloadBluePrint(@PathVariable(value = "id") id: String): ResponseEntity<Resource> {
+ return this.bluePrintModelHandler.downloadBlueprintModelFile(id)
+ }
+
+ @PostMapping("/enrich", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType
+ .MULTIPART_FORM_DATA_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun enrichBlueprint(@RequestPart("file") file: FilePart): ResponseEntity<Resource> = runBlocking {
+ bluePrintModelHandler.enrichBlueprint(file)
+ }
+
+ @PostMapping("/publish", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun publishBlueprint(@RequestPart("file") file: FilePart): BlueprintModelSearch = runBlocking {
+ bluePrintModelHandler.publishBlueprint(file)
+ }
+
+ @GetMapping("/search/{tags}", produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchBlueprintModels(@PathVariable(value = "tags") tags: String): List<BlueprintModelSearch> {
+ return this.bluePrintModelHandler.searchBlueprintModels(tags)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt
new file mode 100644
index 000000000..0d2a7b7dc
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ControllerBlueprintExceptionHandler.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright © 2018-2019 Bell Canada 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.cds.blueprintsprocessor.designer.api
+
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.slf4j.LoggerFactory
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.web.bind.annotation.ExceptionHandler
+import org.springframework.web.bind.annotation.RestControllerAdvice
+
+/**
+ * ControllerBlueprintExceptionHandler Purpose: Handle exceptions in controllerBlueprint API and provide the right
+ * HTTP code status
+ *
+ * @author Vinal Patel
+ * @version 1.0
+ */
+@RestControllerAdvice("org.onap.ccsdk.cds.controllerblueprints")
+open class ControllerBlueprintExceptionHandler {
+
+ companion object ControllerBlueprintExceptionHandler {
+ val LOG = LoggerFactory.getLogger(ControllerBlueprintExceptionHandler::class.java)
+ }
+
+ @ExceptionHandler
+ fun ControllerBlueprintExceptionHandler(e: BluePrintException): ResponseEntity<ErrorMessage> {
+ val errorCode = ErrorCode.valueOf(e.code)
+ val errorMessage = ErrorMessage(errorCode?.message(e.message!!), errorCode?.value, "ControllerBluePrint_Error_Message")
+ LOG.error("Error: $errorCode ${e.message}")
+ return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode!!.httpCode))
+ }
+
+ @ExceptionHandler
+ fun ControllerBlueprintExceptionHandler(e: Exception): ResponseEntity<ErrorMessage> {
+ val errorCode = ErrorCode.GENERIC_FAILURE
+ val errorMessage = ErrorMessage(errorCode?.message(e.message!!), errorCode?.value, "ControllerBluePrint_Error_Message")
+ LOG.error("Error: $errorCode ${e.message}")
+ return ResponseEntity(errorMessage, HttpStatus.resolve(errorCode!!.httpCode))
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt
new file mode 100644
index 000000000..5259ee1c9
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiData.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.annotation.JsonInclude
+import com.fasterxml.jackson.annotation.JsonTypeInfo
+import com.fasterxml.jackson.annotation.JsonTypeName
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import java.io.Serializable
+import java.util.*
+
+/**
+ * ArtifactRequest.java Purpose: Provide Configuration Generator ArtifactRequest Model
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+class AutoMapResponse {
+ var resourceAssignments: List<ResourceAssignment>? = null
+ var dataDictionaries: List<ResourceDictionary>? = null
+}
+
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonTypeName("errorMessage")
+@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
+class ErrorMessage(var message: String?, var code: Int?, var debugMessage: String?) : Serializable {
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ var timestamp = Date()
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
new file mode 100644
index 000000000..bac281356
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeController.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = arrayOf("/api/v1/model-type"))
+open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) {
+
+ @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? = runBlocking {
+ modelTypeHandler.getModelTypeByName(name)
+ }
+
+ @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ fun searchModelTypes(@PathVariable(value = "tags") tags: String): List<ModelType> = runBlocking {
+ modelTypeHandler.searchModelTypes(tags)
+ }
+
+ @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ResponseBody
+ fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List<ModelType> = runBlocking {
+ modelTypeHandler.getModelTypeByDefinitionType(definitionType)
+ }
+
+ @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveModelType(@RequestBody modelType: ModelType): ModelType = runBlocking {
+ modelTypeHandler.saveModel(modelType)
+ }
+
+ @DeleteMapping(path = arrayOf("/{name}"))
+ fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = runBlocking {
+ modelTypeHandler.deleteByModelName(name)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
new file mode 100644
index 000000000..bae890a87
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryController.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDictionaryHandler
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+
+@RestController
+@RequestMapping(value = ["/api/v1/dictionary"])
+open class ResourceDictionaryController(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
+
+ @GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary = runBlocking {
+ resourceDictionaryHandler.getResourceDictionaryByName(name)
+ }
+
+ @PostMapping(path = [""], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @Throws(BluePrintException::class)
+ fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary = runBlocking {
+ resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
+ }
+
+ @DeleteMapping(path = ["/{name}"])
+ fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) = runBlocking {
+ resourceDictionaryHandler.deleteResourceDictionary(name)
+ }
+
+ @PostMapping(path = ["/by-names"], produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByNames(@RequestBody names: List<String>): List<ResourceDictionary> = runBlocking {
+ resourceDictionaryHandler.searchResourceDictionaryByNames(names)
+ }
+
+ @GetMapping(path = ["/search/{tags}"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun searchResourceDictionaryByTags(@PathVariable(value = "tags") tags: String): List<ResourceDictionary> = runBlocking {
+ resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
+
+ }
+
+ @GetMapping(path = ["/source-mapping"], produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ fun getResourceSourceMapping(): ResourceSourceMapping = runBlocking {
+ resourceDictionaryHandler.getResourceSourceMapping()
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt
new file mode 100644
index 000000000..97c7ab6a6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaJsonNodeConverter.kt
@@ -0,0 +1,38 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.domain
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+import javax.persistence.AttributeConverter
+import javax.persistence.Converter
+
+/**
+ * @author Brinda Santh
+ */
+@Converter
+class JpaJsonNodeConverter : AttributeConverter<JsonNode, String> {
+
+ override fun convertToDatabaseColumn(node: JsonNode): String {
+ return JacksonUtils.getJson(node, true)
+ }
+
+ override fun convertToEntityAttribute(dbData: String): JsonNode {
+ return JacksonUtils.jsonNode(dbData)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt
new file mode 100644
index 000000000..75cfede50
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/JpaResourceDefinitionConverter.kt
@@ -0,0 +1,37 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.domain
+
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+
+import javax.persistence.AttributeConverter
+import javax.persistence.Converter
+
+/**
+ * @author Brinda Santh
+ */
+@Converter
+class JpaResourceDefinitionConverter : AttributeConverter<ResourceDefinition, String> {
+ override fun convertToDatabaseColumn(resourceDefinition: ResourceDefinition): String {
+ return JacksonUtils.getJson(resourceDefinition)
+ }
+
+ override fun convertToEntityAttribute(content: String): ResourceDefinition? {
+ return JacksonUtils.readValue(content, ResourceDefinition::class.java)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt
new file mode 100644
index 000000000..a964e0416
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ModelType.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.domain
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import com.fasterxml.jackson.databind.JsonNode
+import io.swagger.annotations.ApiModelProperty
+import org.springframework.data.annotation.LastModifiedDate
+import org.springframework.data.jpa.domain.support.AuditingEntityListener
+import java.io.Serializable
+import java.util.*
+import javax.persistence.*
+
+/**
+ * Provide ModelType Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "MODEL_TYPE")
+class ModelType : Serializable {
+
+ @Id
+ @Column(name = "model_name", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var modelName: String
+
+ @Column(name = "derived_from", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var derivedFrom: String
+
+ @Column(name = "definition_type", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var definitionType: String
+
+ @Lob
+ @Convert(converter = JpaJsonNodeConverter::class)
+ @Column(name = "definition", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var definition: JsonNode
+
+ @Lob
+ @Column(name = "description", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var description: String
+
+ @Column(name = "version", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var version: String
+
+ @Lob
+ @Column(name = "tags", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var tags: String
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var creationDate: Date? = null
+
+ @Column(name = "updated_by", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var updatedBy: String
+
+ override fun toString(): String {
+ return "[" + "modelName = " + modelName +
+ ", derivedFrom = " + derivedFrom +
+ ", definitionType = " + definitionType +
+ ", description = " + description +
+ ", creationDate = " + creationDate +
+ ", version = " + version +
+ ", updatedBy = " + updatedBy +
+ ", tags = " + tags +
+ "]"
+ }
+
+ companion object {
+ private const val serialVersionUID = 1L
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt
new file mode 100644
index 000000000..ac5ea2070
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/domain/ResourceDictionary.kt
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.domain
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import io.swagger.annotations.ApiModelProperty
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+import org.springframework.data.annotation.LastModifiedDate
+import org.springframework.data.jpa.domain.support.AuditingEntityListener
+import java.io.Serializable
+import java.util.*
+import javax.persistence.*
+
+/**
+ * Provide ResourceDictionary Entity
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "RESOURCE_DICTIONARY")
+class ResourceDictionary : Serializable {
+
+ @Id
+ @Column(name = "name", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var name: String
+
+ @Column(name = "data_type", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var dataType: String
+
+ @Column(name = "entry_schema")
+ var entrySchema: String? = null
+
+ @Lob
+ @Convert(converter = JpaResourceDefinitionConverter::class)
+ @Column(name = "definition", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var definition: ResourceDefinition
+
+ @Lob
+ @Column(name = "description", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var description: String
+
+ @Lob
+ @Column(name = "tags", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var tags: String
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var creationDate: Date? = null
+
+ @Column(name = "updated_by", nullable = false)
+ @ApiModelProperty(required = true)
+ lateinit var updatedBy: String
+
+ override fun toString(): String {
+ return "[" + ", name = " + name +
+ ", dataType = " + dataType +
+ ", entrySchema = " + entrySchema +
+ ", definition =" + definition +
+ ", description = " + description +
+ ", updatedBy = " + updatedBy +
+ ", tags = " + tags +
+ ", creationDate = " + creationDate +
+ "]"
+ }
+
+ companion object {
+ private const val serialVersionUID = 1L
+ }
+
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
new file mode 100644
index 000000000..552339be9
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
@@ -0,0 +1,92 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
+ : BluePrintArtifactDefinitionEnhancer {
+
+ companion object {
+ const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
+ }
+
+
+ private val log = logger(BluePrintArtifactDefinitionEnhancerImpl::class)
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) {
+ log.info("enhancing ArtifactDefinition($name)")
+
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val artifactTypeName = artifactDefinition.type
+ ?: throw BluePrintException("artifact type is missing for ArtifactDefinition($name)")
+
+ // Populate Artifact Type
+ BluePrintEnhancerUtils.populateArtifactType(bluePrintContext, bluePrintRepoService, artifactTypeName)
+
+ when (artifactTypeName) {
+ ARTIFACT_TYPE_MAPPING_SOURCE -> {
+ enhanceMappingType(name, artifactDefinition)
+ }
+ }
+ }
+
+ // Enhance Resource Mapping
+ open fun enhanceMappingType(name: String, artifactDefinition: ArtifactDefinition) {
+
+ val artifactFilePath = "${bluePrintContext.rootPath}/${artifactDefinition.file}"
+
+ val alreadyEnhancedKey = "enhanced-${artifactDefinition.file}"
+ val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey)
+
+ log.info("enhancing resource mapping file(${artifactDefinition.file}) already enhanced($alreadyEnhanced)")
+
+ if (!alreadyEnhanced) {
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(artifactFilePath, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($artifactFilePath)")
+
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+
+ bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive())
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
new file mode 100644
index 000000000..0b64ed503
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintAttributeDefinitionEnhancerImpl.kt
@@ -0,0 +1,55 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+
+class BluePrintAttributeDefinitionEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
+ private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintAttributeDefinitionEnhancer {
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val propertyType = attributeDefinition.type
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+ val entrySchema = attributeDefinition.entrySchema
+ ?: throw BluePrintException("Entry Schema is missing for collection property($name)")
+
+ if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
+ }
+ } else {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt
new file mode 100644
index 000000000..b4d149e16
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -0,0 +1,79 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils
+import org.springframework.stereotype.Service
+import java.util.*
+
+@Service
+open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService {
+
+ private val log = logger(BluePrintEnhancerServiceImpl::class)
+
+ override suspend fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {
+
+ // Copy the Blueprint Content to Target Location
+ BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath)
+
+ // Enhance the Blueprint
+ return enhance(enrichedBasePath)
+ }
+
+ @Throws(BluePrintException::class)
+ override suspend fun enhance(basePath: String): BluePrintContext {
+
+ log.info("Enhancing blueprint($basePath)")
+ val blueprintRuntimeService = BluePrintMetadataUtils
+ .getBaseEnhancementBluePrintRuntime(UUID.randomUUID().toString(), basePath)
+
+ try {
+
+ bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",
+ blueprintRuntimeService.bluePrintContext().serviceTemplate)
+
+ log.info("##### Enhancing blueprint Resource Definitions")
+ val resourceDefinitions = resourceDefinitionEnhancerService.enhance(bluePrintTypeEnhancerService,
+ blueprintRuntimeService)
+
+ // Write the Enhanced Blueprint Definitions
+ BluePrintFileUtils.writeEnhancedBluePrint(blueprintRuntimeService.bluePrintContext())
+
+ // Write the Enhanced Blueprint Resource Definitions
+ ResourceDictionaryUtils.writeResourceDefinitionTypes(basePath, resourceDefinitions)
+
+ if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) {
+ throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString())
+ }
+
+ } catch (e: Exception) {
+ throw e
+ }
+ return blueprintRuntimeService.bluePrintContext()
+ }
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
new file mode 100644
index 000000000..723d7bb27
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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 {
+
+ private val log= logger(BluePrintNodeTemplateEnhancerImpl::class)
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
+ log.info("***** Enhancing NodeTemplate($name)")
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+
+ val nodeTypeName = nodeTemplate.type
+ // Get NodeType from Repo and Update Service Template
+ val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
+
+ // Enrich NodeType
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
+
+ //Enrich Node Template Artifacts
+ enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
+ }
+
+ open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
+
+ nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
+ // Enhance Artifacct Definitions
+ bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt
new file mode 100644
index 000000000..efb695b22
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintNodeTypeEnhancerImpl.kt
@@ -0,0 +1,153 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTypeEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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= logger(BluePrintNodeTypeEnhancerImpl::class)
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+
+ val derivedFrom = nodeType.derivedFrom
+
+ if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) {
+ val derivedFromNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, name)
+ // Enrich NodeType
+ enhance(bluePrintRuntimeService, derivedFrom, derivedFromNodeType)
+ }
+
+ // NodeType Attribute Definitions
+ enrichNodeTypeAttributes(name, nodeType)
+
+ // NodeType Property Definitions
+ enrichNodeTypeProperties(name, nodeType)
+
+ //NodeType Requirement
+ enrichNodeTypeRequirements(name, nodeType)
+
+ //NodeType Capability
+ enrichNodeTypeCapabilityProperties(name, nodeType)
+
+ //NodeType Interface
+ enrichNodeTypeInterfaces(name, nodeType)
+
+ }
+
+ open fun enrichNodeTypeAttributes(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.attributes?.let {
+ bluePrintTypeEnhancerService.enhanceAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
+ }
+ }
+
+ open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.properties?.let {
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
+ }
+ }
+
+ open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) {
+
+ nodeType.requirements?.forEach { requirementName, requirementDefinition ->
+ // Populate Requirement Node
+ requirementDefinition.node?.let { requirementNodeTypeName ->
+ // Get Requirement NodeType from Repo and Update Service Template
+ val requirementNodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext,
+ bluePrintRepoService, requirementNodeTypeName)
+ // Enhance Node Type
+ enhance(bluePrintRuntimeService, requirementNodeTypeName, requirementNodeType)
+
+ // Enhance Relationship Type
+ val relationShipTypeName = requirementDefinition.relationship
+ ?: throw BluePrintException("couldn't get relationship name for the NodeType($nodeTypeName) " +
+ "Requirement($requirementName)")
+ enrichRelationShipType(relationShipTypeName)
+ }
+ }
+ }
+
+ open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) {
+ nodeType.capabilities?.forEach { _, capabilityDefinition ->
+ capabilityDefinition.properties?.let { properties ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, 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)
+ enrichNodeTypeInterfaceOperationOutputs(nodeTypeName, operationName, operation)
+ }
+ }
+
+ open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) {
+ operation.inputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
+ }
+ }
+
+ open fun enrichNodeTypeInterfaceOperationOutputs(nodeTypeName: String, operationName: String,
+ operation: OperationDefinition) {
+ operation.outputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
+ }
+ }
+
+ /**
+ * Get the Relationship Type from database and add to Blueprint Context
+ */
+ open fun enrichRelationShipType(relationshipName: String) {
+ BluePrintEnhancerUtils.populateRelationshipType(bluePrintContext, bluePrintRepoService, relationshipName)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
new file mode 100644
index 000000000..83fd403e8
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPolicyTypeEnhancerImpl.kt
@@ -0,0 +1,43 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PolicyType
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPolicyTypeEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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 {
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: PolicyType) {
+
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+
+ // TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
new file mode 100644
index 000000000..b87cf9c6b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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 bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val propertyType = propertyDefinition.type
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)
+ || BluePrintTypes.validComplexTypes().contains(propertyType)) {
+ // Do Nothing,
+ } 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)) {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, entrySchema.type)
+ }
+ } else {
+ BluePrintEnhancerUtils.populateDataTypes(bluePrintContext, bluePrintRepoService, propertyType)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
new file mode 100644
index 000000000..65e5ff9e1
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
@@ -0,0 +1,68 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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 bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
+ : BluePrintServiceTemplateEnhancer {
+ private val log = logger(BluePrintServiceTemplateEnhancerImpl::class)
+
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: ServiceTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ initialCleanUp()
+ enhanceTopologyTemplate()
+ }
+
+ open fun initialCleanUp() {
+ bluePrintContext.serviceTemplate.artifactTypes?.clear()
+ bluePrintContext.serviceTemplate.nodeTypes?.clear()
+ bluePrintContext.serviceTemplate.dataTypes?.clear()
+ bluePrintContext.serviceTemplate.policyTypes?.clear()
+ bluePrintContext.serviceTemplate.relationshipTypes?.clear()
+
+ bluePrintContext.serviceTemplate.artifactTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.nodeTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.dataTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.policyTypes = mutableMapOf()
+ bluePrintContext.serviceTemplate.relationshipTypes = mutableMapOf()
+ log.info("reinitialized all type definitions")
+
+ }
+
+ open fun enhanceTopologyTemplate() {
+ bluePrintContext.serviceTemplate.topologyTemplate?.let { topologyTemplate ->
+ bluePrintTypeEnhancerService.enhanceTopologyTemplate(bluePrintRuntimeService, "topology_template", topologyTemplate)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.kt
new file mode 100644
index 000000000..c22370c33
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTopologyTemplateEnhancerImpl.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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.data.TopologyTemplate
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTopologyTemplateEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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 bluePrintRuntimeService: BluePrintRuntimeService<*>
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: TopologyTemplate) {
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+
+ enhanceTopologyTemplateInputs(type)
+ enhanceTopologyTemplateNodeTemplates(type)
+ enhanceTopologyTemplateWorkflows(type)
+ }
+
+ open fun enhanceTopologyTemplateInputs(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.inputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
+ }
+ }
+
+ open fun enhanceTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate ->
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate)
+ }
+ }
+
+ open fun enhanceTopologyTemplateWorkflows(topologyTemplate: TopologyTemplate) {
+ topologyTemplate.workflows?.forEach { workflowName, workflow ->
+ bluePrintTypeEnhancerService.enhanceWorkflow(bluePrintRuntimeService, workflowName, workflow)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt
new file mode 100644
index 000000000..db361a248
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintTypeEnhancerServiceImpl.kt
@@ -0,0 +1,65 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.*
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintTypeEnhancerServiceImpl : BluePrintTypeEnhancerService {
+
+ @Autowired
+ private lateinit var context: ApplicationContext
+
+ override fun getServiceTemplateEnhancers(): List<BluePrintServiceTemplateEnhancer> {
+ return context.getBeansOfType(BluePrintServiceTemplateEnhancer::class.java).map { it.value }
+ }
+
+ override fun getTopologyTemplateEnhancers(): List<BluePrintTopologyTemplateEnhancer> {
+ return context.getBeansOfType(BluePrintTopologyTemplateEnhancer::class.java).map { it.value }
+ }
+
+ override fun getWorkflowEnhancers(): List<BluePrintWorkflowEnhancer> {
+ return context.getBeansOfType(BluePrintWorkflowEnhancer::class.java).map { it.value }
+ }
+
+ override fun getNodeTemplateEnhancers(): List<BluePrintNodeTemplateEnhancer> {
+ return context.getBeansOfType(BluePrintNodeTemplateEnhancer::class.java).map { it.value }
+ }
+
+ override fun getNodeTypeEnhancers(): List<BluePrintNodeTypeEnhancer> {
+ return context.getBeansOfType(BluePrintNodeTypeEnhancer::class.java).map { it.value }
+ }
+
+ override fun getArtifactDefinitionEnhancers(): List<BluePrintArtifactDefinitionEnhancer> {
+ return context.getBeansOfType(BluePrintArtifactDefinitionEnhancer::class.java).map { it.value }
+ }
+
+ override fun getPolicyTypeEnhancers(): List<BluePrintPolicyTypeEnhancer> {
+ return context.getBeansOfType(BluePrintPolicyTypeEnhancer::class.java).map { it.value }
+ }
+
+ override fun getPropertyDefinitionEnhancers(): List<BluePrintPropertyDefinitionEnhancer> {
+ return context.getBeansOfType(BluePrintPropertyDefinitionEnhancer::class.java).map { it.value }
+ }
+
+ override fun getAttributeDefinitionEnhancers(): List<BluePrintAttributeDefinitionEnhancer> {
+ return context.getBeansOfType(BluePrintAttributeDefinitionEnhancer::class.java).map { it.value }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt
new file mode 100644
index 000000000..394289ced
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -0,0 +1,227 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowEnhancer
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.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 {
+ private val log= logger(BluePrintWorkflowEnhancerImpl::class)
+
+ companion object {
+ const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
+ const val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
+ }
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+
+ private val workflowDataTypes: MutableMap<String, DataType> = hashMapOf()
+
+ override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) {
+ log.info("##### Enhancing Workflow($name)")
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val dynamicPropertyName = "$name-properties"
+ if (workflow.inputs == null) {
+ workflow.inputs = hashMapOf()
+ }
+ // Clean Dynamic Property Field, If present
+ workflow.inputs?.remove(dynamicPropertyName)
+
+ // Enrich Workflow Inputs
+ enhanceWorkflowInputs(name, workflow)
+
+ // Enrich Workflow Outputs
+ enhanceWorkflowOutputs(name, workflow)
+
+ // Enrich Only for Resource Assignment and Dynamic Input Properties if any
+ enhanceStepTargets(name, workflow)
+
+
+ }
+
+ open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
+
+ workflow.inputs?.let { inputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, inputs)
+ }
+ }
+
+ open fun enhanceWorkflowOutputs(name: String, workflow: Workflow) {
+ workflow.outputs?.let { outputs ->
+ bluePrintTypeEnhancerService.enhancePropertyDefinitions(bluePrintRuntimeService, outputs)
+ }
+ }
+
+ private fun enhanceStepTargets(name: String, workflow: Workflow) {
+
+ // Get the first Step Target NodeTemplate name( It may be Component or DG Node Template)
+ val firstNodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(name)
+
+ val derivedFrom = bluePrintContext.nodeTemplateNodeType(firstNodeTemplateName).derivedFrom
+
+ when {
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, true) -> {
+ enhanceStepTargets(name, workflow, firstNodeTemplateName, false)
+ }
+ derivedFrom.startsWith(BluePrintConstants.MODEL_TYPE_NODE_WORKFLOW, true) -> {
+ enhanceStepTargets(name, workflow, firstNodeTemplateName, true)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't execute workflow($name) step mapped " +
+ "to node template($firstNodeTemplateName) derived from($derivedFrom)")
+ }
+ }
+
+ }
+
+ private fun enhanceStepTargets(name: String, workflow: Workflow, nodeTemplateName: String, isDG: Boolean) {
+
+ val dependencyNodeTemplates: List<String>
+ if (isDG) {
+ val dgNodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName)
+
+ // Get the Dependent Component Node Template Names
+ val dependencyNodeTemplateNodes = dgNodeTemplate.properties?.get(PROPERTY_DEPENDENCY_NODE_TEMPLATES)
+ ?: throw BluePrintException("couldn't get property($PROPERTY_DEPENDENCY_NODE_TEMPLATES) ")
+
+ dependencyNodeTemplates =
+ JacksonUtils.getListFromJsonNode(dependencyNodeTemplateNodes, String::class.java)
+ } else {
+ dependencyNodeTemplates = listOf(nodeTemplateName)
+ }
+
+ log.info("workflow($name) dependent component NodeTemplates($dependencyNodeTemplates)")
+
+ // Check and Get Resource Assignment File
+ val resourceAssignmentArtifacts = dependencyNodeTemplates?.mapNotNull { componentNodeTemplateName ->
+ log.info("identified workflow($name) targets($componentNodeTemplateName)")
+
+ val resourceAssignmentArtifacts = bluePrintContext.nodeTemplateByName(componentNodeTemplateName)
+ .artifacts?.filter {
+ it.value.type == ARTIFACT_TYPE_MAPPING_SOURCE
+ }?.map {
+ log.info("resource assignment artifacts(${it.key}) for NodeType(${componentNodeTemplateName})")
+ it.value.file
+ }
+ resourceAssignmentArtifacts
+ }?.flatten()
+
+ log.info("workflow($name) resource assignment files($resourceAssignmentArtifacts")
+
+ if (resourceAssignmentArtifacts != null && resourceAssignmentArtifacts.isNotEmpty()) {
+
+ // Add Workflow Dynamic Property
+ addWorkFlowDynamicPropertyDefinitions(name, workflow)
+
+ resourceAssignmentArtifacts.forEach { fileName ->
+ // Enhance Resource Assignment File
+ val resourceAssignmentProperties = enhanceResourceAssignmentFile(fileName!!)
+ // Add Workflow Dynamic DataType
+ addWorkFlowDynamicDataType(name, resourceAssignmentProperties)
+ }
+ }
+ }
+
+ // Enhancement for Dynamic Properties, Resource Assignment Properties, Resource Sources
+ private fun enhanceResourceAssignmentFile(fileName: String): MutableMap<String, PropertyDefinition> {
+
+ val filePath = "${bluePrintContext.rootPath}/$fileName"
+
+ log.info("enriching artifacts file(${filePath}")
+
+ val resourceAssignmentProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
+
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
+
+ val alreadyEnhancedKey = "enhanced-$fileName"
+ val alreadyEnhanced = bluePrintRuntimeService.check(alreadyEnhancedKey)
+
+ log.info("enhancing workflow resource mapping file($fileName) already enhanced($alreadyEnhanced)")
+
+ if (!alreadyEnhanced) {
+ // Call Resource Assignment Enhancer
+ resourceAssignmentEnhancerService.enhanceBluePrint(bluePrintTypeEnhancerService, bluePrintRuntimeService, resourceAssignments)
+ bluePrintRuntimeService.put(alreadyEnhancedKey, true.asJsonPrimitive())
+ }
+
+ resourceAssignments.forEach { resourceAssignment ->
+ resourceAssignmentProperties[resourceAssignment.name] = resourceAssignment.property!!
+ }
+ return resourceAssignmentProperties
+ }
+
+ private fun addWorkFlowDynamicPropertyDefinitions(name: String, workflow: Workflow) {
+ val dynamicPropertyName = "$name-properties"
+ val propertyDefinition = PropertyDefinition()
+ propertyDefinition.description = "Dynamic PropertyDefinition for workflow($name)."
+ propertyDefinition.type = "dt-$dynamicPropertyName"
+ propertyDefinition.required = true
+ // Add to Workflow Inputs
+ workflow.inputs?.put(dynamicPropertyName, propertyDefinition)
+ }
+
+ private fun addWorkFlowDynamicDataType(workflowName: String, mappingProperties: MutableMap<String, PropertyDefinition>) {
+
+ val dataTypeName = "dt-$workflowName-properties"
+
+ var dynamicDataType: DataType? = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+
+ if (dynamicDataType == null) {
+ log.info("dataType not present for the recipe({})", dataTypeName)
+ dynamicDataType = DataType()
+ dynamicDataType.version = "1.0.0"
+ dynamicDataType.description = "Dynamic DataType definition for workflow($workflowName)."
+ dynamicDataType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
+
+ val dataTypeProperties: MutableMap<String, PropertyDefinition> = hashMapOf()
+ dynamicDataType.properties = dataTypeProperties
+
+ // Overwrite WorkFlow DataType
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dynamicDataType)
+
+ } else {
+ log.info("dynamic dataType($dataTypeName) already present for workflow($workflowName).")
+ }
+ // Merge all the Recipe Properties
+ mappingProperties.forEach { (propertyName, propertyDefinition) ->
+ dynamicDataType.properties?.put(propertyName, propertyDefinition)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt
new file mode 100644
index 000000000..55eb42f89
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceAssignmentEnhancerService.kt
@@ -0,0 +1,110 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+/**
+ * ResourceAssignmentEnhancerService.
+ *
+ * @author Brinda Santh
+ */
+interface ResourceAssignmentEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceAssignments: List<ResourceAssignment>)
+}
+
+/**
+ * ResourceAssignmentEnhancerDefaultService.
+ *
+ * @author Brinda Santh
+ */
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
+ : ResourceAssignmentEnhancerService {
+ private val log= logger(ResourceAssignmentEnhancerServiceImpl::class)
+
+ /**
+ * Get the defined source instance from the ResourceAssignment,
+ * then get the NodeType of the Sources assigned
+ */
+ override fun enhanceBluePrint(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceAssignments: List<ResourceAssignment>) {
+
+ val uniqueSourceNodeTypeNames = hashSetOf<String>()
+
+ // Iterate the Resource Assignment and
+ resourceAssignments.map { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName!!
+ val dictionarySource = resourceAssignment.dictionarySource!!
+ log.debug("Enriching assignment name(${resourceAssignment.name}), dictionary name($dictionaryName), source($dictionarySource)")
+ val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource)
+
+ // Add Unique Node Types
+ uniqueSourceNodeTypeNames.add(sourceNodeTypeName)
+
+ // TODO("Candidate for Optimisation")
+ if (checkResourceDefinitionNeeded(resourceAssignment)) {
+
+ bluePrintTypeEnhancerService.enhancePropertyDefinition(bluePrintRuntimeService, resourceAssignment.name,
+ resourceAssignment.property!!);
+
+ // Get the Resource Definition from Repo
+ val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName)
+
+ val sourceNodeTemplate = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintException("failed to get assigned dictionarySource($dictionarySource) from resourceDefinition($dictionaryName)")
+
+ // Enrich as NodeTemplate
+ bluePrintTypeEnhancerService.enhanceNodeTemplate(bluePrintRuntimeService, dictionarySource, sourceNodeTemplate)
+ }
+ }
+ // Enrich the ResourceSource NodeTypes
+ uniqueSourceNodeTypeNames.map { nodeTypeName ->
+ val nodeType = resourceDefinitionRepoService.getNodeType(nodeTypeName)
+ bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
+ }
+
+ }
+
+ private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean {
+ return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT)
+ || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT))
+ && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!))
+ }
+
+ private fun getResourceDefinition(name: String): ResourceDefinition {
+ return resourceDefinitionRepoService.getResourceDefinition(name)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt
new file mode 100644
index 000000000..c018664e4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/ResourceDefinitionEnhancerService.kt
@@ -0,0 +1,144 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.async
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+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.utils.ResourceDictionaryUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.service.ResourceDefinitionRepoService
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.springframework.stereotype.Service
+
+interface ResourceDefinitionEnhancerService {
+
+ @Throws(BluePrintException::class)
+ fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition>
+}
+
+@Service
+class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) :
+ ResourceDefinitionEnhancerService {
+
+ private val log = logger(ResourceDefinitionEnhancerService::class)
+
+ companion object {
+ const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
+ }
+
+ // Enhance the Resource Definition
+ // 1. Get the Resource Mapping files from all NodeTemplates.
+ // 2. Get all the Unique Resource assignments from all mapping files
+ // 3. Collect the Resource Definition for Resource Assignment names from database.
+ // 4. Create the Resource Definition under blueprint base path.
+ override fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition> {
+
+ var resourceDefinitions: List<ResourceDefinition> = mutableListOf()
+
+ val blueprintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val mappingFiles = getAllResourceMappingFiles(blueprintContext)
+ log.info("resources assignment files ($mappingFiles)")
+ if (mappingFiles != null) {
+ resourceDefinitions = getResourceDefinition(blueprintContext, mappingFiles)
+ // Enriching Resource Definition Sources
+ enrichResourceDefinitionSources(bluePrintRuntimeService.bluePrintContext(), resourceDefinitions)
+ }
+ return resourceDefinitions
+ }
+
+ // Get all the Mapping files from all node templates.
+ private fun getAllResourceMappingFiles(blueprintContext: BluePrintContext): List<String>? {
+
+ return blueprintContext.nodeTemplates()?.mapNotNull { nodeTemplateMap ->
+
+ // Return only Mapping Artifact File Names
+ nodeTemplateMap.value.artifacts?.filter { artifactDefinitionMap ->
+ artifactDefinitionMap.value.type == ARTIFACT_TYPE_MAPPING_SOURCE
+ }?.mapNotNull { artifactDefinitionMap ->
+ artifactDefinitionMap.value.file
+ }
+
+ }?.flatten()?.distinct()
+ }
+
+ // Convert file content to ResourceAssignments asynchronously
+ private fun getResourceDefinition(blueprintContext: BluePrintContext, files: List<String>) = runBlocking {
+ val blueprintBasePath = blueprintContext.rootPath
+ val deferredResourceAssignments = mutableListOf<Deferred<List<ResourceAssignment>>>()
+ for (file in files) {
+ log.info("processing file ($file)")
+ deferredResourceAssignments += async {
+ ResourceDictionaryUtils.getResourceAssignmentFromFile("$blueprintBasePath/$file")
+ }
+ }
+
+ val resourceAssignments = mutableListOf<ResourceAssignment>()
+ for (deferredResourceAssignment in deferredResourceAssignments) {
+ resourceAssignments.addAll(deferredResourceAssignment.await())
+ }
+
+ val distinctResourceAssignments = resourceAssignments.distinctBy { it.name }
+ generateResourceDictionary(blueprintBasePath, distinctResourceAssignments)
+ //log.info("distinct Resource assignment ($distinctResourceAssignments)")
+ }
+
+
+ // Read the Resource Definitions from the Database and write to type file.
+ private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>)
+ : List<ResourceDefinition> {
+ val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted()
+ log.info("distinct resource keys ($resourceKeys)")
+
+ //TODO("Optimise DB single Query to multiple Query")
+ return resourceKeys.map { resourceKey ->
+ getResourceDefinition(resourceKey)
+ }
+ }
+
+ private fun enrichResourceDefinitionSources(bluePrintContext: BluePrintContext,
+ resourceDefinitions: List<ResourceDefinition>) {
+ val sources = resourceDefinitions
+ .map { it.sources }
+ .map {
+ it.values
+ .map { nodeTemplate ->
+ nodeTemplate.type
+ }
+ }
+ .flatten().distinct()
+ log.info("Enriching Resource Definition sources Node Template: $sources")
+ sources.forEach {
+ BluePrintEnhancerUtils.populateNodeType(bluePrintContext, resourceDefinitionRepoService, it)
+ }
+ }
+
+ // Get the Resource Definition from Database
+ private fun getResourceDefinition(name: String): ResourceDefinition {
+ return resourceDefinitionRepoService.getResourceDefinition(name)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt
new file mode 100644
index 000000000..c074573dd
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt
@@ -0,0 +1,332 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.handler
+
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelContentRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelSearchRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BluePrintEnhancerUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.slf4j.LoggerFactory
+import org.springframework.core.io.ByteArrayResource
+import org.springframework.core.io.Resource
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.http.codec.multipart.FilePart
+import org.springframework.stereotype.Service
+import org.springframework.transaction.annotation.Transactional
+import java.io.File
+import java.io.IOException
+import java.util.*
+
+/**
+ * BlueprintModelHandler Purpose: Handler service to handle the request from BlurPrintModelRest
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+
+@Service
+open class BluePrintModelHandler(private val controllerBlueprintsCatalogService: BluePrintCatalogService,
+ private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val blueprintModelSearchRepository: BlueprintModelSearchRepository,
+ private val blueprintModelRepository: BlueprintModelRepository,
+ private val blueprintModelContentRepository: BlueprintModelContentRepository,
+ private val bluePrintEnhancerService: BluePrintEnhancerService) {
+
+ private val log = LoggerFactory.getLogger(BluePrintModelHandler::class.java)!!
+
+ /**
+ * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database
+ *
+ * @return List<BlueprintModelSearch> list of the controller blueprint archives
+ </BlueprintModelSearch> */
+ open fun allBlueprintModel(): List<BlueprintModelSearch> {
+ return blueprintModelSearchRepository.findAll()
+ }
+
+ /**
+ * This is a saveBlueprintModel method
+ *
+ * @param filePart filePart
+ * @return Mono<BlueprintModelSearch>
+ * @throws BluePrintException BluePrintException
+ </BlueprintModelSearch> */
+ @Throws(BluePrintException::class)
+ open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch {
+ val saveId = UUID.randomUUID().toString()
+ val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId)
+ try {
+ //Recreate the Dir
+ normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, saveId).reCreateDirs()
+ val deCompressedFile = normalizedFile(blueprintArchive, "cba.zip")
+ // Copy the File Part to Local File
+ BluePrintEnhancerUtils.copyFromFilePart(filePart, deCompressedFile)
+ // Save the Copied file to Database
+ val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(saveId, deCompressedFile, false)
+ // Check and Return the Saved File
+ val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId))
+
+ log.info("Save($saveId) successful for blueprint(${blueprintModelSearch.artifactName}) " +
+ "version(${blueprintModelSearch.artifactVersion})")
+ return blueprintModelSearch
+ } catch (e: IOException) {
+ throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Save CBA: ${e.message}", e)
+ } finally {
+ deleteDir(blueprintArchive)
+ }
+ }
+
+
+ /**
+ * This is a searchBlueprintModels method
+ *
+ * @param tags tags
+ * @return List<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ open fun searchBlueprintModels(tags: String): List<BlueprintModelSearch> {
+ return blueprintModelSearchRepository.findByTagsContainingIgnoreCase(tags)
+ }
+
+ /**
+ * This is a getBlueprintModelSearchByNameAndVersion method
+ *
+ * @param name name
+ * @param version version
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open fun getBlueprintModelSearchByNameAndVersion(name: String, version: String): BlueprintModelSearch {
+ return blueprintModelSearchRepository.findByArtifactNameAndArtifactVersion(name, version)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version))
+
+ }
+
+ /**
+ * This is a downloadBlueprintModelFileByNameAndVersion method to download a Blueprint by Name and Version
+ *
+ * @param name name
+ * @param version version
+ * @return ResponseEntity<Resource>
+ * @throws BluePrintException BluePrintException
+ </Resource> */
+ @Throws(BluePrintException::class)
+ open fun downloadBlueprintModelFileByNameAndVersion(name: String,
+ version: String): ResponseEntity<Resource> {
+ val blueprintModel: BlueprintModel
+ try {
+ blueprintModel = getBlueprintModelByNameAndVersion(name, version)
+ } catch (e: BluePrintException) {
+ throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while " + "downloading the CBA file: %s", e.message), e)
+ }
+
+ val fileName = blueprintModel.id + ".zip"
+ val file = blueprintModel.blueprintModelContent?.content
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while downloading the CBA file: couldn't get model content"))
+ return prepareResourceEntity(fileName, file)
+ }
+
+ /**
+ * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource
+ *
+ * @return ResponseEntity<Resource>
+ * @throws BluePrintException BluePrintException
+ </Resource> */
+ @Throws(BluePrintException::class)
+ open fun downloadBlueprintModelFile(id: String): ResponseEntity<Resource> {
+ val blueprintModel: BlueprintModel
+ try {
+ blueprintModel = getBlueprintModel(id)
+ } catch (e: BluePrintException) {
+ throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, String.format("Error while " + "downloading the CBA file: %s", e.message), e)
+ }
+
+ val fileName = blueprintModel.id + ".zip"
+ val file = blueprintModel.blueprintModelContent?.content
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format("Error while downloading the CBA file: couldn't get model content"))
+ return prepareResourceEntity(fileName, file)
+ }
+
+ /**
+ * @return ResponseEntity<Resource>
+ </Resource> */
+ private fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity<Resource> {
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
+ .body(ByteArrayResource(file))
+ }
+
+ /**
+ * This is a getBlueprintModel method
+ *
+ * @param id id
+ * @return BlueprintModel
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open fun getBlueprintModel(id: String): BlueprintModel {
+ val blueprintModel: BlueprintModel
+ val dbBlueprintModel = blueprintModelRepository.findById(id)
+ if (dbBlueprintModel.isPresent) {
+ blueprintModel = dbBlueprintModel.get()
+ } else {
+ val msg = String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)
+ throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, msg)
+ }
+ return blueprintModel
+ }
+
+ /**
+ * This is a getBlueprintModelByNameAndVersion method
+ *
+ * @param name name
+ * @param version version
+ * @return BlueprintModel
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open fun getBlueprintModelByNameAndVersion(name: String, version: String): BlueprintModel {
+ val blueprintModel = blueprintModelRepository
+ .findByArtifactNameAndArtifactVersion(name, version)
+ if (blueprintModel != null) {
+ return blueprintModel
+ } else {
+ val msg = String.format(BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG, name, version)
+ throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, msg)
+ }
+ }
+
+ /**
+ * This is a getBlueprintModelSearch method
+ *
+ * @param id id
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open fun getBlueprintModelSearch(id: String): BlueprintModelSearch {
+ return blueprintModelSearchRepository.findById(id)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id))
+ }
+
+ /**
+ * This is a deleteBlueprintModel method
+ *
+ * @param id id
+ * @throws BluePrintException BluePrintException
+ */
+ @Transactional
+ @Throws(BluePrintException::class)
+ open fun deleteBlueprintModel(id: String) {
+ val dbBlueprintModel = blueprintModelRepository.findById(id)
+ if (dbBlueprintModel != null && dbBlueprintModel.isPresent) {
+ blueprintModelContentRepository.deleteByBlueprintModel(dbBlueprintModel.get())
+ blueprintModelRepository.delete(dbBlueprintModel.get())
+ } else {
+ val msg = String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id)
+ throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, msg)
+ }
+ }
+
+ /**
+ * This is a CBA enrichBlueprint method
+ * Save the Zip File in archive location and extract the cba content.
+ * Populate the Enhancement Location
+ * Enhance the CBA content
+ * Compress the Enhanced Content
+ * Return back the the compressed content back to the caller.
+ *
+ * @param filePart filePart
+ * @return ResponseEntity<Resource>
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open suspend fun enrichBlueprint(filePart: FilePart): ResponseEntity<Resource> {
+ val enhanceId = UUID.randomUUID().toString()
+ val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, enhanceId)
+ val blueprintWorkingDir = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, enhanceId)
+ try {
+ BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchive, blueprintWorkingDir)
+
+ // Enhance the Blue Prints
+ bluePrintEnhancerService.enhance(blueprintWorkingDir)
+
+ return BluePrintEnhancerUtils.compressToFilePart(blueprintWorkingDir, blueprintArchive)
+
+ } catch (e: IOException) {
+ throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Enriching CBA: ${e.message}", e)
+ } finally {
+ BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
+ }
+ }
+
+ /**
+ * This is a publishBlueprintModel method to change the status published to YES
+ *
+ * @param filePart filePart
+ * @return BlueprintModelSearch
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ open suspend fun publishBlueprint(filePart: FilePart): BlueprintModelSearch {
+ val publishId = UUID.randomUUID().toString()
+ val blueprintArchive = bluePrintLoadConfiguration.blueprintArchivePath.plus(File.separator).plus(publishId)
+ val blueprintWorkingDir = bluePrintLoadConfiguration.blueprintWorkingPath.plus(File.separator).plus(publishId)
+ try {
+ val compressedFilePart = BluePrintEnhancerUtils
+ .extractCompressFilePart(filePart, blueprintArchive, blueprintWorkingDir)
+
+ val blueprintId = controllerBlueprintsCatalogService.saveToDatabase(publishId, compressedFilePart, true)
+
+ return blueprintModelSearchRepository.findById(blueprintId)
+ ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value,
+ String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, blueprintId))
+
+ } catch (e: Exception) {
+ throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
+ "Error in Publishing CBA: ${e.message}", e)
+ } finally {
+ BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
+ }
+ }
+
+ companion object {
+
+ private const val BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%s) from repo"
+ private const val BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%s)" + " and version(%s) from repo"
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt
new file mode 100644
index 000000000..5c7ba275d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeHandler.kt
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.handler
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.ModelTypeValidator
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) {
+
+ private val log = LoggerFactory.getLogger(ModelTypeHandler::class.java)!!
+
+ /**
+ * This is a getModelTypeByName service
+ *
+ * @param modelTypeName modelTypeName
+ * @return ModelType
+ */
+ suspend fun getModelTypeByName(modelTypeName: String): ModelType {
+ log.info("Searching : $modelTypeName")
+ check(modelTypeName.isNotBlank()) { "Model Name Information is missing." }
+ val modelType = modelTypeRepository.findByModelName(modelTypeName)
+ return if (modelType != null) {
+ modelType
+ } else {
+ throw BluePrintException("couldn't get modelType($modelTypeName)")
+ }
+ }
+
+
+ /**
+ * This is a searchModelTypes service
+ *
+ * @param tags tags
+ * @return List<ModelType>
+ </ModelType> */
+ suspend fun searchModelTypes(tags: String): List<ModelType> {
+ check(tags.isNotBlank()) { "No Search Information provide" }
+ return modelTypeRepository.findByTagsContainingIgnoreCase(tags)
+ }
+
+ /**
+ * This is a saveModel service
+ *
+ * @param modelType modelType
+ * @return ModelType
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ suspend open fun saveModel(modelType: ModelType): ModelType {
+ lateinit var dbModel: ModelType
+ ModelTypeValidator.validateModelType(modelType)
+ val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName)
+ if (dbModelType != null) {
+ dbModel = dbModelType
+ dbModel.description = modelType.description
+ dbModel.definition = modelType.definition
+ dbModel.definitionType = modelType.definitionType
+ dbModel.derivedFrom = modelType.derivedFrom
+ dbModel.tags = modelType.tags
+ dbModel.version = modelType.version
+ dbModel.updatedBy = modelType.updatedBy
+ dbModel = modelTypeRepository.save(dbModel)
+ } else {
+ dbModel = modelTypeRepository.save(modelType)
+ }
+ return dbModel
+ }
+
+
+ /**
+ * This is a deleteByModelName service
+ *
+ * @param modelName modelName
+ */
+ suspend open fun deleteByModelName(modelName: String) {
+ check(modelName.isNotBlank()) { "Model Name Information is missing." }
+ modelTypeRepository.deleteByModelName(modelName)
+
+ }
+
+ /**
+ * This is a getModelTypeByDefinitionType service
+ *
+ * @param definitionType definitionType
+ * @return List<ModelType>
+ */
+ suspend fun getModelTypeByDefinitionType(definitionType: String): List<ModelType> {
+ check(definitionType.isNotBlank()) { "Model definitionType Information is missing." }
+ return modelTypeRepository.findByDefinitionType(definitionType)
+ }
+
+ /**
+ * This is a getModelTypeByDerivedFrom service
+ *
+ * @param derivedFrom derivedFrom
+ * @return List<ModelType>
+ */
+ suspend fun getModelTypeByDerivedFrom(derivedFrom: String): List<ModelType> {
+ check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." }
+ return modelTypeRepository.findByDerivedFrom(derivedFrom)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt
new file mode 100644
index 000000000..8ba4c7b38
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ResourceDictionaryHandler.kt
@@ -0,0 +1,147 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.handler
+
+import com.google.common.base.Preconditions
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ResourceDictionaryRepository
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.springframework.stereotype.Service
+
+@Service
+class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
+
+
+ /**
+ * This is a getDataDictionaryByName service
+ *
+ * @param name name
+ * @return DataDictionary
+ * @throws BluePrintException BluePrintException
+ */
+ @Throws(BluePrintException::class)
+ suspend fun getResourceDictionaryByName(name: String): ResourceDictionary {
+ Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.")
+ val resourceDictionaryDb = resourceDictionaryRepository.findByName(name)
+ return if (resourceDictionaryDb != null) {
+ resourceDictionaryDb
+ } else {
+ throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name))
+ }
+ }
+
+ /**
+ * This is a searchResourceDictionaryByNames service
+ *
+ * @param names names
+ * @return List<ResourceDictionary>
+ </ResourceDictionary> */
+ suspend fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
+ Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide")
+ return resourceDictionaryRepository.findByNameIn(names)
+ }
+
+ /**
+ * This is a searchResourceDictionaryByTags service
+ *
+ * @param tags tags
+ * @return List<ResourceDictionary>
+ </ResourceDictionary> */
+ suspend fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
+ Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide")
+ return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags)
+ }
+
+ /**
+ * This is a saveDataDictionary service
+ *
+ * @param resourceDictionary resourceDictionary
+ * @return DataDictionary
+ */
+ @Throws(BluePrintException::class)
+ suspend fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
+ var resourceDictionary = resourceDictionary
+
+ val resourceDefinition = resourceDictionary.definition
+ Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content")
+ // Validate the Resource Definitions
+ //TODO( Save Validator)
+ //validate(resourceDefinition)
+
+ resourceDictionary.tags = resourceDefinition.tags!!
+ resourceDefinition.updatedBy = resourceDictionary.updatedBy
+ // Set the Property Definitions
+ val propertyDefinition = resourceDefinition.property
+ resourceDictionary.description = propertyDefinition.description!!
+ resourceDictionary.dataType = propertyDefinition.type
+ if (propertyDefinition.entrySchema != null) {
+ resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type
+ }
+
+ validateResourceDictionary(resourceDictionary)
+
+ val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name)
+ if (dbResourceDictionaryData != null) {
+ val dbResourceDictionary = dbResourceDictionaryData
+
+ dbResourceDictionary.name = resourceDictionary.name
+ dbResourceDictionary.definition = resourceDictionary.definition
+ dbResourceDictionary.description = resourceDictionary.description
+ dbResourceDictionary.tags = resourceDictionary.tags
+ dbResourceDictionary.updatedBy = resourceDictionary.updatedBy
+ dbResourceDictionary.dataType = resourceDictionary.dataType
+ dbResourceDictionary.entrySchema = resourceDictionary.entrySchema
+ resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary)
+ } else {
+ resourceDictionary = resourceDictionaryRepository.save(resourceDictionary)
+ }
+
+ return resourceDictionary
+ }
+
+ /**
+ * This is a deleteResourceDictionary service
+ *
+ * @param name name
+ */
+ suspend fun deleteResourceDictionary(name: String) {
+ check(name.isNotBlank()) { "Resource dictionary name is missing." }
+ resourceDictionaryRepository.deleteByName(name)
+ }
+
+ /**
+ * This is a getResourceSourceMapping service
+ */
+ suspend fun getResourceSourceMapping(): ResourceSourceMapping {
+ return ResourceSourceMappingFactory.getRegisterSourceMapping()
+ }
+
+ private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean {
+ checkNotEmpty(resourceDictionary.name){ "DataDictionary Definition name is missing."}
+ checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." }
+ checkNotEmpty(resourceDictionary.description){ "DataDictionary Definition Information is missing."}
+ checkNotEmpty(resourceDictionary.tags){ "DataDictionary Definition tags is missing."}
+ checkNotEmpty(resourceDictionary.updatedBy){ "DataDictionary Definition updatedBy is missing."}
+ return true
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt
new file mode 100644
index 000000000..36df06909
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintCatalogLoadService.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.load
+
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.async
+import kotlinx.coroutines.runBlocking
+import org.apache.commons.lang.text.StrBuilder
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+import java.util.*
+
+@Service
+open class BluePrintCatalogLoadService(private val controllerBlueprintsCatalogService: BluePrintCatalogService) {
+
+ private val log = LoggerFactory.getLogger(BluePrintCatalogLoadService::class.java)
+
+ open fun loadPathsBluePrintModelCatalog(paths: List<String>) {
+ paths.forEach { loadPathBluePrintModelCatalog(it) }
+ }
+
+ open fun loadPathBluePrintModelCatalog(path: String) {
+
+ val files = File(path).listFiles()
+ runBlocking {
+ val errorBuilder = StrBuilder()
+ val deferredResults = mutableListOf<Deferred<Unit>>()
+
+ for (file in files) {
+ deferredResults += async {
+ loadBluePrintModelCatalog(errorBuilder, file)
+ }
+ }
+
+ for (deferredResult in deferredResults) {
+ deferredResult.await()
+ }
+
+ if (!errorBuilder.isEmpty) {
+ log.error(errorBuilder.toString())
+ }
+ }
+ }
+
+ open suspend fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) {
+ try {
+ controllerBlueprintsCatalogService.saveToDatabase(UUID.randomUUID().toString(), file)
+ } catch (e: Exception) {
+ errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}")
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt
new file mode 100644
index 000000000..f30d156ef
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/BluePrintDatabaseLoadService.kt
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.load
+
+import kotlinx.coroutines.runBlocking
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.slf4j.LoggerFactory
+import org.springframework.boot.context.event.ApplicationReadyEvent
+import org.springframework.context.event.EventListener
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
+ private val modelTypeLoadService: ModelTypeLoadService,
+ private val resourceDictionaryLoadService: ResourceDictionaryLoadService,
+ private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) {
+
+ private val log = LoggerFactory.getLogger(BluePrintDatabaseLoadService::class.java)
+
+
+ @EventListener(ApplicationReadyEvent::class)
+ open fun init() = runBlocking {
+ if (bluePrintLoadConfiguration.loadInitialData) {
+ initModelTypes()
+ initResourceDictionary()
+ initBluePrintCatalog()
+ } else {
+ log.info("Initial data load is disabled")
+ }
+
+ }
+
+ open suspend fun initModelTypes() {
+ log.info("model types load configuration(${bluePrintLoadConfiguration.loadModelType}) " +
+ "under paths(${bluePrintLoadConfiguration.loadModeTypePaths})")
+
+ if (bluePrintLoadConfiguration.loadModelType) {
+ val paths = bluePrintLoadConfiguration.loadModeTypePaths?.split(",")
+ paths?.let {
+ modelTypeLoadService.loadPathsModelType(paths)
+ }
+ }
+ }
+
+ open suspend fun initResourceDictionary() {
+ log.info("resource dictionary load configuration(${bluePrintLoadConfiguration.loadResourceDictionary}) " +
+ "under paths(${bluePrintLoadConfiguration.loadResourceDictionaryPaths})")
+
+ if (bluePrintLoadConfiguration.loadResourceDictionary) {
+ val paths = bluePrintLoadConfiguration.loadResourceDictionaryPaths?.split(",")
+ paths?.let {
+ resourceDictionaryLoadService.loadPathsResourceDictionary(paths)
+ }
+ }
+ }
+
+ open suspend fun initBluePrintCatalog() {
+ log.info("blueprint load configuration(${bluePrintLoadConfiguration.loadBluePrint}) " +
+ "under paths(${bluePrintLoadConfiguration.loadBluePrintPaths})")
+
+ if (bluePrintLoadConfiguration.loadBluePrint) {
+ val paths = bluePrintLoadConfiguration.loadBluePrintPaths?.split(",")
+ paths?.let {
+ bluePrintCatalogLoadService.loadPathsBluePrintModelCatalog(paths)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt
new file mode 100644
index 000000000..9f43740aa
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ModelTypeLoadService.kt
@@ -0,0 +1,146 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.load
+
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.coroutineScope
+import org.apache.commons.io.FilenameUtils
+import org.apache.commons.lang3.text.StrBuilder
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ModelTypeHandler
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) {
+
+ private val log = LoggerFactory.getLogger(ModelTypeLoadService::class.java)
+ private val updateBySystem = "System"
+
+ open suspend fun loadPathsModelType(modelTypePaths: List<String>) {
+ modelTypePaths.forEach {
+ loadPathModelType(it)
+ }
+ }
+
+ /**
+ * Load the Model Type file content from the defined path, Load of sequencing should be maintained.
+ */
+ open suspend fun loadPathModelType(modelTypePath: String) {
+ log.info(" ****** loadModelType($modelTypePath) ********")
+ try {
+ val errorBuilder = StrBuilder()
+
+ coroutineScope {
+ val dataTypeFiles = normalizedFile("$modelTypePath", "data_type").listFiles()
+ val deferred = dataTypeFiles.map {
+ async {
+ loadModelType(it, DataType::class.java, errorBuilder)
+ }
+ }
+ deferred.awaitAll()
+ }
+
+ coroutineScope {
+ val artifactTypeFiles = normalizedFile("$modelTypePath", "artifact_type").listFiles()
+ val deferred = artifactTypeFiles.map {
+ async {
+ loadModelType(it, ArtifactType::class.java, errorBuilder)
+ }
+ }
+ deferred.awaitAll()
+ }
+
+ coroutineScope {
+ val relationshipTypeFiles = normalizedFile("$modelTypePath", "relationship_type").listFiles()
+ val deferred = relationshipTypeFiles.map {
+ async {
+ loadModelType(it, RelationshipType::class.java, errorBuilder)
+ }
+ }
+ deferred.awaitAll()
+ }
+
+ coroutineScope {
+ val nodeTypeFiles = normalizedFile("$modelTypePath", "node_type").listFiles()
+ val deferred = nodeTypeFiles.map {
+ async {
+ loadModelType(it, NodeType::class.java, errorBuilder)
+ }
+ }
+ deferred.awaitAll()
+ }
+
+ if (!errorBuilder.isEmpty) {
+ log.error(errorBuilder.toString())
+ }
+ } catch (e: Exception) {
+ log.error("Failed to loade ModelTypes under($modelTypePath)", e)
+ }
+ }
+
+ private suspend inline fun <reified T> loadModelType(file: File, classType: Class<T>, errorBuilder: StrBuilder) {
+ try {
+ log.trace("Loading ${classType.name} (${file.name})")
+ val dataKey = FilenameUtils.getBaseName(file.name)
+ val definitionContent = file.readNBText()
+ val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType
+ //checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
+
+ val modelType = ModelType()
+ val definitionType: String?
+ when (T::class) {
+ DataType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ }
+ RelationshipType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE
+ }
+ ArtifactType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE
+ }
+ NodeType::class -> {
+ definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE
+ }
+ else -> {
+ throw BluePrintException("couldn't process model type($classType) definition")
+ }
+ }
+ modelType.definitionType = definitionType
+ modelType.derivedFrom = definition.derivedFrom
+ modelType.description = definition.description!!
+ modelType.definition = JacksonUtils.jsonNode(definitionContent)
+ modelType.modelName = dataKey
+ modelType.version = definition.version
+ modelType.updatedBy = updateBySystem
+ modelType.tags = (dataKey + "," + definition.derivedFrom + "," + definitionType)
+ modelTypeHandler.saveModel(modelType)
+ log.trace("${classType.name}(${file.name}) loaded successfully ")
+ } catch (e: Exception) {
+ errorBuilder.appendln("Couldn't load ${classType.name}(${file.name}: ${e.message}")
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt
new file mode 100644
index 000000000..95073e99d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/load/ResourceDictionaryLoadService.kt
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.load
+
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.coroutineScope
+import org.apache.commons.lang3.StringUtils
+import org.apache.commons.lang3.text.StrBuilder
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.ResourceDictionaryHandler
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
+
+ private val log = LoggerFactory.getLogger(ResourceDictionaryLoadService::class.java)
+
+ open suspend fun loadPathsResourceDictionary(paths: List<String>) {
+ coroutineScope {
+ val deferred = paths.map {
+ async {
+ loadPathResourceDictionary(it)
+ }
+ }
+ deferred.awaitAll()
+ }
+ }
+
+ open suspend fun loadPathResourceDictionary(path: String) {
+ log.info(" ******* loadResourceDictionary($path) ********")
+ val files = normalizedFile(path).listFiles()
+ val errorBuilder = StrBuilder()
+
+ coroutineScope() {
+ val deferred = files.map {
+ async {
+ loadResourceDictionary(errorBuilder, it)
+ }
+ }
+ deferred.awaitAll()
+ }
+
+ if (!errorBuilder.isEmpty) {
+ log.error(errorBuilder.toString())
+ }
+
+ }
+
+ private suspend fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) {
+ try {
+ log.trace("Loading NodeType(${file.name}}")
+ val definitionContent = file.readNBText()
+ val resourceDefinition = JacksonUtils.readValue(definitionContent, ResourceDefinition::class.java)
+ if (resourceDefinition != null) {
+
+ checkNotNull(resourceDefinition.property) { "Failed to get Property Definition" }
+ val resourceDictionary = ResourceDictionary()
+ resourceDictionary.name = resourceDefinition.name
+ resourceDictionary.definition = resourceDefinition
+
+ checkNotNull(resourceDefinition.property) { "Property field is missing" }
+ resourceDictionary.description = resourceDefinition.property.description!!
+ resourceDictionary.dataType = resourceDefinition.property.type
+
+ if (resourceDefinition.property.entrySchema != null) {
+ resourceDictionary.entrySchema = resourceDefinition.property.entrySchema!!.type
+ }
+ resourceDictionary.updatedBy = resourceDefinition.updatedBy
+
+ if (StringUtils.isBlank(resourceDefinition.tags)) {
+ resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy
+ + ", " + resourceDefinition.updatedBy)
+
+ } else {
+ resourceDictionary.tags = resourceDefinition.tags!!
+ }
+ resourceDictionaryHandler.saveResourceDictionary(resourceDictionary)
+
+ log.trace("Resource dictionary(${file.name}) loaded successfully ")
+ } else {
+ throw BluePrintException("couldn't get dictionary from content information")
+ }
+ } catch (e: Exception) {
+ errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}")
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt
new file mode 100644
index 000000000..1d69cd7cc
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/BluePrintsReactRepository.kt
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.springframework.stereotype.Service
+import reactor.core.publisher.Flux
+import reactor.core.publisher.Mono
+import reactor.core.scheduler.Schedulers
+// TODO("Convert into coroutines")
+/**
+ * ModelTypeReactRepository.
+ *
+ * @author Brinda Santh
+ */
+@Service
+open class ModelTypeReactRepository(private val modelTypeRepository: ModelTypeRepository) {
+
+ fun save(modelType: ModelType): Mono<ModelType> {
+ return Mono.justOrEmpty(modelTypeRepository.save(modelType))
+ }
+
+ fun findByModelName(modelName: String): Mono<ModelType> {
+ return Mono.justOrEmpty(modelTypeRepository.findByModelName(modelName))
+ }
+
+ fun findByModelNameIn(modelNames: List<String>): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByModelNameIn(modelNames))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun findByDerivedFrom(derivedFrom: String): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByDerivedFrom(derivedFrom))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun findByDerivedFromIn(derivedFroms: List<String>): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByDerivedFromIn(derivedFroms))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun findByDefinitionType(definitionType: String): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByDefinitionType(definitionType))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun findByDefinitionTypeIn(definitionTypes: List<String>): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByDefinitionTypeIn(definitionTypes))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun findByTagsContainingIgnoreCase(tags: String): Flux<ModelType> {
+ return Flux.fromIterable(modelTypeRepository.findByTagsContainingIgnoreCase(tags))
+ .subscribeOn(Schedulers.elastic())
+ }
+
+ fun deleteByModelName(modelName: String): Mono<Void> {
+ modelTypeRepository.deleteByModelName(modelName)
+ return Mono.empty()
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt
new file mode 100644
index 000000000..3e36947a4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeRepository.kt
@@ -0,0 +1,85 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+import javax.transaction.Transactional
+
+@Repository
+interface ModelTypeRepository : JpaRepository<ModelType, String> {
+ /**
+ * This is a findByModelName method
+ *
+ * @param modelName Model Name
+ * @return Optional<ModelType>
+ */
+ fun findByModelName(modelName: String): ModelType?
+ /**
+ * This is a findByModelNameIn method
+ *
+ * @param modelNames Model Names
+ * @return List<ModelType>
+ */
+ fun findByModelNameIn(modelNames: List<String>): List<ModelType>
+ /**
+ * This is a findByDerivedFrom method
+ *
+ * @param derivedFrom Derived From
+ * @return List<ModelType>
+ */
+ fun findByDerivedFrom(derivedFrom: String): List<ModelType>
+ /**
+ * This is a findByDerivedFromIn method
+ *
+ * @param derivedFroms Derived Froms
+ * @return List<ModelType>
+ */
+ fun findByDerivedFromIn(derivedFroms: List<String>): List<ModelType>
+
+ /**
+ * This is a findByDefinitionType method
+ *
+ * @param definitionType Definition Type
+ * @return List<ModelType>
+ */
+ fun findByDefinitionType(definitionType: String): List<ModelType>
+ /**
+ * This is a findByDefinitionTypeIn method
+ *
+ * @param definitionTypes Definition Types
+ * @return List<ModelType>
+ */
+ fun findByDefinitionTypeIn(definitionTypes: List<String>): List<ModelType>
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags Tags
+ * @return Optional<ModelType>
+ */
+ fun findByTagsContainingIgnoreCase(tags: String): List<ModelType>
+
+ /**
+ * This is a deleteByModelName method
+ *
+ * @param modelName ModelName
+ */
+ @Transactional
+ fun deleteByModelName(modelName: String)
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt
new file mode 100644
index 000000000..68db371c6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepository.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.repository
+
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+
+
+/**
+ * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+interface ResourceDictionaryRepository : JpaRepository<ResourceDictionary, String> {
+
+
+ /**
+ * This is a findByName method
+ *
+ * @param name name
+ * @return Optional<ResourceMapping>
+ </ResourceMapping> */
+ fun findByName(name: String): ResourceDictionary?
+
+ /**
+ * This is a findByNameIn method
+ *
+ * @param names names
+ * @return Optional<ResourceMapping>
+ </ResourceMapping> */
+ fun findByNameIn(names: List<String>): List<ResourceDictionary>
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags tags
+ * @return Optional<ModelType>
+ </ModelType> */
+ fun findByTagsContainingIgnoreCase(tags: String): List<ResourceDictionary>
+
+ /**
+ * This is a deleteByName method
+ *
+ * @param name name
+ */
+ fun deleteByName(name: String)
+
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt
new file mode 100644
index 000000000..edf4c8cf6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/ApplicationRegistrationService.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.service
+
+import org.apache.commons.collections.CollectionUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.stereotype.Component
+import javax.annotation.PostConstruct
+
+@Component
+class ApplicationRegistrationService {
+
+ @Value("#{'\${resourceSourceMappings}'.split(',')}")
+ private val resourceSourceMappings: List<String>? = null
+
+ @PostConstruct
+ fun register() {
+ registerDictionarySources()
+ }
+
+ fun registerDictionarySources() {
+ log.info("Registering Dictionary Sources : {}", resourceSourceMappings)
+ if (CollectionUtils.isNotEmpty(resourceSourceMappings)) {
+ resourceSourceMappings!!.forEach { resourceSourceMapping ->
+ val mappingKeyValue = resourceSourceMapping.split("=".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
+ if (mappingKeyValue != null && mappingKeyValue.size == 2) {
+ ResourceSourceMappingFactory.registerSourceMapping(mappingKeyValue[0].trim { it <= ' ' }, mappingKeyValue[1].trim { it <= ' ' })
+ } else {
+ log.warn("failed to get resource source mapping {}", resourceSourceMapping)
+ }
+ }
+ }
+ }
+
+ companion object {
+ private val log = LoggerFactory.getLogger(ApplicationRegistrationService::class.java)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/AutoResourceMappingService.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/AutoResourceMappingService.kt
new file mode 100644
index 000000000..be562642f
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/AutoResourceMappingService.kt
@@ -0,0 +1,174 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Huawei.
+ *
+ * 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.cds.blueprintsprocessor.designer.api.service
+
+import com.google.common.base.Preconditions
+import org.apache.commons.collections.CollectionUtils
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.AutoMapResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ResourceDictionaryRepository
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.util.*
+
+@Service
+open class AutoResourceMappingService(private val dataDictionaryRepository: ResourceDictionaryRepository) {
+
+ private val log = LoggerFactory.getLogger(AutoResourceMappingService::class.java)
+
+ @Throws(BluePrintException::class)
+ fun autoMap(resourceAssignments: MutableList<ResourceAssignment>):
+ AutoMapResponse {
+ val autoMapResponse = AutoMapResponse()
+ try {
+ if (CollectionUtils.isNotEmpty(resourceAssignments)) {
+ // Create the Dictionary definitions for the ResourceAssignment Names
+ val dictionaryMap = getDictionaryDefinitions(resourceAssignments)
+
+ for (resourceAssignment in resourceAssignments) {
+ if (StringUtils.isNotBlank(resourceAssignment.name)
+ && StringUtils.isBlank(resourceAssignment.dictionaryName)) {
+ populateDictionaryMapping(dictionaryMap, resourceAssignment)
+ log.info("Mapped Resource : {}", resourceAssignment)
+ }
+ }
+ }
+ val dictionaries = getDictionaryDefinitionsList(resourceAssignments)
+ val resourceAssignmentsFinal = getAllAutoMapResourceAssignments(resourceAssignments)
+ autoMapResponse.dataDictionaries = dictionaries
+ autoMapResponse.resourceAssignments = resourceAssignmentsFinal
+ } catch (e: Exception) {
+ log.error(String.format("Failed in auto process %s", e.message))
+ throw BluePrintException(e, e.message!!)
+ }
+
+ return autoMapResponse
+ }
+
+ private fun populateDictionaryMapping(dictionaryMap: Map<String, ResourceDictionary>, resourceAssignment: ResourceAssignment) {
+ val dbDataDictionary = dictionaryMap[resourceAssignment.name]
+ if (dbDataDictionary != null && dbDataDictionary.definition != null) {
+
+ val dictionaryDefinition = dbDataDictionary.definition
+
+ if (dictionaryDefinition != null && StringUtils.isNotBlank(dictionaryDefinition.name)
+ && StringUtils.isBlank(resourceAssignment.dictionaryName)) {
+
+ resourceAssignment.dictionaryName = dbDataDictionary.name
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition)
+ }
+ }
+ }
+
+ private fun getDictionaryDefinitions(resourceAssignments: List<ResourceAssignment>): Map<String, ResourceDictionary> {
+ val dictionaryMap = HashMap<String, ResourceDictionary>()
+ val names = ArrayList<String>()
+ for (resourceAssignment in resourceAssignments) {
+ if (StringUtils.isNotBlank(resourceAssignment.name)) {
+ names.add(resourceAssignment.name)
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+
+ val dictionaries = dataDictionaryRepository.findByNameIn(names)
+ if (CollectionUtils.isNotEmpty(dictionaries)) {
+ for (dataDictionary in dictionaries) {
+ if (StringUtils.isNotBlank(dataDictionary.name)) {
+ dictionaryMap[dataDictionary.name] = dataDictionary
+ }
+ }
+ }
+ }
+ return dictionaryMap
+
+ }
+ private fun getDictionaryDefinitionsList(resourceAssignments: List<ResourceAssignment>): List<ResourceDictionary>? {
+ var dictionaries: List<ResourceDictionary>? = null
+ val names = ArrayList<String>()
+ for (resourceAssignment in resourceAssignments) {
+ if (StringUtils.isNotBlank(resourceAssignment.dictionaryName)) {
+
+ if (!names.contains(resourceAssignment.dictionaryName)) {
+ names.add(resourceAssignment.dictionaryName!!)
+ }
+
+ if (resourceAssignment.dependencies != null && !resourceAssignment.dependencies!!.isEmpty()) {
+ val dependencyNames = resourceAssignment.dependencies
+ for (dependencyName in dependencyNames!!) {
+ if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName)) {
+ names.add(dependencyName)
+ }
+ }
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(names)) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names)
+ }
+ return dictionaries
+
+ }
+
+ private fun getAllAutoMapResourceAssignments(resourceAssignments: MutableList<ResourceAssignment>): List<ResourceAssignment> {
+ var dictionaries: List<ResourceDictionary>? = null
+ val names = ArrayList<String>()
+ for (resourceAssignment in resourceAssignments) {
+ if (StringUtils.isNotBlank(resourceAssignment.dictionaryName)) {
+ if (resourceAssignment.dependencies != null && !resourceAssignment.dependencies!!.isEmpty()) {
+ val dependencyNames = resourceAssignment.dependencies
+ for (dependencyName in dependencyNames!!) {
+ if (StringUtils.isNotBlank(dependencyName) && !names.contains(dependencyName)
+ && !checkAssignmentsExists(resourceAssignments, dependencyName)) {
+ names.add(dependencyName)
+ }
+ }
+ }
+ }
+ }
+
+ if (!names.isEmpty()) {
+ dictionaries = dataDictionaryRepository.findByNameIn(names)
+ }
+ if (dictionaries != null) {
+ for (rscDictionary in dictionaries) {
+ val dictionaryDefinition = rscDictionary.definition
+ Preconditions.checkNotNull(dictionaryDefinition, "failed to get Resource Definition from dictionary definition")
+ val property = PropertyDefinition()
+ property.required = true
+ val resourceAssignment = ResourceAssignment()
+ resourceAssignment.name = rscDictionary.name
+ resourceAssignment.dictionaryName = rscDictionary.name
+ resourceAssignment.version = 0
+ resourceAssignment.property = property
+ ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition)
+ resourceAssignments.add(resourceAssignment)
+ }
+ }
+ return resourceAssignments
+ }
+
+
+ private fun checkAssignmentsExists(resourceAssignmentsWithDepencies: List<ResourceAssignment>, resourceName: String): Boolean {
+ return resourceAssignmentsWithDepencies.stream().anyMatch { names -> names.name.equals(resourceName, ignoreCase = true) }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt
new file mode 100644
index 000000000..f8e6163a5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/service/BluePrintRepoServiceImpl.kt
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.service
+
+import com.fasterxml.jackson.databind.JsonNode
+import com.google.common.base.Preconditions
+import org.apache.commons.lang3.StringUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ModelTypeRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.repository.ResourceDictionaryRepository
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+import org.springframework.stereotype.Service
+
+interface ResourceDefinitionRepoService : BluePrintRepoService {
+
+ @Throws(BluePrintException::class)
+ fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition
+}
+
+@Service
+open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRepository,
+ private val resourceDictionaryRepository: ResourceDictionaryRepository) : ResourceDefinitionRepoService {
+
+ @Throws(BluePrintException::class)
+ override fun getNodeType(nodeTypeName: String): NodeType {
+ return getModelType(nodeTypeName, NodeType::class.java)
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName)")
+ }
+
+ @Throws(BluePrintException::class)
+ override fun getDataType(dataTypeName: String): DataType {
+ return getModelType(dataTypeName, DataType::class.java)
+ ?: throw BluePrintException("couldn't get DataType($dataTypeName)")
+ }
+
+ @Throws(BluePrintException::class)
+ override fun getArtifactType(artifactTypeName: String): ArtifactType {
+ return getModelType(artifactTypeName, ArtifactType::class.java)
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName)")
+ }
+
+ @Throws(BluePrintException::class)
+ override fun getRelationshipType(relationshipTypeName: String): RelationshipType {
+ return getModelType(relationshipTypeName, RelationshipType::class.java)
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipTypeName)")
+ }
+
+ @Throws(BluePrintException::class)
+ override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition {
+ return getModelType(capabilityDefinitionName, CapabilityDefinition::class.java)
+ ?: throw BluePrintException("couldn't get CapabilityDefinition($capabilityDefinitionName)")
+ }
+
+ @Throws(BluePrintException::class)
+ override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition {
+ val dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName)
+ return if (dbResourceDictionary != null) {
+ dbResourceDictionary.definition
+ } else {
+ throw BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName))
+ }
+ }
+
+ @Throws(BluePrintException::class)
+ private fun <T> getModelType(modelName: String, valueClass: Class<T>): T? {
+ Preconditions.checkArgument(StringUtils.isNotBlank(modelName),
+ "Failed to get model from repo, model name is missing")
+
+ val modelDefinition = getModelDefinition(modelName)
+ Preconditions.checkNotNull(modelDefinition,
+ String.format("Failed to get model content for model name (%s)", modelName))
+
+ return JacksonUtils.readValue(modelDefinition, valueClass)
+ }
+
+ @Throws(BluePrintException::class)
+ private fun getModelDefinition(modelName: String): JsonNode {
+ val modelDefinition: JsonNode
+ val modelTypeDb = modelTypeRepository.findByModelName(modelName)
+ if (modelTypeDb != null) {
+ modelDefinition = modelTypeDb.definition
+ } else {
+ throw BluePrintException(String.format("failed to get model definition (%s) from repo", modelName))
+ }
+ return modelDefinition
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt
new file mode 100644
index 000000000..6eab5cd3f
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtils.kt
@@ -0,0 +1,164 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api.utils
+
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.reactive.awaitSingle
+import kotlinx.coroutines.withContext
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
+import org.springframework.core.io.ByteArrayResource
+import org.springframework.core.io.Resource
+import org.springframework.http.HttpHeaders
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.http.codec.multipart.FilePart
+import org.springframework.util.StringUtils
+import reactor.core.publisher.Mono
+import java.io.File
+import java.io.IOException
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.util.*
+
+
+class BluePrintEnhancerUtils {
+ companion object {
+
+ fun populateDataTypes(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ dataTypeName: String): DataType {
+ val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: bluePrintRepoService.getDataType(dataTypeName)
+ ?: throw BluePrintException("couldn't get DataType($dataTypeName) from repo.")
+ bluePrintContext.serviceTemplate.dataTypes?.put(dataTypeName, dataType)
+ return dataType
+ }
+
+ fun populateRelationshipType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ relationshipName: String): RelationshipType {
+
+ val relationshipType = bluePrintContext.serviceTemplate.relationshipTypes?.get(relationshipName)
+ ?: bluePrintRepoService.getRelationshipType(relationshipName)
+ ?: throw BluePrintException("couldn't get RelationshipType($relationshipName) from repo.")
+ bluePrintContext.serviceTemplate.relationshipTypes?.put(relationshipName, relationshipType)
+ return relationshipType
+ }
+
+
+ fun populateNodeType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ nodeTypeName: String): NodeType {
+
+ val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
+ ?: bluePrintRepoService.getNodeType(nodeTypeName)
+ ?: throw BluePrintException("couldn't get NodeType($nodeTypeName) from repo.")
+ bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
+ return nodeType
+ }
+
+ fun populateArtifactType(bluePrintContext: BluePrintContext, bluePrintRepoService: BluePrintRepoService,
+ artifactTypeName: String): ArtifactType {
+
+ val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: bluePrintRepoService.getArtifactType(artifactTypeName)
+ ?: throw BluePrintException("couldn't get ArtifactType($artifactTypeName) from repo.")
+ bluePrintContext.serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType)
+ return artifactType
+ }
+
+ suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File {
+ // Delete the Directory
+ targetFile.deleteRecursively()
+ return filePart.transferTo(targetFile)
+ .thenReturn(targetFile)
+ .awaitSingle()
+ }
+
+ suspend fun extractCompressFilePart(filePart: FilePart, archiveDir: String, enhanceDir: String): File {
+ //Recreate the Base Directories
+ normalizedFile(archiveDir).reCreateDirs()
+ normalizedFile(enhanceDir).reCreateDirs()
+ val filePartFile = normalizedFile(archiveDir, "cba.zip")
+ // Copy the File Part to ZIP
+ return copyFromFilePart(filePart, filePartFile)
+ }
+
+ suspend fun decompressFilePart(filePart: FilePart, archiveDir: String, enhanceDir: String): File {
+ val filePartFile = extractCompressFilePart(filePart, archiveDir, enhanceDir)
+ val deCompressFileName = normalizedPathName(enhanceDir)
+ return filePartFile.deCompress(deCompressFileName)
+ }
+
+ suspend fun compressToFilePart(enhanceDir: String, archiveDir: String,
+ outputFileName:String="enhanced-cba.zip"): ResponseEntity<Resource> {
+ val compressedFile = normalizedFile(archiveDir, outputFileName)
+ BluePrintArchiveUtils.compress(Paths.get(enhanceDir).toFile(), compressedFile)
+ return prepareResourceEntity(compressedFile.name, compressedFile.readBytes())
+ }
+
+ suspend fun prepareResourceEntity(fileName: String, file: ByteArray): ResponseEntity<Resource> {
+ return ResponseEntity.ok()
+ .contentType(MediaType.parseMediaType("text/plain"))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"$fileName\"")
+ .body(ByteArrayResource(file))
+ }
+
+ suspend fun cleanEnhancer(archiveLocation: String, enhancementLocation: String) = withContext(Dispatchers.Default) {
+ deleteDir(archiveLocation)
+ deleteDir(enhancementLocation)
+ }
+
+ /**
+ * This is a saveCBAFile method
+ * take a [FilePart], transfer it to disk using a Flux of FilePart and return a [Mono] representing the CBA file name
+ *
+ * @param (filePart, targetDirectory) - the request part containing the file to be saved and the default directory where to save
+ * @return a [Mono] String representing the result of the operation
+ * @throws (BluePrintException, IOException) BluePrintException, IOException
+ */
+ @Throws(BluePrintException::class, IOException::class)
+ fun saveCBAFile(filePart: FilePart, targetDirectory: Path): Mono<String> {
+
+ // Normalize file name
+ val fileName = StringUtils.cleanPath(filePart.filename())
+
+ // Check if the file's extension is "CBA"
+ if (StringUtils.getFilenameExtension(fileName) != "zip") {
+ throw BluePrintException(ErrorCode.INVALID_FILE_EXTENSION.value, "Invalid file extension required ZIP")
+ }
+
+ // Change file name to match a pattern
+ val changedFileName = UUID.randomUUID().toString() + ".zip"
+ //String changedFileName = BluePrintFileUtils.Companion.getCBAGeneratedFileName(fileName, this.CBA_FILE_NAME_PATTERN);
+
+ // Copy file to the target location (Replacing existing file with the same name)
+ val targetLocation = targetDirectory.resolve(changedFileName)
+
+ // if a file with the same name already exists in a repository, delete and recreate it
+ val file = File(targetLocation.toString())
+ if (file.exists())
+ file.delete()
+ file.createNewFile()
+
+ return filePart.transferTo(file).thenReturn(changedFileName)
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt
new file mode 100644
index 000000000..8ec0b9bab
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidator.kt
@@ -0,0 +1,83 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.cds.controllerblueprints.core.data.*
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+class ModelTypeValidator {
+ companion object {
+ /**
+ * This is a validateModelTypeDefinition
+ *
+ * @param definitionType definitionType
+ * @param definitionContent definitionContent
+ * @return boolean
+ */
+ fun validateModelTypeDefinition(definitionType: String, definitionContent: JsonNode): Boolean {
+
+ when (definitionType) {
+ BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE -> {
+ JacksonUtils.readValue(definitionContent, DataType::class.java)
+ ?: throw BluePrintException("Model type definition is not DataType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE -> {
+ JacksonUtils.readValue(definitionContent, NodeType::class.java)
+ ?: throw BluePrintException("Model type definition is not NodeType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE -> {
+ JacksonUtils.readValue(definitionContent, ArtifactType::class.java)
+ ?: throw BluePrintException("Model type definition is not ArtifactType valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE -> {
+ JacksonUtils.readValue(definitionContent, CapabilityDefinition::class.java)
+ ?: throw BluePrintException("Model type definition is not CapabilityDefinition valid content $definitionContent")
+ }
+ BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE -> {
+ JacksonUtils.readValue(definitionContent, RelationshipType::class.java)
+ ?: throw BluePrintException("Model type definition is not RelationshipType valid content $definitionContent")
+ }
+ }
+ return true
+ }
+
+ /**
+ * This is a validateModelType method
+ *
+ * @param modelType modelType
+ * @return boolean
+ */
+ fun validateModelType(modelType: ModelType?): Boolean {
+ checkNotNull(modelType) { "Model Type Information is missing." }
+
+ val validRootTypes = BluePrintTypes.validModelTypes()
+
+ check(validRootTypes.contains(modelType.definitionType)) {
+ "Not Valid Model Root Type(${modelType.definitionType}), It should be $validRootTypes"
+ }
+
+ validateModelTypeDefinition(modelType.definitionType, modelType.definition)
+ return true
+ }
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt
new file mode 100644
index 000000000..877584ed6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelControllerTest.kt
@@ -0,0 +1,223 @@
+/*
+ * Copyright © 2019 Bell Canada Intellectual Property.
+ * Modifications Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import kotlinx.coroutines.reactive.awaitSingle
+import kotlinx.coroutines.runBlocking
+import org.json.JSONException
+import org.junit.After
+import org.junit.Before
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.core.io.ByteArrayResource
+import org.springframework.http.HttpMethod
+import org.springframework.http.HttpStatus
+import org.springframework.http.client.MultipartBodyBuilder
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.test.web.reactive.server.WebTestClient
+import org.springframework.test.web.reactive.server.returnResult
+import org.springframework.util.Base64Utils
+import org.springframework.web.reactive.function.BodyInserters
+import java.io.File
+import java.nio.charset.StandardCharsets.UTF_8
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * BlueprintModelControllerTest Purpose: Integration test at API level
+ *
+ * @author Vinal Patel
+ * @version 1.0
+ */
+
+@RunWith(SpringRunner::class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class BlueprintModelControllerTest {
+
+ private val log = LoggerFactory.getLogger(BlueprintModelControllerTest::class.java)!!
+
+ companion object {
+ private var bp: BlueprintModelSearch? = null
+ }
+
+ @Autowired
+ lateinit var webTestClient: WebTestClient
+
+ private var bluePrintLoadConfiguration: BluePrintLoadConfiguration? = null
+
+ private val blueprintDir = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ private var zipBlueprintFileName: String? = null
+
+ private var testZipFile: File? = null
+
+
+ @Before
+ fun setUp() {
+ assertNotNull(webTestClient, " Failed to create WebTestClient")
+
+ bluePrintLoadConfiguration = BluePrintLoadConfiguration().apply {
+ blueprintArchivePath = "./target/blueprints/archive"
+ blueprintWorkingPath = "./target/blueprints/work"
+ blueprintDeployPath = "./target/blueprints/deploy"
+ }
+ zipBlueprintFileName = normalizedPathName(bluePrintLoadConfiguration!!.blueprintArchivePath, "test.zip")
+
+ val archiveDir = normalizedFile(bluePrintLoadConfiguration!!.blueprintArchivePath).reCreateDirs()
+ assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}")
+
+ val blueprintFile = normalizedFile(blueprintDir)
+ testZipFile = blueprintFile.compress(zipBlueprintFileName!!)
+ assertNotNull(testZipFile, "test zip is null")
+ assertTrue(testZipFile!!.exists(), "Failed to create blueprint test zip(${testZipFile!!.absolutePath}")
+ }
+
+ @After
+ fun tearDown() {
+ deleteDir(bluePrintLoadConfiguration!!.blueprintArchivePath)
+ deleteDir(bluePrintLoadConfiguration!!.blueprintWorkingPath)
+ }
+
+ @Test
+ fun test01_saveBluePrint() {
+ bp = runBlocking {
+ val body = MultipartBodyBuilder().apply {
+ part("file", object : ByteArrayResource(testZipFile!!.readBytes()) {
+ override fun getFilename(): String {
+ return "test.zip"
+ }
+ })
+ }.build()
+
+ val saveBP = webTestClient
+ .post()
+ .uri("/api/v1/blueprint-model")
+ .body(BodyInserters.fromMultipartData(body))
+ .exchange()
+ .expectStatus().isOk
+ .returnResult<BlueprintModelSearch>()
+ .responseBody
+ .awaitSingle()
+
+ assertNotNull(saveBP, "failed to get response")
+ assertEquals("baseconfiguration", saveBP.artifactName, "mismatch artifact name")
+ assertEquals("1.0.0", saveBP.artifactVersion, "mismatch artifact version")
+ assertEquals("N", saveBP.published, "mismatch publish")
+ saveBP
+ }
+ }
+
+ @Test
+ @Throws(JSONException::class)
+ fun test02_getBluePrintByNameAndVersion() {
+ webTestClient(HttpMethod.GET, null,
+ "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+ HttpStatus.OK, false)
+ }
+
+
+ @Test
+ @Throws(JSONException::class)
+ fun test03_getBlueprintModel() {
+ webTestClient(HttpMethod.GET, null,
+ "/api/v1/blueprint-model/${bp!!.id}",
+ HttpStatus.OK, false)
+ }
+
+ @Test
+ @Throws(JSONException::class)
+ fun test04_getAllBlueprintModel() {
+ webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model", HttpStatus.OK, false)
+ }
+
+ @Test
+ @Throws(JSONException::class)
+ fun test05_downloadBluePrint() {
+ webTestClient(HttpMethod.GET, null,
+ "/api/v1/blueprint-model/download/${bp!!.id}",
+ HttpStatus.OK, false)
+ }
+
+ @Test
+ fun test06_enrichBlueprintModel() {
+ }
+
+ @Test
+ fun test07_publishBlueprintModel() {
+ }
+
+ @Test
+ @Throws(JSONException::class)
+ fun test08_searchBlueprintModels() {
+ webTestClient(HttpMethod.GET, null,
+ "/api/v1/blueprint-model/search/${bp!!.artifactName}",
+ HttpStatus.OK, false)
+ }
+
+ @Test
+ @Throws(JSONException::class)
+ fun test09_downloadBlueprintByNameAndVersion() {
+ webTestClient(HttpMethod.GET, null,
+ "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+ HttpStatus.OK, false)
+ }
+
+ @Test
+ fun test10_deleteBluePrint() {
+ webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}")
+ .header("Authorization", "Basic " + Base64Utils
+ .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
+ .exchange()
+ .expectStatus().is2xxSuccessful
+ }
+
+ @Throws(JSONException::class)
+ private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String,
+ expectedResponceStatus: HttpStatus, setParam: Boolean) {
+
+ log.info("Requesting($uri): Method(${requestMethod.name})")
+
+ webTestClient.method(requestMethod).uri(uri)
+ .header("Authorization", "Basic " + Base64Utils
+ .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
+ .body(body)
+ .exchange()
+ .expectStatus().isEqualTo(expectedResponceStatus)
+ .expectBody()
+ .returnResult().responseBody!!
+
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt
new file mode 100644
index 000000000..03e016b8e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/DesignerApiTestConfiguration.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints",
+ "org.onap.ccsdk.cds.blueprintsprocessor"])
+@EnableAutoConfiguration
+open class DesignerApiTestConfiguration
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt
new file mode 100644
index 000000000..6fe7097e5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ModelTypeControllerTest.kt
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeControllerTest {
+
+ private val log = LoggerFactory.getLogger(ModelTypeControllerTest::class.java)!!
+
+ @Autowired
+ internal var modelTypeController: ModelTypeController? = null
+
+ private var modelName = "test-datatype"
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test01SaveModelType() {
+ log.info("**************** test01SaveModelType ********************")
+
+ val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json")
+ var modelType = ModelType()
+ modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
+ modelType.description = "Definition for Sample Datatype "
+ modelType.definition = JacksonUtils.jsonNode(content)
+ modelType.modelName = modelName
+ modelType.version = "1.0.0"
+ modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ modelType.updatedBy = "xxxxxx@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ log.info("Saved Mode {}", modelType.toString())
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
+
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelType.modelName)
+ Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType)
+
+ // Model Update
+ modelType.updatedBy = "bs2796@xxx.com"
+ modelType = modelTypeController!!.saveModelType(modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test02SearchModelTypes() {
+ log.info("*********************** test02SearchModelTypes ***************************")
+
+ val tags = "test-datatype"
+
+ val dbModelTypes = modelTypeController!!.searchModelTypes(tags)
+ Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
+ Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.isNotEmpty())
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test03GetModelType() {
+ log.info("************************* test03GetModelType *********************************")
+ val dbModelType = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName $modelName", dbModelType)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName)
+
+ val dbDatatypeModelTypes = modelTypeController!!.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes)
+ Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.isNotEmpty())
+ }
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test04DeleteModelType() {
+ log.info(
+ "************************ test03DeleteModelType ***********************")
+ val dbResourceMapping = modelTypeController!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
+
+ modelTypeController!!.deleteModelTypeByName(dbResourceMapping.modelName)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt
new file mode 100644
index 000000000..893622308
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/ResourceDictionaryControllerTest.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api
+
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ResourceDictionaryControllerTest {
+
+ @Autowired
+ lateinit var resourceDictionaryController: ResourceDictionaryController
+
+ @Test
+ fun testResourceDictionaryControllerPresence() {
+ assertNotNull(resourceDictionaryController, "failed to initialise ResourceDictionaryController")
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
new file mode 100644
index 000000000..974a3b9b7
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/enhancer/BluePrintEnhancerServiceImplTest.kt
@@ -0,0 +1,126 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.enhancer
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.ModelTypeLoadService
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.load.ResourceDictionaryLoadService
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
+import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintEnhancerServiceImplTest {
+
+ @Autowired
+ lateinit var modelTypeLoadService: ModelTypeLoadService
+
+ @Autowired
+ lateinit var resourceDictionaryLoadService: ResourceDictionaryLoadService
+
+ @Autowired
+ lateinit var bluePrintEnhancerService: BluePrintEnhancerService
+
+ @Autowired
+ lateinit var bluePrintValidatorService: BluePrintValidatorService
+
+
+ @Test
+ @Throws(Exception::class)
+ fun testEnhancementAndValidation() {
+
+ runBlocking {
+ modelTypeLoadService.loadPathModelType("./../../../../../components/model-catalog/definition-type/starter-type")
+
+ val dictPaths: MutableList<String> = arrayListOf()
+ dictPaths.add("./../../../../../components/model-catalog/resource-dictionary/starter-dictionary")
+ dictPaths.add("./../../../../../components/model-catalog/resource-dictionary/test-dictionary")
+ resourceDictionaryLoadService.loadPathsResourceDictionary(dictPaths)
+
+ testBaseConfigEnhancementAndValidation()
+ testVFWEnhancementAndValidation()
+ testGoldenEnhancementAndValidation()
+ testRemoteScriptsEnhancementAndValidation()
+ testCapabilityCliEnhancementAndValidation()
+ }
+ }
+
+ fun testBaseConfigEnhancementAndValidation() {
+ val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ testComponentInvokeEnhancementAndValidation(basePath, "base-enhance")
+ }
+
+ fun testVFWEnhancementAndValidation() {
+ val basePath = "./../../../../../components/model-catalog/blueprint-model/service-blueprint/vFW"
+ testComponentInvokeEnhancementAndValidation(basePath, "vFW-enhance")
+ }
+
+ fun testGoldenEnhancementAndValidation() {
+ val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/golden"
+ testComponentInvokeEnhancementAndValidation(basePath, "golden-enhance")
+ }
+
+ fun testRemoteScriptsEnhancementAndValidation() {
+ val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/remote_scripts"
+ testComponentInvokeEnhancementAndValidation(basePath, "remote_scripts-enhance")
+
+ }
+
+ fun testCapabilityCliEnhancementAndValidation() {
+ val basePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/capability_cli"
+ testComponentInvokeEnhancementAndValidation(basePath, "capability_cli-enhance")
+ }
+
+ private fun testComponentInvokeEnhancementAndValidation(basePath: String, targetDirName: String) {
+ runBlocking {
+ val targetPath = normalizedPathName("target/blueprints/enrichment", targetDirName)
+
+ deleteDir(targetPath)
+
+ val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath)
+ Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
+
+ // Validate the Generated BluePrints
+ val valid = bluePrintValidatorService.validateBluePrints(targetPath)
+ Assert.assertTrue("blueprint($basePath) validation failed ", valid)
+
+ // Enable this to get the enhanced zip file
+// val compressFile = normalizedFile("target/blueprints/enrichment", "$targetDirName.zip")
+// normalizedFile(targetPath).compress(compressFile)
+
+ deleteDir(targetPath)
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt
new file mode 100644
index 000000000..00e78d247
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/ModelTypeServiceTest.kt
@@ -0,0 +1,138 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.handler
+
+import kotlinx.coroutines.runBlocking
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeServiceTest {
+ @Autowired
+ private val modelTypeHandler: ModelTypeHandler? = null
+
+ internal var modelName = "test-datatype"
+
+ private val log = LoggerFactory.getLogger(ModelTypeServiceTest::class.java)
+
+ @Test
+ @Commit
+ @Throws(Exception::class)
+ fun test01SaveModelType() {
+ runBlocking {
+ log.info("**************** test01SaveModelType ********************")
+
+ val content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json")
+ var modelType = ModelType()
+ modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
+ modelType.description = "Definition for Sample Datatype "
+ modelType.definition = JacksonUtils.jsonNode(content)
+ modelType.modelName = modelName
+ modelType.version = "1.0.0"
+ modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ modelType.updatedBy = "xxxxxx@xxx.com"
+ modelType = modelTypeHandler!!.saveModel(modelType)
+ log.info("Saved Mode {}", modelType.toString())
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.modelName)
+
+ val dbModelType = modelTypeHandler.getModelTypeByName(modelType.modelName)
+ Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType!!.modelName + ")",
+ dbModelType)
+
+ // Model Update
+ modelType.updatedBy = "bs2796@xxx.com"
+ modelType = modelTypeHandler.saveModel(modelType)
+ Assert.assertNotNull("Failed to get Saved ModelType", modelType)
+ Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.updatedBy)
+ }
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test02SearchModelTypes() {
+ runBlocking {
+ log.info("*********************** test02SearchModelTypes ***************************")
+
+ val tags = "test-datatype"
+
+ val dbModelTypes = modelTypeHandler!!.searchModelTypes(tags)
+ Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes)
+ Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size > 0)
+ }
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test03GetModelType() {
+ runBlocking {
+ log.info("************************* test03GetModelType *********************************")
+ val dbModelType = modelTypeHandler!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType!!.modelName)
+
+ val dbDatatypeModelTypes = modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes)
+ Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size > 0)
+
+ val dbModelTypeByDerivedFroms = modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)
+ Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms)
+ Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size > 0)
+ }
+
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun test04DeleteModelType() {
+ runBlocking {
+ log.info(
+ "************************ test03DeleteModelType ***********************")
+ val dbResourceMapping = modelTypeHandler!!.getModelTypeByName(modelName)
+ Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping)
+ Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping!!.modelName)
+
+ modelTypeHandler.deleteByModelName(dbResourceMapping.modelName)
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt
new file mode 100644
index 000000000..3165a6e2f
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/mock/MockFilePart.kt
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.mock
+
+import org.apache.commons.io.FilenameUtils
+import org.slf4j.LoggerFactory
+import org.springframework.core.io.buffer.DataBuffer
+import org.springframework.http.HttpHeaders
+import org.springframework.http.codec.multipart.FilePart
+import org.springframework.util.FileCopyUtils
+import reactor.core.publisher.Flux
+import reactor.core.publisher.Mono
+import java.io.File
+import java.nio.file.Path
+
+class MockFilePart(private val fileName: String) : FilePart {
+ val log = LoggerFactory.getLogger(MockFilePart::class.java)!!
+ override fun content(): Flux<DataBuffer> {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun headers(): HttpHeaders {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun filename(): String {
+ return FilenameUtils.getName(fileName)
+ }
+
+ override fun name(): String {
+ return FilenameUtils.getBaseName(fileName)
+ }
+
+ override fun transferTo(path: Path): Mono<Void> {
+ log.info("Copying file($fileName to ${path}")
+ FileCopyUtils.copy(File(fileName), path.toFile())
+ return Mono.empty()
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt
new file mode 100644
index 000000000..55bc1e4af
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ModelTypeReactRepositoryTest.kt
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.repository
+
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import java.nio.charset.Charset
+import java.util.*
+
+/**
+ * ModelTypeReactRepositoryTest.
+ *
+ * @author Brinda Santh
+ */
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeReactRepositoryTest {
+
+ @Autowired
+ private val modelTypeReactRepository: ModelTypeReactRepository? = null
+
+ internal var modelName = "test-datatype"
+
+ @Test
+ @Commit
+ fun test01Save() {
+ val content = normalizedFile("./src/test/resources/model_type/data_type/datatype-property.json")
+ .readText(Charset.defaultCharset())
+ val modelType = ModelType()
+ modelType.definitionType = BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE
+ modelType.derivedFrom = BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT
+ modelType.description = "Definition for Sample Datatype "
+ modelType.definition = JacksonUtils.jsonNode(content)
+ modelType.modelName = modelName
+ modelType.version = "1.0.0"
+ modelType.tags = ("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
+ modelType.updatedBy = "xxxxxx@xxx.com"
+
+ val dbModelType = modelTypeReactRepository!!.save(modelType).block()
+ Assert.assertNotNull("Failed to get Saved ModelType", dbModelType)
+ }
+
+ @Test
+ fun test02Finds() {
+ val dbFindByModelName = modelTypeReactRepository!!.findByModelName(modelName).block()
+ Assert.assertNotNull("Failed to findByModelName ", dbFindByModelName)
+
+ val dbFindByDefinitionType = modelTypeReactRepository.findByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE).collectList().block()
+ Assert.assertNotNull("Failed to findByDefinitionType ", dbFindByDefinitionType)
+ Assert.assertTrue("Failed to findByDefinitionType count", dbFindByDefinitionType!!.size > 0)
+
+ val dbFindByDerivedFrom = modelTypeReactRepository.findByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT).collectList().block()
+ Assert.assertNotNull("Failed to find findByDerivedFrom", dbFindByDerivedFrom)
+ Assert.assertTrue("Failed to find findByDerivedFrom by count", dbFindByDerivedFrom!!.size > 0)
+
+ val dbFindByModelNameIn = modelTypeReactRepository.findByModelNameIn(Arrays.asList(modelName)).collectList().block()
+ Assert.assertNotNull("Failed to findByModelNameIn ", dbFindByModelNameIn)
+ Assert.assertTrue("Failed to findByModelNameIn by count", dbFindByModelNameIn!!.size > 0)
+
+ val dbFindByDefinitionTypeIn = modelTypeReactRepository.findByDefinitionTypeIn(Arrays.asList(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)).collectList().block()
+ Assert.assertNotNull("Failed to findByDefinitionTypeIn", dbFindByDefinitionTypeIn)
+ Assert.assertTrue("Failed to findByDefinitionTypeIn by count", dbFindByDefinitionTypeIn!!.size > 0)
+
+ val dbFindByDerivedFromIn = modelTypeReactRepository.findByDerivedFromIn(Arrays.asList(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT)).collectList().block()
+ Assert.assertNotNull("Failed to find findByDerivedFromIn", dbFindByDerivedFromIn)
+ Assert.assertTrue("Failed to find findByDerivedFromIn by count", dbFindByDerivedFromIn!!.size > 0)
+ }
+
+ @Test
+ @Commit
+ fun test03Delete() {
+ modelTypeReactRepository!!.deleteByModelName(modelName).block()
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt
new file mode 100644
index 000000000..70e1b8ed2
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/repository/ResourceDictionaryRepositoryTest.kt
@@ -0,0 +1,99 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.repository
+
+import org.junit.Assert
+import org.junit.FixMethodOrder
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.MethodSorters
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.DesignerApiTestConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ResourceDictionary
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.transaction.annotation.Transactional
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [DesignerApiTestConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ResourceDictionaryReactRepositoryTest {
+
+ private val sourceName = "test-source"
+
+ @Autowired
+ lateinit var resourceDictionaryRepository: ResourceDictionaryRepository
+
+ @Test
+ @Commit
+ fun test01Save() {
+ val resourceDefinition = JacksonUtils
+ .readValueFromFile("./../../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json",
+ ResourceDefinition::class.java)
+ Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition)
+ resourceDefinition!!.name = sourceName
+
+ val resourceDictionary = transformResourceDictionary(resourceDefinition)
+ val dbResourceDictionary = resourceDictionaryRepository.save(resourceDictionary)
+ Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary)
+ }
+
+ @Test
+ fun test02FindByNameReact() {
+ val dbResourceDictionary = resourceDictionaryRepository.findByName(sourceName)
+ Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary)
+ }
+
+ @Test
+ fun test03FindByNameInReact() {
+ val dbResourceDictionaries = resourceDictionaryRepository.findByNameIn(arrayListOf(sourceName))
+ Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries)
+ }
+
+ @Test
+ fun test04FindByTagsContainingIgnoreCaseReact() {
+ val dbTagsResourceDictionaries = resourceDictionaryRepository.findByTagsContainingIgnoreCase(sourceName)
+ Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries)
+ }
+
+ @Test
+ @Transactional
+ @Commit
+ fun test05Delete() {
+ resourceDictionaryRepository.deleteByName(sourceName)
+ }
+
+ private fun transformResourceDictionary(resourceDefinition: ResourceDefinition): ResourceDictionary {
+ val resourceDictionary = ResourceDictionary()
+ resourceDictionary.name = resourceDefinition.name
+ resourceDictionary.dataType = resourceDefinition.property.type
+ resourceDictionary.description = resourceDefinition.property.description!!
+ resourceDictionary.tags = resourceDefinition.tags!!
+ resourceDictionary.updatedBy = resourceDefinition.updatedBy
+ resourceDictionary.definition = resourceDefinition
+ return resourceDictionary
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt
new file mode 100644
index 000000000..e34238eb9
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2019 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.cds.blueprintsprocessor.designer.api.utils
+
+import kotlinx.coroutines.runBlocking
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.mock.MockFilePart
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import java.nio.file.Paths
+import java.util.*
+import kotlin.test.assertTrue
+
+class BluePrintEnhancerUtilsTest {
+
+ private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ private val blueprintArchivePath: String = "./target/blueprints/archive"
+ private val blueprintEnrichmentPath: String = "./target/blueprints/enrichment"
+ private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip")
+
+ @Before
+ fun setUp() {
+ val archiveDir = normalizedFile(blueprintArchivePath).reCreateDirs()
+ assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}")
+ val enhancerDir = normalizedFile(blueprintEnrichmentPath).reCreateDirs()
+ assertTrue(enhancerDir.exists(), "failed to create enhancerDir(${enhancerDir.absolutePath}")
+ val blueprintFile = Paths.get(blueprintDir).toFile().normalize()
+ val testZipFile = blueprintFile.compress(zipBlueprintFileName)
+ assertTrue(testZipFile.exists(), "Failed to create blueprint test zip(${testZipFile.absolutePath}")
+ }
+
+ @After
+ fun tearDown() {
+ deleteDir(blueprintArchivePath)
+ deleteDir(blueprintEnrichmentPath)
+ }
+
+ @Test
+ fun testFilePartCompressionNDeCompression() {
+ val filePart = MockFilePart(zipBlueprintFileName)
+
+ runBlocking {
+ val enhanceId = UUID.randomUUID().toString()
+ val blueprintArchiveLocation = normalizedPathName(blueprintArchivePath, enhanceId)
+ val blueprintEnrichmentLocation = normalizedPathName(blueprintEnrichmentPath, enhanceId)
+ BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchiveLocation, blueprintEnrichmentLocation)
+ BluePrintEnhancerUtils.compressToFilePart(blueprintEnrichmentLocation, blueprintArchiveLocation)
+ }
+ }
+}
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidatorTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidatorTest.kt
new file mode 100644
index 000000000..3c263b349
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/ModelTypeValidatorTest.kt
@@ -0,0 +1,39 @@
+/*
+ * 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.cds.blueprintsprocessor.designer.api.utils
+
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.domain.ModelType
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+class ModelTypeValidatorTest {
+
+ @Test(expected = IllegalStateException::class)
+ @Throws(Exception::class)
+ fun testvalidateModelType() {
+ val modelType = ModelType()
+ modelType.definitionType = ""
+ modelType.derivedFrom = ""
+ modelType.description = ""
+ modelType.definition = JacksonUtils.objectMapper.createObjectNode()
+ modelType.modelName = ""
+ modelType.version = ""
+ modelType.tags = ""
+ modelType.updatedBy = ""
+ ModelTypeValidator.validateModelType(modelType)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties
new file mode 100755
index 000000000..e22e522ee
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/application-test.properties
@@ -0,0 +1,41 @@
+#
+# Copyright © 2019 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.
+#
+
+spring.main.banner-mode=off
+spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
+logging.level.org.springframework.web=INFO
+logging.level.org.hibernate.SQL=warn
+logging.level.org.hibernate.type.descriptor.sql=debug
+
+blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.username=sa
+blueprintsprocessor.db.password=
+blueprintsprocessor.db.driverClassName=org.h2.Driver
+blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.hibernateDDLAuto=update
+blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect
+
+# Load Resource Source Mappings
+resourceSourceMappings=processor-db=source-db,input=source-input,default=source-default,sdnc=source-rest,aai-data=source-rest,capability=source-capability
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-resource-assignment.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-resource-assignment.json
new file mode 100644
index 000000000..fdf76ab44
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-resource-assignment.json
@@ -0,0 +1,62 @@
+[
+ {
+ "name": "rs-db-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-db-source",
+ "dictionary-source": "processor-db",
+ "dependencies": [
+ "input-source"
+ ]
+ },
+ {
+ "name": "ra-default-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-default-source",
+ "dictionary-source": "default",
+ "dependencies": []
+ },
+ {
+ "name": "ra-input-source",
+ "input-param": true,
+ "property": {
+ "type": "string",
+ "required": true
+ },
+ "dictionary-name": "sample-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-list-input-source",
+ "input-param": true,
+ "property": {
+ "type": "list",
+ "required": true,
+ "entry_schema": {
+ "type": "string"
+ }
+ },
+ "dictionary-name": "ra-list-input-source",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "ra-complex-input-source",
+ "input-param": true,
+ "property": {
+ "type": "dt-v4-aggregate",
+ "required": true
+ },
+ "dictionary-name": "sample-mdsal-source",
+ "dictionary-source": "sdnc",
+ "dependencies": []
+ }
+]
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-template.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-template.json
new file mode 100644
index 000000000..3692b7dcd
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhance-template.json
@@ -0,0 +1,351 @@
+{
+ "metadata": {
+ "template_author": "Brinda Santh",
+ "template_name": "enhance-template",
+ "template_version": "1.0.0",
+ "template_tags": "brinda, VPE",
+ "service-type": "Sample Service",
+ "release": "1806",
+ "vnf-type": "VPE"
+ },
+ "topology_template": {
+ "inputs": {
+ "request-id": {
+ "required": true,
+ "type": "string"
+ },
+ "service-instance-id": {
+ "required": true,
+ "type": "string"
+ },
+ "scope-type": {
+ "required": true,
+ "type": "string"
+ },
+ "action-name": {
+ "required": true,
+ "type": "string"
+ },
+ "hostname": {
+ "required": true,
+ "type": "string"
+ }
+ },
+ "node_templates": {
+ "vpe-netconf-device": {
+ "capabilities": {
+ "netconf": {
+ "properties": {
+ "login-key": "sdnc",
+ "login-account": "sndc-local",
+ "source": "local",
+ "target-ip-address": {
+ "get_attribute": [
+ "SELF",
+ "lo0-local-ipv4-address"
+ ]
+ },
+ "port-number": 22,
+ "connection-time-out": 30
+ }
+ }
+ },
+ "type": "vnf-netconf-device"
+ },
+ "activate-netconf-component": {
+ "capabilities": {
+ "component-node": {}
+ },
+ "requirements": {
+ "netconf-connection": {
+ "capability": "netconf",
+ "node": "vpe-netconf-device",
+ "relationship": "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces": {
+ "NetconfExecutorComponent": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "action-name": {
+ "get_input": "action-name"
+ },
+ "template-name": {
+ "get_input": "template_name"
+ },
+ "template-version": {
+ "get_input": "template_version"
+ },
+ "resource-type": "vnf-type",
+ "request-id": {
+ "get_input": "request-id"
+ },
+ "resource-id": {
+ "get_input": "hostname"
+ },
+ "execution-script": "execution-script"
+ },
+ "outputs": {
+ "response-data": {
+ "get_attribute": [
+ "SELF",
+ "netconf-executor-baseconfig.response-data"
+ ]
+ },
+ "status": {
+ "get_attribute": [
+ "SELF",
+ "netconf-executor-baseconfig.status"
+ ]
+ }
+ },
+ "implementation": {
+ "primary": "file://netconf_adaptor/DefaultBaseLicenceConfig.py"
+ }
+ }
+ }
+ }
+ },
+ "type": "component-netconf-executor"
+ },
+ "resource-assignment-ra-component": {
+ "capabilities": {
+ "component-node": {}
+ },
+ "interfaces": {
+ "ResourceAssignmentComponent": {
+ "operations": {
+ "process": {
+ "inputs": {
+ "template-names": [
+ "base-config-template",
+ "licence-template"
+ ],
+ "action-name": {
+ "get_input": "action-name"
+ },
+ "template-name": {
+ "get_input": "template_name"
+ },
+ "template-version": {
+ "get_input": "template-version"
+ },
+ "resource-type": "vnf-type",
+ "request-id": {
+ "get_input": "request-id"
+ },
+ "resource-id": {
+ "get_input": "hostname"
+ }
+ },
+ "outputs": {
+ "resource-assignment-params": "success",
+ "status": "status"
+ }
+ }
+ }
+ }
+ },
+ "type": "component-resource-assignment"
+ },
+ "resource-assignment-action": {
+ "properties": {
+ "mode": "sync",
+ "version": "LATEST",
+ "is-start-flow": false
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "resource-assignment-ra-component",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "capabilities": {
+ "dg-node": {}
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ResourceAssignment": {
+ "inputs": {
+ "params": []
+ }
+ }
+ }
+ }
+ },
+ "type": "dg-resource-assignment"
+ },
+ "activate-action": {
+ "properties": {
+ "mode": "sync",
+ "version": "LATEST",
+ "is-start-flow": false
+ },
+ "requirements": {
+ "component-dependency": {
+ "capability": "component-node",
+ "node": "activate-netconf-component",
+ "relationship": "tosca.relationships.DependsOn"
+ }
+ },
+ "capabilities": {
+ "dg-node": {}
+ },
+ "interfaces": {
+ "CONFIG": {
+ "operations": {
+ "ActivateNetconf": {
+ "inputs": {
+ "params": []
+ }
+ }
+ }
+ }
+ },
+ "type": "dg-activate-netconf"
+ },
+ "base-config-template": {
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": "db://base-config-template"
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": [
+ {
+ "name": "rs-db-source",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "input-param": false,
+ "dictionary-name": "sample-db-source",
+ "dictionary-source": "processor-db",
+ "dependencies": [
+ "hostname"
+ ],
+ "version": 0
+ },
+ {
+ "name": "mdsal-source",
+ "property": {
+ "description": "",
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-v4-aggregate"
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "sample-mdsal-source",
+ "dictionary-source": "sdnc",
+ "dependencies": [
+ "service-instance-id"
+ ],
+ "version": 0
+ },
+ {
+ "name": "hostname",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "hostname",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ },
+ {
+ "name": "service",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ },
+ {
+ "name": "service-instance-id",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ }
+ ]
+ }
+ }
+ },
+ "properties": {
+ "action-names": [
+ "resource-assignment-action"
+ ]
+ },
+ "type": "artifact-config-template"
+ },
+ "licence-template": {
+ "capabilities": {
+ "content": {
+ "properties": {
+ "content": "db://licence-template"
+ }
+ },
+ "mapping": {
+ "properties": {
+ "mapping": [
+ {
+ "name": "licenses",
+ "property": {
+ "required": true,
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-license-key"
+ }
+ },
+ "input-param": false,
+ "dictionary-name": "sample-licenses",
+ "dictionary-source": "sdnc",
+ "dependencies": [
+ "service-instance-id"
+ ],
+ "version": 0
+ },
+ {
+ "name": "service-instance-id",
+ "property": {
+ "required": true,
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "version": 0,
+ "input-param": false
+ }
+ ]
+ }
+ }
+ },
+ "properties": {
+ "action-names": [
+ "resource-assignment-action"
+ ]
+ },
+ "type": "artifact-config-template"
+ }
+ }
+ },
+ "node_types": {
+ },
+ "data_types": {
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhanced-template.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhanced-template.json
new file mode 100644
index 000000000..d71293259
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/enhance/enhanced-template.json
@@ -0,0 +1,327 @@
+{
+ "metadata" : {
+ "template_author" : "Brinda Santh",
+ "template_name" : "enhance-template",
+ "template_version" : "1.0.0",
+ "template_tags" : "brinda, VPE",
+ "service-type" : "Sample Service",
+ "release" : "1806",
+ "vnf-type" : "VPE"
+ },
+ "tosca_definitions_version" : "controller_blueprint_1_0_0",
+ "artifact_types" : { },
+ "data_types" : {
+ },
+ "node_types" : {
+ },
+ "topology_template" : {
+ "inputs" : {
+ "request-id" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "service-instance-id" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "scope-type" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "action-name" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "hostname" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "resource-assignment-request" : {
+ "description" : "This is Dynamic Data type for the receipe resource-assignment-action.",
+ "required" : false,
+ "type" : "dt-resource-assignment-request"
+ }
+ },
+ "node_templates" : {
+ "vpe-netconf-device" : {
+ "type" : "vnf-netconf-device",
+ "capabilities" : {
+ "netconf" : {
+ "properties" : {
+ "login-key" : "sdnc",
+ "login-account" : "sndc-local",
+ "source" : "local",
+ "target-ip-address" : {
+ "get_attribute" : [ "SELF", "lo0-local-ipv4-address" ]
+ },
+ "port-number" : 22,
+ "connection-time-out" : 30
+ }
+ }
+ }
+ },
+ "activate-netconf-component" : {
+ "type" : "component-netconf-executor",
+ "capabilities" : {
+ "component-node" : { }
+ },
+ "requirements" : {
+ "netconf-connection" : {
+ "capability" : "netconf",
+ "node" : "vpe-netconf-device",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "NetconfExecutorComponent" : {
+ "operations" : {
+ "process" : {
+ "implementation" : {
+ "primary" : "file://netconf_adaptor/DefaultBaseLicenceConfig.py"
+ },
+ "inputs" : {
+ "action-name" : {
+ "get_input" : "action-name"
+ },
+ "template-name" : {
+ "get_input" : "template_name"
+ },
+ "template-version" : {
+ "get_input" : "template_version"
+ },
+ "resource-type" : "vnf-type",
+ "request-id" : {
+ "get_input" : "request-id"
+ },
+ "resource-id" : {
+ "get_input" : "hostname"
+ },
+ "execution-script" : "execution-script"
+ },
+ "outputs" : {
+ "response-data" : {
+ "get_attribute" : [ "SELF", "netconf-executor-baseconfig.response-data" ]
+ },
+ "status" : {
+ "get_attribute" : [ "SELF", "netconf-executor-baseconfig.status" ]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "resource-assignment-ra-component" : {
+ "type" : "component-resource-assignment",
+ "capabilities" : {
+ "component-node" : { }
+ },
+ "interfaces" : {
+ "ResourceAssignmentComponent" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "template-names" : [ "base-config-template", "licence-template" ],
+ "action-name" : {
+ "get_input" : "action-name"
+ },
+ "template-name" : {
+ "get_input" : "template_name"
+ },
+ "template-version" : {
+ "get_input" : "template-version"
+ },
+ "resource-type" : "vnf-type",
+ "request-id" : {
+ "get_input" : "request-id"
+ },
+ "resource-id" : {
+ "get_input" : "hostname"
+ }
+ },
+ "outputs" : {
+ "resource-assignment-params" : "success",
+ "status" : "status"
+ }
+ }
+ }
+ }
+ }
+ },
+ "resource-assignment-action" : {
+ "type" : "dg-resource-assignment",
+ "properties" : {
+ "mode" : "sync",
+ "version" : "LATEST",
+ "is-start-flow" : false
+ },
+ "capabilities" : {
+ "dg-node" : { }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "resource-assignment-ra-component",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ResourceAssignment" : {
+ "inputs" : {
+ "params" : [ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "activate-action" : {
+ "type" : "dg-activate-netconf",
+ "properties" : {
+ "mode" : "sync",
+ "version" : "LATEST",
+ "is-start-flow" : false
+ },
+ "capabilities" : {
+ "dg-node" : { }
+ },
+ "requirements" : {
+ "component-dependency" : {
+ "capability" : "component-node",
+ "node" : "activate-netconf-component",
+ "relationship" : "tosca.relationships.DependsOn"
+ }
+ },
+ "interfaces" : {
+ "CONFIG" : {
+ "operations" : {
+ "ActivateNetconf" : {
+ "inputs" : {
+ "params" : [ ]
+ }
+ }
+ }
+ }
+ }
+ },
+ "base-config-template" : {
+ "type" : "artifact-config-template",
+ "properties" : {
+ "action-names" : [ "resource-assignment-action" ]
+ },
+ "capabilities" : {
+ "content" : {
+ "properties" : {
+ "content" : "db://base-config-template"
+ }
+ },
+ "mapping" : {
+ "properties" : {
+ "mapping" : [ {
+ "name" : "rs-db-source",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "input-param" : false,
+ "dictionary-name" : "sample-db-source",
+ "dictionary-source" : "processor-db",
+ "dependencies" : [ "hostname" ],
+ "version" : 0
+ }, {
+ "name" : "mdsal-source",
+ "property" : {
+ "description" : "",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "dt-v4-aggregate"
+ }
+ },
+ "input-param" : false,
+ "dictionary-name" : "sample-mdsal-source",
+ "dictionary-source" : "sdnc",
+ "dependencies" : [ "service-instance-id" ],
+ "version" : 0
+ }, {
+ "name" : "hostname",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "hostname",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ }, {
+ "name" : "service",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ }, {
+ "name" : "service-instance-id",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service-instance-id",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ } ]
+ }
+ }
+ }
+ },
+ "licence-template" : {
+ "type" : "artifact-config-template",
+ "properties" : {
+ "action-names" : [ "resource-assignment-action" ]
+ },
+ "capabilities" : {
+ "content" : {
+ "properties" : {
+ "content" : "db://licence-template"
+ }
+ },
+ "mapping" : {
+ "properties" : {
+ "mapping" : [ {
+ "name" : "licenses",
+ "property" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "dt-license-key"
+ }
+ },
+ "input-param" : false,
+ "dictionary-name" : "sample-licenses",
+ "dictionary-source" : "sdnc",
+ "dependencies" : [ "service-instance-id" ],
+ "version" : 0
+ }, {
+ "name" : "service-instance-id",
+ "property" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dictionary-name" : "service-instance-id",
+ "dictionary-source" : "input",
+ "version" : 0,
+ "input-param" : false
+ } ]
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml
new file mode 100644
index 000000000..feb4514d6
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/logback-test.xml
@@ -0,0 +1,39 @@
+<!--
+ ~ Copyright © 2018 IBM.
+ ~ Modifications 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.
+ -->
+
+<configuration>
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.springframework.web" level="warn"/>
+ <logger name="org.hibernate" level="error"/>
+ <logger name="org.onap.ccsdk.cds.controllerblueprints.core" level="warn"/>
+ <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/model_type/data_type/datatype-property.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/model_type/data_type/datatype-property.json
new file mode 100644
index 000000000..d3ecffd17
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/model_type/data_type/datatype-property.json
@@ -0,0 +1,27 @@
+{
+ "version": "1.0.0",
+ "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs",
+ "properties": {
+ "type": {
+ "required": true,
+ "type": "string"
+ },
+ "description": {
+ "required": false,
+ "type": "string"
+ },
+ "required": {
+ "required": false,
+ "type": "boolean"
+ },
+ "default": {
+ "required": false,
+ "type": "string"
+ },
+ "entry_schema": {
+ "required": false,
+ "type": "string"
+ }
+ },
+ "derived_from": "tosca.datatypes.Root"
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/automap.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/automap.json
new file mode 100644
index 000000000..820c59804
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/automap.json
@@ -0,0 +1,14 @@
+[
+ {
+ "name": "sample-input-source"
+ },
+ {
+ "name": "sample-default-source"
+ },
+ {
+ "name": "sample-db-source"
+ },
+ {
+ "name": "sample-mdsal-source"
+ }
+] \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/default_definition.json b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/default_definition.json
new file mode 100644
index 000000000..d2fa29918
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/resources/resourcedictionary/default_definition.json
@@ -0,0 +1,17 @@
+{
+ "name": "ipaddress",
+ "property": {
+ "description": "name of the ",
+ "type": "list",
+ "entry_schema": {
+ "type": "dt-v4-aggregate"
+ }
+ },
+ "updated-by": "Brinda Santh (bs2796)",
+ "tags": "ipaddress",
+ "sources": {
+ "input": {
+ "type": "source-input"
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index a892f205f..8afecab3c 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -85,5 +85,11 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
index 53c1e975b..cf8c61ac7 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml
@@ -36,22 +36,5 @@
<groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
<artifactId>blueprint-core</artifactId>
</dependency>
- <!--dependency>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <artifactId>db-resources</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <artifactId>blueprint-validation</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <artifactId>blueprint-scripts</artifactId>
- </dependency-->
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index cfa2d6fea..2c241cc4f 100755
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -55,11 +55,6 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
<!-- For Message libraries -->
<dependency>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
index 81f3ec309..451f827b6 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
@@ -24,7 +24,7 @@ import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.currentTimestamp
import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
import org.onap.ccsdk.cds.controllerblueprints.common.api.Status
-import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
@@ -40,7 +40,7 @@ import java.io.File
import java.util.*
@Service
-open class BluePrintManagementGRPCHandler(private val bluePrintPathConfiguration: BluePrintPathConfiguration,
+open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
private val blueprintsProcessorCatalogService: BluePrintCatalogService)
: BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
@@ -54,7 +54,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintPathConfiguration
log.info("request(${request.commonHeader.requestId})")
val uploadId = UUID.randomUUID().toString()
try {
- val cbaFile = normalizedFile(bluePrintPathConfiguration.blueprintArchivePath, uploadId, "cba-zip")
+ val cbaFile = normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, uploadId, "cba-zip")
saveToDisk(request, cbaFile)
@@ -64,8 +64,8 @@ open class BluePrintManagementGRPCHandler(private val bluePrintPathConfiguration
} catch (e: Exception) {
responseObserver.onError(failStatus("request(${request.commonHeader.requestId}): Failed to upload CBA", e))
} finally {
- deleteDir(bluePrintPathConfiguration.blueprintArchivePath, uploadId)
- deleteDir(bluePrintPathConfiguration.blueprintWorkingPath, uploadId)
+ deleteDir(bluePrintLoadConfiguration.blueprintArchivePath, uploadId)
+ deleteDir(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId)
}
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index a81d35eac..9dd04bf95 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -26,7 +26,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.*
-import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
@@ -42,7 +42,7 @@ import java.util.*
import java.util.stream.Collectors
@Service
-class ExecutionServiceHandler(private val bluePrintPathConfiguration: BluePrintPathConfiguration,
+class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
private val blueprintsProcessorCatalogService: BluePrintCatalogService,
private val bluePrintWorkflowExecutionService
: BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>) {
@@ -51,8 +51,8 @@ class ExecutionServiceHandler(private val bluePrintPathConfiguration: BluePrintP
suspend fun upload(filePart: FilePart): String {
val saveId = UUID.randomUUID().toString()
- val blueprintArchive = normalizedPathName(bluePrintPathConfiguration.blueprintArchivePath, saveId)
- val blueprintWorking = normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath, saveId)
+ val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId)
+ val blueprintWorking = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, saveId)
try {
val compressedFile = normalizedFile(blueprintArchive, "cba.zip")
@@ -67,7 +67,7 @@ class ExecutionServiceHandler(private val bluePrintPathConfiguration: BluePrintP
} finally {
// Clean blueprint script cache
val cacheKey = BluePrintFileUtils
- .compileCacheKey(normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath,saveId))
+ .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath,saveId))
BluePrintCompileCache.cleanClassLoader(cacheKey)
deleteNBDir(blueprintArchive)
deleteNBDir(blueprintWorking)
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
index 65b41262b..d9e352bff 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
@@ -56,7 +56,7 @@ import kotlin.test.assertTrue
class ExecutionServiceHandlerTest {
@Autowired
- lateinit var blueprintCatalog: BluePrintCatalogService
+ lateinit var blueprintsProcessorCatalogService: BluePrintCatalogService
@Autowired
lateinit var webTestClient: WebTestClient
@@ -98,7 +98,7 @@ class ExecutionServiceHandlerTest {
@Test
fun `test rest process`() {
runBlocking {
- blueprintCatalog.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
+ blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
val executionServiceInput = JacksonUtils
.readValueFromClassPathFile("execution-input/default-input.json",
@@ -116,7 +116,7 @@ class ExecutionServiceHandlerTest {
@Test
fun `rest resource process should return status code 500 in case of server-side exception`() {
runBlocking {
- blueprintCatalog.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
+ blueprintsProcessorCatalogService.saveToDatabase(UUID.randomUUID().toString(), loadTestCbaFile())
val executionServiceInput = JacksonUtils
.readValueFromClassPathFile("execution-input/faulty-input.json",