summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore33
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html15
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss3
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts116
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts6
-rw-r--r--docs/bluePrintsProcessor.rst21
-rw-r--r--docs/controllerBlueprintStudioProcessor.rst10
-rw-r--r--docs/index.rst4
-rw-r--r--docs/media/blueprintprocessor.jpgbin0 -> 47208 bytes
-rw-r--r--ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt39
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt13
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt4
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt8
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt21
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt44
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt28
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt14
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt39
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt21
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt91
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt29
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt112
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java69
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java69
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt20
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt23
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt16
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt24
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt20
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt40
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt14
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt76
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt48
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.kt63
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt56
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt66
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.java127
-rw-r--r--ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java103
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt138
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt94
43 files changed, 1005 insertions, 748 deletions
diff --git a/.gitignore b/.gitignore
index fdde5ebe8..53cb42dfe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,6 +83,39 @@ typings/
# DynamoDB Local files
.dynamodb/
+# Microservices
+
+.classpath
+.settings/
+
+# Target dirs in all projects
+**/target-ide/*
+**/target/*
+**/logs/*
+**/tokens/*
+
+# Added for Intellij IDEA IDE
+**/*.ipr
+**/*.iws
+**/debug-logs/*
+**/.idea/*
+**/*.iml
+**/*.project
+**/.springBeans
+
+**/*versionsBackup
+**/blackDuckHub*
+**/*.jsonld
+**/.checkstyle
+**/.gitignore
+
+**/*.log
+**/*py.class
+**/.DS_Store
+
+# To Remove Kotlin Script Generated Jars
+**/*cba-kts.jar
+
# Added for Intellij IDEA IDE
**/*.ipr
**/*.iws
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
index 308f9cc1f..2b88bcfcf 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
+++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
@@ -20,18 +20,29 @@ limitations under the License.
<div class="container">
<div class="fileViewContainer">
+ <!-- <div style="width:inherit; height: inherit; position: fixed;z-index: 1; background-color: rgb(0,0,0);background-color: rgba(0,0,0,0.4);"></div> -->
+ <div style="display: flex;">
+ <div>
+ <i class="fa fa-folder" aria-hidden="true" style="color:#3f51b5; font-size: 20px;margin: 3px; cursor: pointer;" (click)="enableNameInputEl('createFolder')"></i>
+ <i class="fa fa-file" aria-hidden="true" style="color:#3f51b5; font-size: 18px; margin: 3px; cursor: pointer;" (click)="enableNameInputEl('createFile')"></i>
+ <i class="fa fa-trash" aria-hidden="true" style="color:#3f51b5; font-size: 20px; margin: 3px; cursor: pointer;" (click)="deleteFolderOrFile('deleteFile')"></i>
+ </div>
+ <div>
+ <input *ngIf="isNameTextboxEnablled" type="text" (focusout)="createFolderOrFile($event)"/>
+ </div>
+ </div>
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" style="background-color: #ebebeb">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding (click)="selectFileToView(node);activeNode = node" [ngClass]="{ 'background-highlight': activeNode === node }">
<button mat-icon-button disabled></button>
<button mat-icon-button (click)="selectFileToView(node)">{{node.name}}</button>
</mat-tree-node>
- <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
+ <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding (click)="activeNode = node" [ngClass]="{ 'background-highlight': activeNode === node }">
<button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
- <button mat-icon-button>{{node.name}}</button>
+ <button mat-icon-button (click)="selectFolder(node)">{{node.name}}</button>
</mat-tree-node>
</mat-tree>
</div>
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss
index 2f16af7a5..ad2e03833 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss
+++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss
@@ -61,5 +61,6 @@ limitations under the License.
}
.background-highlight {
- background-color: whitesmoke !important;
+ background-color: #3f51b5 !important;
+ color: white !important;
} \ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
index e48177d0a..eaac8cbde 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts
@@ -83,6 +83,11 @@ export class EditorComponent implements OnInit {
mode: string;
private zipFile: JSZip = new JSZip();
activeNode: any;
+ selectedFolder: string;
+ activationBlueprint: string;
+ isNameTextboxEnablled : boolean = false;
+ fileAction : string;
+ filetoDelete : string;
private transformer = (node: Node, level: number) => {
return {
@@ -155,14 +160,14 @@ export class EditorComponent implements OnInit {
updateBlueprint() {
console.log(this.blueprint);
this.filesData.forEach(fileNode => {
- if (fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) {
+ if (this.selectedFile && fileNode.name.includes(this.blueprintName.trim()) && fileNode.name.includes(this.selectedFile.trim())) {
fileNode.data = this.text;
- } else if (fileNode.name.includes(this.selectedFile.trim())) {
+ } else if (this.selectedFile && fileNode.name.includes(this.selectedFile.trim())) {
fileNode.data = this.text;
}
});
- if (this.selectedFile == this.blueprintName.trim()) {
+ if (this.selectedFile && this.selectedFile == this.blueprintName.trim()) {
this.blueprint = JSON.parse(this.text);
} else {
this.blueprint = this.blueprintdata;
@@ -180,6 +185,7 @@ export class EditorComponent implements OnInit {
selectFileToView(file) {
this.selectedFile = file.name;
+ this.filetoDelete = file.name;
this.filesData.forEach((fileNode) => {
if (fileNode.name.includes(file.name)) {
this.text = fileNode.data;
@@ -239,4 +245,108 @@ export class EditorComponent implements OnInit {
this.mode = 'json';
}
}
+
+ selectFolder(node) {
+ this.selectedFolder = node.name;
+ this.filetoDelete = node.name;
+ console.log(node);
+ // this.createFolderOrFile(node.name, 'folder');
+ }
+
+ createFolderOrFile(name) {
+ let newFilesData: [any] = this.filesData;
+ let newFileNode = {
+ name: '',
+ data: ''
+ }
+ let newFileNode1 = {
+ name: '',
+ data: ''
+ }
+ for(let i=0; i< this.filesData.length; i++) {
+ if (this.filesData[i].name.includes(this.selectedFolder)) {
+ if(this.fileAction == 'createFolder') {
+ newFileNode.name = this.filesData[i].name + name.srcElement.value + '/';
+ newFileNode.data = '';
+
+ newFileNode1.name = this.filesData[i].name + name.srcElement.value + '/README.md'
+ newFileNode1.data = name.srcElement.value + ' Folder';
+ } else {
+ newFileNode.name = this.filesData[i].name + name.srcElement.value;
+ newFileNode.data = '';
+ }
+ break;
+ }
+ }
+
+ this.filesData.splice(this.findIndexForNewNode()+1, 0, newFileNode);
+ this.filesData.splice(this.findIndexForNewNode()+1, 0, newFileNode1);
+ this.arrangeTreeData(this.filesData);
+ }
+
+ findIndexForNewNode() {
+ let indexForNewNode;
+ for(let i=0; i< this.filesData.length; i++) {
+ if (this.filesData[i].name.includes(this.selectedFolder)) {
+ indexForNewNode = i;
+ }
+ }
+ return indexForNewNode;
+ }
+
+ arrangeTreeData(paths) {
+ const tree = [];
+
+ paths.forEach((path) => {
+
+ const pathParts = path.name.split('/');
+ // pathParts.shift();
+ let currentLevel = tree;
+
+ pathParts.forEach((part) => {
+ const existingPath = currentLevel.filter(level => level.name === part);
+
+ if (existingPath.length > 0) {
+ currentLevel = existingPath[0].children;
+ } else {
+ const newPart = {
+ name: part,
+ children: [],
+ data: path.data,
+ path : path.name
+ };
+ if(part.trim() == this.blueprintName.trim()) {
+ this.activationBlueprint = path.data;
+ newPart.data = JSON.parse(this.activationBlueprint.toString());
+ console.log('newpart', newPart);
+ }
+ if(newPart.name !== '') {
+ currentLevel.push(newPart);
+ currentLevel = newPart.children;
+ }
+ }
+ });
+ });
+ this.dataSource.data = tree;
+ this.filesTree = tree;
+ this.isNameTextboxEnablled = false;
+ this.updateBlueprint();
+ }
+
+ enableNameInputEl(action) {
+ this.fileAction = action;
+ if (action == 'createFolder' || action == 'createFile') {
+ this.isNameTextboxEnablled = true;
+ }
+ }
+
+ deleteFolderOrFile(action) {
+ for(let i=0;i< this.filesData.length ; i++) {
+ if(this.filesData[i].name.includes(this.filetoDelete.trim())) {
+ this.filesData.splice(i, 1);
+ i = i-1;
+ }
+ }
+ this.arrangeTreeData(this.filesData);
+ }
}
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
index 777faee68..36876233d 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
@@ -60,6 +60,7 @@ export class SearchTemplateComponent implements OnInit {
}
fileChanged(e: any) {
+ this.paths = [];
this.file = e.target.files[0];
this.zipFile.files = {};
this.zipFile.loadAsync(this.file)
@@ -119,7 +120,7 @@ export class SearchTemplateComponent implements OnInit {
paths.forEach((path) => {
const pathParts = path.name.split('/');
- pathParts.shift();
+ // pathParts.shift();
let currentLevel = tree;
pathParts.forEach((part) => {
@@ -131,7 +132,8 @@ export class SearchTemplateComponent implements OnInit {
const newPart = {
name: part,
children: [],
- data: path.data
+ data: path.data,
+ path : path.name
};
if(part.trim() == this.blueprintName.trim()) {
this.activationBlueprint = path.data;
diff --git a/docs/bluePrintsProcessor.rst b/docs/bluePrintsProcessor.rst
new file mode 100644
index 000000000..a687d50be
--- /dev/null
+++ b/docs/bluePrintsProcessor.rst
@@ -0,0 +1,21 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.
+.. Copyright (C) 2019 IBM.
+
+Blueprints Processor
+====================
+
+.. toctree::
+ :maxdepth: 1
+ :titlesonly:
+
+Micro service to Manage Controller Blueprint Models, such as Resource Dictionary, Service Models, Velocity Templates etc, which will serve service for Controller Design Studio and Controller runtimes.
+
+Architecture:
+==============
+
+|image0|
+
+.. |image0| image:: images/blueprintprocessor.jpg
+ :height: 600px
+ :width: 800px \ No newline at end of file
diff --git a/docs/controllerBlueprintStudioProcessor.rst b/docs/controllerBlueprintStudioProcessor.rst
new file mode 100644
index 000000000..fc9112296
--- /dev/null
+++ b/docs/controllerBlueprintStudioProcessor.rst
@@ -0,0 +1,10 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.
+.. Copyright (C) 2019 IBM.
+
+Controller Blueprints Studio Processor
+======================================
+
+.. toctree::
+ :maxdepth: 1
+ :titlesonly: \ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index f46653ab6..9e8e0e10f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -22,6 +22,10 @@ Design tools:
CBA/index
datadictionary/index
+MicroServices:
+==============
+ * Controller Blueprints Studio Processor
+ * Blueprints Processor
Architecture:
=============
diff --git a/docs/media/blueprintprocessor.jpg b/docs/media/blueprintprocessor.jpg
new file mode 100644
index 000000000..c618e0e32
--- /dev/null
+++ b/docs/media/blueprintprocessor.jpg
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index a73c6a7d1..fb6a0832a 100644
--- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -43,7 +43,7 @@ open class ExecutionServiceOutput {
@get:ApiModelProperty(required = true)
lateinit var actionIdentifiers: ActionIdentifiers
@get:ApiModelProperty(required = true)
- var status: Status = Status()
+ lateinit var status: Status
@get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index d6c1a7c21..35fef96fd 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -19,7 +19,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.execution
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.JsonNodeFactory
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
@@ -30,6 +29,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode
import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
/**
@@ -70,10 +70,10 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")
- val operationInputs = bluePrintRuntimeService.get("$stepName-step-inputs")
- ?: JsonNodeFactory.instance.objectNode()
+ val stepInputs = bluePrintRuntimeService.get("$stepName-step-inputs")
+ ?: JacksonUtils.objectMapper.createObjectNode()
- operationInputs.fields().forEach {
+ stepInputs.fields().forEach {
this.operationInputs[it.key] = it.value
}
@@ -98,23 +98,20 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
log.info("Preparing Response...")
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
-
- // Resolve the Output Expression
- val stepOutputs = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
-
- // FIXME("Not the right place to populate the response payload")
- executionServiceOutput.payload = stepOutputs.asObjectNode()
-
- bluePrintRuntimeService.put("$stepName-step-outputs", executionServiceOutput.payload)
-
- // FIXME("Not the right place to populate the status")
- // Populate Status
- val status = Status()
- status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
- status.code = 200
- status.message = BluePrintConstants.STATUS_SUCCESS
- executionServiceOutput.status = status
+ var status: Status?
+ try {
+ // Resolve the Output Expression
+ val stepOutputs = bluePrintRuntimeService
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
+
+ bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asObjectNode())
+ // Set the Default Step Status
+ status = Status()
+ } catch (e: Exception) {
+ status = Status()
+ status.message = BluePrintConstants.STATUS_FAILURE
+ }
+ executionServiceOutput.status = status!!
return this.executionServiceOutput
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
index fbd9f4c8b..d8aefe904 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImpl.kt
@@ -20,8 +20,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
@@ -41,6 +43,10 @@ open class BluePrintWorkflowExecutionServiceImpl(
val workflowName = executionServiceInput.actionIdentifiers.actionName
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
@@ -65,7 +71,12 @@ open class BluePrintWorkflowExecutionServiceImpl(
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- // TODO("Populate Response Payload and status")
+ // Resolve Workflow Outputs
+ val workflowOutputs = bluePrintRuntimeService.resolveWorkflowOutputs(workflowName)
+
+ // Set the Response Payload
+ executionServiceOutput.payload = JacksonUtils.objectMapper.createObjectNode()
+ executionServiceOutput.payload.set("$workflowName-response", workflowOutputs.asObjectNode())
return executionServiceOutput
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
index 3b2fc3368..ee6c35397 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/ComponentWorkflowExecutionService.kt
@@ -38,10 +38,6 @@ open class ComponentWorkflowExecutionService(private val nodeTemplateExecutionSe
// Get the DG Node Template
val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
- // Assign Workflow inputs
- val input = executionServiceInput.payload.get("$workflowName-request")
- bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
-
return nodeTemplateExecutionService.executeNodeTemplate(bluePrintRuntimeService,
nodeTemplateName, executionServiceInput)
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
index 571b6c7c0..80aa1030d 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionService.kt
@@ -21,10 +21,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
-import java.io.File
@Service("dgWorkflowExecutionService")
@@ -51,17 +51,13 @@ open class DGWorkflowExecutionService(private val blueprintSvcLogicService: Blue
WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
// Populate the DG Path
- val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
+ val dgFilePath = normalizedPathName(bluePrintContext.rootPath, artifactDefinition.file)
log.info("Executing directed graph ($dgFilePath)")
// Create DG instance
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
- // Assign Workflow inputs
- val input = executionServiceInput.payload.get("$workflowName-request")
- bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
-
// Execute the DG
return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
index 3958f0c15..59be9406e 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BluePrintWorkflowExecutionServiceImplTest.kt
@@ -21,12 +21,15 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@@ -38,16 +41,20 @@ class BluePrintWorkflowExecutionServiceImplTest {
@Test
fun testBluePrintWorkflowExecutionService() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
+ ExecutionServiceInput::class.java)!!
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json",
- ExecutionServiceInput::class.java)!!
- runBlocking {
- bluePrintWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput,
- hashMapOf())
+ val executionServiceOutput = bluePrintWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, hashMapOf())
+
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
}
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index ad2ee57d7..4352277b7 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -24,21 +24,20 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu
import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.slf4j.LoggerFactory
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
class BlueprintServiceLogicTest {
- private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
-
@Autowired
lateinit var applicationContext: ApplicationContext
@@ -47,14 +46,22 @@ class BlueprintServiceLogicTest {
@Test
fun testExecuteGraphWithSingleComponent() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val executionServiceInput = JacksonReactorUtils
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ // Assign Workflow inputs Mock
+ val input = executionServiceInput.payload.get("resource-assignment-request")
+ bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
- runBlocking {
- dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ val executionServiceOutput = dgWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
}
@@ -62,14 +69,23 @@ class BlueprintServiceLogicTest {
@Test
fun testExecuteGraphWithMultipleComponents() {
+ runBlocking {
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val executionServiceInput = JacksonReactorUtils
+ .readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+ // Assign Workflow inputs Mock
+ val input = executionServiceInput.payload.get("assign-activate-request")
+ bluePrintRuntimeService.assignWorkflowInputs("assign-activate", input)
- runBlocking {
- dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+
+ val executionServiceOutput = dgWorkflowExecutionService
+ .executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
}
}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
index 0980f84aa..ac2d7d62c 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/DGWorkflowExecutionServiceTest.kt
@@ -22,33 +22,43 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.slf4j.LoggerFactory
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
class DGWorkflowExecutionServiceTest {
- private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
-
@Autowired
lateinit var dgWorkflowExecutionService: DGWorkflowExecutionService
@Test
fun testExecuteDirectedGraph() {
+ runBlocking {
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+ val executionServiceInput = JacksonReactorUtils
+ .readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
- runBlocking {
- dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService, executionServiceInput, mutableMapOf())
+ // Assign Workflow inputs Mock
+ val input = executionServiceInput.payload.get("resource-assignment-request")
+ bluePrintRuntimeService.assignWorkflowInputs("resource-assignment", input)
+
+ val executionServiceOutput = dgWorkflowExecutionService.executeBluePrintWorkflow(bluePrintRuntimeService,
+ executionServiceInput, mutableMapOf())
+
+ assertNotNull(executionServiceOutput, "failed to get response")
+ assertEquals(BluePrintConstants.STATUS_SUCCESS, executionServiceOutput.status.message,
+ "failed to get successful response")
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt
index b9d80b301..6744b625e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt
@@ -16,10 +16,13 @@
package org.onap.ccsdk.cds.controllerblueprints.core
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
import org.apache.commons.io.FileUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
import java.io.File
import java.io.InputStream
+import java.nio.charset.Charset
import java.nio.file.Path
import java.nio.file.Paths
@@ -81,3 +84,10 @@ fun normalizedPathName(path: String, vararg more: String?): String {
return normalizedPath(path, *more).toString()
}
+suspend fun File.readNBText(): String = withContext(Dispatchers.IO) {
+ readText(Charset.defaultCharset())
+}
+
+suspend fun File.readNBLines(): List<String> = withContext(Dispatchers.IO) {
+ readLines(Charset.defaultCharset())
+}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
index 904983fcd..bc0103958 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018-2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,12 +26,12 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import java.io.File
-import java.nio.charset.Charset
import java.util.*
class BluePrintMetadataUtils {
@@ -39,13 +39,13 @@ class BluePrintMetadataUtils {
private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
- fun toscaMetaData(basePath: String): ToscaMetaData {
+ suspend fun toscaMetaData(basePath: String): ToscaMetaData {
val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
return toscaMetaDataFromMetaFile(toscaMetaPath)
}
- fun entryDefinitionFile(basePath: String): String {
+ suspend fun entryDefinitionFile(basePath: String): String {
val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER)
.plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE)
return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions
@@ -59,7 +59,7 @@ class BluePrintMetadataUtils {
fun environmentFileProperties(pathName: String): Properties {
val properties = Properties()
- val envDir = File(pathName)
+ val envDir = normalizedFile(pathName)
// Verify if the environment directory exists
if (envDir.exists() && envDir.isDirectory) {
//Find all available environment files
@@ -72,9 +72,9 @@ class BluePrintMetadataUtils {
return properties
}
- fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
+ private suspend fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
val toscaMetaData = ToscaMetaData()
- val lines = normalizedFile(metaFilePath).readLines(Charset.defaultCharset())
+ val lines = normalizedFile(metaFilePath).readNBLines()
lines.forEach { line ->
if (line.contains(":")) {
val keyValue = line.split(":")
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
index 85ae359cd..7ac79e2f1 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
@@ -16,15 +16,12 @@
*/
package org.onap.ccsdk.cds.controllerblueprints.core.utils
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.node.*
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.apache.commons.io.IOUtils
@@ -39,16 +36,18 @@ import java.nio.charset.Charset
*/
class JacksonUtils {
companion object {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+
+ val objectMapper = jacksonObjectMapper()
+
inline fun <reified T : Any> readValue(content: String): T =
- jacksonObjectMapper().readValue(content, T::class.java)
+ objectMapper.readValue(content, T::class.java)
fun <T> readValue(content: String, valueType: Class<T>): T? {
- return jacksonObjectMapper().readValue(content, valueType)
+ return objectMapper.readValue(content, valueType)
}
fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
- return jacksonObjectMapper().treeToValue(node, valueType)
+ return objectMapper.treeToValue(node, valueType)
}
fun removeJsonNullNode(node: JsonNode) {
@@ -64,16 +63,12 @@ class JacksonUtils {
}
- fun getContent(fileName: String): String = getContent(normalizedFile(fileName))
-
- fun getContent(file: File): String = runBlocking {
- async {
- try {
- file.readText(Charsets.UTF_8)
- } catch (e: Exception) {
- throw BluePrintException("couldn't get file (${file.absolutePath}) content : ${e.message}")
- }
- }.await()
+ fun getContent(fileName: String): String = runBlocking {
+ try {
+ normalizedFile(fileName).readNBText()
+ } catch (e: Exception) {
+ throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ }
}
fun getClassPathFileContent(fileName: String): String {
@@ -96,11 +91,11 @@ class JacksonUtils {
}
fun objectNodeFromObject(from: kotlin.Any): ObjectNode {
- return jacksonObjectMapper().convertValue(from, ObjectNode::class.java)
+ return objectMapper.convertValue(from, ObjectNode::class.java)
}
fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
- return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
+ return objectMapper.convertValue(from, JsonNode::class.java)
}
fun jsonNodeFromClassPathFile(fileName: String): JsonNode {
@@ -171,9 +166,9 @@ class JacksonUtils {
return objectMapper.readValue(content, mapType)
}
- fun <T> getMapFromFile(file: File, valueType: Class<T>): MutableMap<String, T> {
- val content: String = getContent(file)
- return getMapFromJson(content, valueType)
+ fun <T> getMapFromFile(file: File, valueType: Class<T>): MutableMap<String, T> = runBlocking {
+ val content: String = file.readNBText()
+ getMapFromJson(content, valueType)
}
fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T> = getMapFromFile(File(fileName), valueType)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
index 7a1fb6d9e..1a6ccfa17 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
@@ -18,6 +18,7 @@
package org.onap.ccsdk.cds.controllerblueprints.core.utils
+import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
import kotlin.test.assertEquals
@@ -29,15 +30,17 @@ class BluePrintMetadataUtilsTest {
@Test
fun testToscaMetaData() {
- val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
-
- val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
- assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
- assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
- assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
- assertNotNull(toscaMetaData.createdBy, "Missing Created by")
- assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition")
- assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
+ runBlocking {
+ val basePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+
+ val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
+ assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
+ assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
+ assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
+ assertNotNull(toscaMetaData.createdBy, "Missing Created by")
+ assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition")
+ assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
+ }
}
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
index 7e70a762d..fb466f7c3 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -1,6 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Modifications Copyright © 2018-2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,17 +19,14 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
-import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
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.format
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintExpressionService
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -43,6 +40,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
lateinit var bluePrintContext: BluePrintContext
+ lateinit var propertyAssignmentValidationUtils: PropertyAssignmentValidationUtils
var paths: MutableList<String> = arrayListOf()
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
@@ -51,6 +49,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+ propertyAssignmentValidationUtils = PropertyAssignmentValidationUtils(bluePrintContext)
+
paths.add(name)
val type: String = nodeTemplate.type
@@ -58,7 +58,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type)
?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($name)")
- nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
+ nodeTemplate.properties?.let {
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!)
+ }
nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, name, nodeTemplate) }
@@ -80,29 +83,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
paths.removeAt(paths.lastIndex)
}
-
- @Throws(BluePrintException::class)
- open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
- properties: MutableMap<String, JsonNode>) {
- properties.forEach { propertyName, propertyAssignment ->
- val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
- ?: throw BluePrintException("failed to get definition for the property ($propertyName)")
-
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
-
- }
- }
-
- @Throws(BluePrintException::class)
- open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
- propertyAssignment: JsonNode) {
- // Check and Validate if Expression Node
- val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
- if (!expressionData.isExpression) {
- checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
- }
- }
-
@Throws(BluePrintException::class)
open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
val capabilities = nodeTemplate.capabilities
@@ -125,7 +105,10 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String,
capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) {
- capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) }
+ capabilityAssignment.properties?.let {
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!)
+ }
}
@@ -224,7 +207,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation " +
"definition ($operationAssignmentName) property definition($propertyName)")
// Check the property values with property definition
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
outputs?.forEach { propertyName, propertyAssignment ->
@@ -232,7 +216,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " +
"output property definition($propertyName)")
// Check the property values with property definition
- validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+ propertyAssignmentValidationUtils
+ .validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
}
}
@@ -240,48 +225,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
- open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
- val propertyType = propertyDefinition.type
- val isValid: Boolean
-
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
- isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
-
- } else if (BluePrintTypes.validComplexTypes().contains(propertyType)) {
- isValid = true
- } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
-
- val entrySchemaType = propertyDefinition.entrySchema?.type
- ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
-
- if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
- checkPropertyDataType(entrySchemaType, propertyName)
- }
- isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
- } else {
- checkPropertyDataType(propertyType, propertyName)
- isValid = true
- }
-
- check(isValid) {
- throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)")
- }
- }
-
- private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
-
- val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
- ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found")
-
- checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
-
- }
-
- private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
- check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
- throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
- }
- }
private fun validateExtension(referencePrefix: String, name: String, nodeTemplate: NodeTemplate) {
val customValidator = bluePrintTypeValidatorService
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
index 306203128..a7dbbf846 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -18,6 +19,7 @@ package org.onap.ccsdk.cds.controllerblueprints.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -45,6 +47,12 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
paths.add(workflowName)
paths.joinToString(BluePrintConstants.PATH_DIVIDER)
+ // Validate Workflow Inputs
+ validateInputs(workflow)
+
+ // Validate Workflow outputs
+ validateOutputs(workflow)
+
// Step Validation Start
paths.add("steps")
workflow.steps?.forEach { stepName, step ->
@@ -69,14 +77,33 @@ open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorServ
"definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!)
}
}
- paths.removeAt(paths.lastIndex)
+
}
paths.removeAt(paths.lastIndex)
// Step Validation Ends
paths.removeAt(paths.lastIndex)
+ paths.removeAt(paths.lastIndex)
+ }
+
+ private fun validateInputs(workflow: Workflow) {
workflow.inputs?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!)
}
}
+
+ private fun validateOutputs(workflow: Workflow) {
+ workflow.outputs?.let {
+
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.outputs!!)
+
+ PropertyAssignmentValidationUtils(bluePrintRuntimeService.bluePrintContext())
+ .validatePropertyDefinitionNAssignments(workflow.outputs!!)
+ }
+ // Validate Value or Expression
+ workflow.outputs?.forEach { propertyName, propertyDefinition ->
+
+ }
+ }
+
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt
new file mode 100644
index 000000000..35ddc5b6f
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt
@@ -0,0 +1,112 @@
+/*
+ * 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.controllerblueprints.validation.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+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.format
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintExpressionService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+open class PropertyAssignmentValidationUtils(private val bluePrintContext: BluePrintContext) {
+
+ // Property Definition holds both Definitons and Expression in same construct
+ open fun validatePropertyDefinitionNAssignments(propertyDefinitions: MutableMap<String, PropertyDefinition>) {
+ propertyDefinitions.forEach { propertyName, propertyDefinition ->
+ validatePropertyDefinitionNAssignment(propertyName, propertyDefinition)
+ }
+ }
+
+ // Property Definition holds both Definitons and Expression in same construct
+ open fun validatePropertyDefinitionNAssignment(propertyName: String, propertyDefinition: PropertyDefinition) {
+ // Check and Validate if Expression Node
+ checkNotNull(propertyDefinition.value) {
+ throw BluePrintException("couldn't get 'value' property from PropertyDefinition($propertyName)")
+ }
+ val propertyAssignment = propertyDefinition.value!!
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
+ }
+ }
+
+ open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
+ properties: MutableMap<String, JsonNode>) {
+ properties.forEach { propertyName, propertyAssignment ->
+ val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
+ ?: throw BluePrintException("failed to get definition for the property ($propertyName)")
+
+ validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment)
+
+ }
+ }
+
+ open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition,
+ propertyAssignment: JsonNode) {
+ // Check and Validate if Expression Node
+ val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
+ if (!expressionData.isExpression) {
+ checkPropertyValue(propertyName, propertyDefinition, propertyAssignment)
+ }
+ }
+
+ open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
+ val propertyType = propertyDefinition.type
+ val isValid: Boolean
+
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
+ isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
+
+ } else if (BluePrintTypes.validComplexTypes().contains(propertyType)) {
+ isValid = true
+ } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
+
+ val entrySchemaType = propertyDefinition.entrySchema?.type
+ ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName))
+
+ if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) {
+ checkPropertyDataType(entrySchemaType, propertyName)
+ }
+ isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
+ } else {
+ checkPropertyDataType(propertyType, propertyName)
+ isValid = true
+ }
+
+ check(isValid) {
+ throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)")
+ }
+ }
+
+ open fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found")
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+
+ }
+
+ open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
+ }
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java
deleted file mode 100644
index 9aeee1771..000000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 Bell Canada.
- *
- * 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.controllerblueprints.service.repository;
-
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import javax.validation.constraints.NotNull;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ControllerBlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Repository
-public interface ControllerBlueprintModelSearchRepository extends JpaRepository<BlueprintModelSearch, Long> {
-
- /**
- * This is a findById method
- *
- * @param id id
- * @return Optional<BlueprintModelSearch>
- */
- @NotNull
- Optional<BlueprintModelSearch> findById(@NotNull String id);
-
- /**
- * This is a findAll method
- * @return List<BlueprintModelSearch>
- */
- @Override
- List<BlueprintModelSearch> findAll();
-
- /**
- * This is a findByArtifactNameAndArtifactVersion method
- *
- * @param artifactName artifactName
- * @param artifactVersion artifactVersion
- * @return Optional<AsdcArtifacts>
- */
- Optional<BlueprintModelSearch> findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion);
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags
- * @return Optional<BlueprintModelSearch>
- */
- List<BlueprintModelSearch> findByTagsContainingIgnoreCase(String tags);
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java
deleted file mode 100644
index 314ac6a4e..000000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.controllerblueprints.service.repository;
-
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * ResourceMappingRepository.java Purpose: Provide Configuration Generator ResourceMappingRepository
- *
- * @author Brinda Santh
- * @version 1.0
- */
-@Repository
-public interface ResourceDictionaryRepository extends JpaRepository<ResourceDictionary, String> {
-
-
- /**
- * This is a findByName method
- *
- * @param name name
- * @return Optional<ResourceMapping>
- */
- Optional<ResourceDictionary> findByName(String name);
-
- /**
- * This is a findByNameIn method
- *
- * @param names names
- * @return Optional<ResourceMapping>
- */
- List<ResourceDictionary> findByNameIn(List<String> names);
-
- /**
- * This is a findByTagsContainingIgnoreCase method
- *
- * @param tags tags
- * @return Optional<ModelType>
- */
- List<ResourceDictionary> findByTagsContainingIgnoreCase(String tags);
-
- /**
- * This is a deleteByName method
- *
- * @param name name
- */
- void deleteByName(String name);
-
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt
index 8ede9f208..e1fa1882d 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/BluePrintRepoServiceImpl.kt
@@ -72,8 +72,8 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe
@Throws(BluePrintException::class)
override fun getResourceDefinition(resourceDefinitionName: String): ResourceDefinition {
val dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName)
- return if (dbResourceDictionary.isPresent) {
- dbResourceDictionary.get().definition
+ return if (dbResourceDictionary != null) {
+ dbResourceDictionary.definition
} else {
throw BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName))
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt
index 0509e970e..341d63bf0 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeController.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -19,6 +20,7 @@ package org.onap.ccsdk.cds.controllerblueprints.service.controller
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler
+import kotlinx.coroutines.runBlocking
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.*
@@ -27,30 +29,30 @@ import org.springframework.web.bind.annotation.*
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? {
- return modelTypeHandler.getModelTypeByName(name)
+ 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> {
- return modelTypeHandler.searchModelTypes(tags)
+ 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> {
- return modelTypeHandler.getModelTypeByDefinitionType(definitionType)
+ 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 {
- return modelTypeHandler.saveModel(modelType)
+ fun saveModelType(@RequestBody modelType: ModelType): ModelType = runBlocking {
+ modelTypeHandler.saveModel(modelType)
}
@DeleteMapping(path = arrayOf("/{name}"))
- fun deleteModelTypeByName(@PathVariable(value = "name") name: String) {
+ fun deleteModelTypeByName(@PathVariable(value = "name") name: String) = runBlocking {
modelTypeHandler.deleteByModelName(name)
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt
index e21639715..d728fc229 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ResourceDictionaryController.kt
@@ -20,6 +20,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceSourceMapping
import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler
+import kotlinx.coroutines.runBlocking
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.*
@@ -30,39 +31,39 @@ open class ResourceDictionaryController(private val resourceDictionaryHandler: R
@GetMapping(path = ["/{name}"], produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
@Throws(BluePrintException::class)
- fun getResourceDictionaryByName(@PathVariable(value = "name") name: String): ResourceDictionary {
- return resourceDictionaryHandler.getResourceDictionaryByName(name)
+ 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 {
- return resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
+ fun saveResourceDictionary(@RequestBody dataDictionary: ResourceDictionary): ResourceDictionary = runBlocking {
+ resourceDictionaryHandler.saveResourceDictionary(dataDictionary)
}
@DeleteMapping(path = ["/{name}"])
- fun deleteResourceDictionaryByName(@PathVariable(value = "name") name: String) {
+ 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> {
- return resourceDictionaryHandler.searchResourceDictionaryByNames(names)
+ 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> {
- return resourceDictionaryHandler.searchResourceDictionaryByTags(tags)
+ 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 {
- return resourceDictionaryHandler.getResourceSourceMapping()
+ fun getResourceSourceMapping(): ResourceSourceMapping = runBlocking {
+ resourceDictionaryHandler.getResourceSourceMapping()
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
index 091dfdafc..8379e5032 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -66,11 +67,16 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
// 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)
- // Enrich Workflow Inputs
- enhanceWorkflowInputs(name, workflow)
+
}
open fun enhanceWorkflowInputs(name: String, workflow: Workflow) {
@@ -80,6 +86,12 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
}
}
+ 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)
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt
index 5c1a1652c..f602437ed 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -34,10 +35,15 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
* @param modelTypeName modelTypeName
* @return ModelType
*/
- fun getModelTypeByName(modelTypeName: String): ModelType? {
+ suspend fun getModelTypeByName(modelTypeName: String): ModelType {
log.info("Searching : $modelTypeName")
check(modelTypeName.isNotBlank()) { "Model Name Information is missing." }
- return modelTypeRepository.findByModelName(modelTypeName)
+ val modelType = modelTypeRepository.findByModelName(modelTypeName)
+ return if (modelType != null) {
+ modelType
+ } else {
+ throw BluePrintException("couldn't get modelType($modelTypeName)")
+ }
}
@@ -47,7 +53,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
* @param tags tags
* @return List<ModelType>
</ModelType> */
- fun searchModelTypes(tags: String): List<ModelType> {
+ suspend fun searchModelTypes(tags: String): List<ModelType> {
check(tags.isNotBlank()) { "No Search Information provide" }
return modelTypeRepository.findByTagsContainingIgnoreCase(tags)
}
@@ -60,7 +66,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
* @throws BluePrintException BluePrintException
*/
@Throws(BluePrintException::class)
- open fun saveModel(modelType: ModelType): ModelType {
+ suspend open fun saveModel(modelType: ModelType): ModelType {
lateinit var dbModel: ModelType
ModelTypeValidator.validateModelType(modelType)
val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName)
@@ -86,7 +92,7 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
*
* @param modelName modelName
*/
- open fun deleteByModelName(modelName: String) {
+ suspend open fun deleteByModelName(modelName: String) {
check(modelName.isNotBlank()) { "Model Name Information is missing." }
modelTypeRepository.deleteByModelName(modelName)
@@ -97,8 +103,8 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
*
* @param definitionType definitionType
* @return List<ModelType>
- */
- fun getModelTypeByDefinitionType(definitionType: String): List<ModelType> {
+ */
+ suspend fun getModelTypeByDefinitionType(definitionType: String): List<ModelType> {
check(definitionType.isNotBlank()) { "Model definitionType Information is missing." }
return modelTypeRepository.findByDefinitionType(definitionType)
}
@@ -108,8 +114,8 @@ open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository
*
* @param derivedFrom derivedFrom
* @return List<ModelType>
- */
- fun getModelTypeByDerivedFrom(derivedFrom: String): List<ModelType> {
+ */
+ suspend fun getModelTypeByDerivedFrom(derivedFrom: String): List<ModelType> {
check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." }
return modelTypeRepository.findByDerivedFrom(derivedFrom)
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
index f6e95de2d..df8cffdba 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
@@ -40,11 +40,11 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
* @throws BluePrintException BluePrintException
*/
@Throws(BluePrintException::class)
- fun getResourceDictionaryByName(name: String): ResourceDictionary {
+ 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.isPresent) {
- resourceDictionaryDb.get()
+ return if (resourceDictionaryDb != null) {
+ resourceDictionaryDb
} else {
throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name))
}
@@ -56,7 +56,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
* @param names names
* @return List<ResourceDictionary>
</ResourceDictionary> */
- fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
+ suspend fun searchResourceDictionaryByNames(names: List<String>): List<ResourceDictionary> {
Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide")
return resourceDictionaryRepository.findByNameIn(names)
}
@@ -67,7 +67,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
* @param tags tags
* @return List<ResourceDictionary>
</ResourceDictionary> */
- fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
+ suspend fun searchResourceDictionaryByTags(tags: String): List<ResourceDictionary> {
Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide")
return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags)
}
@@ -79,7 +79,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
* @return DataDictionary
*/
@Throws(BluePrintException::class)
- fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
+ suspend fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary {
var resourceDictionary = resourceDictionary
val resourceDefinition = resourceDictionary.definition
@@ -101,8 +101,8 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
validateResourceDictionary(resourceDictionary)
val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name)
- if (dbResourceDictionaryData.isPresent) {
- val dbResourceDictionary = dbResourceDictionaryData.get()
+ if (dbResourceDictionaryData != null) {
+ val dbResourceDictionary = dbResourceDictionaryData
dbResourceDictionary.name = resourceDictionary.name
dbResourceDictionary.definition = resourceDictionary.definition
@@ -124,7 +124,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
*
* @param name name
*/
- fun deleteResourceDictionary(name: String) {
+ suspend fun deleteResourceDictionary(name: String) {
check(name.isNotBlank()) { "Resource dictionary name is missing." }
resourceDictionaryRepository.deleteByName(name)
}
@@ -132,7 +132,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
/**
* This is a getResourceSourceMapping service
*/
- fun getResourceSourceMapping(): ResourceSourceMapping {
+ suspend fun getResourceSourceMapping(): ResourceSourceMapping {
return ResourceSourceMappingFactory.getRegisterSourceMapping()
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt
index bffdccda7..eca7ce1bf 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -17,11 +18,8 @@
package org.onap.ccsdk.cds.controllerblueprints.service.load
import com.att.eelf.configuration.EELFManager
-import kotlinx.coroutines.Deferred
-import kotlinx.coroutines.async
-import kotlinx.coroutines.runBlocking
-import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
import org.springframework.stereotype.Service
import java.io.File
@@ -30,38 +28,28 @@ open class BluePrintCatalogLoadService(private val bluePrintCatalogService: Blue
private val log = EELFManager.getInstance().getLogger(BluePrintCatalogLoadService::class.java)
- open fun loadPathsBluePrintModelCatalog(paths: List<String>) {
+ open suspend fun loadPathsBluePrintModelCatalog(paths: List<String>) {
paths.forEach { loadPathBluePrintModelCatalog(it) }
}
- open fun loadPathBluePrintModelCatalog(path: String) {
+ open suspend 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())
- }
+ val files = normalizedFile(path).listFiles()
+ val errors = mutableListOf<String>()
+ files.forEach {
+ loadBluePrintModelCatalog(errors, it)
+ }
+ if (!errors.isEmpty()) {
+ log.error(errors.joinToString("\n"))
}
}
- open fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) {
+ open suspend fun loadBluePrintModelCatalog(errorBuilder: MutableList<String>, file: File) {
try {
+ log.info("loading blueprint cba(${file.absolutePath})")
bluePrintCatalogService.saveToDatabase(file)
} catch (e: Exception) {
- errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}")
+ errorBuilder.add("Couldn't load BlueprintModel(${file.name}: ${e.message}")
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
index e6f6498df..4a3168d65 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -33,7 +34,7 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
@EventListener(ApplicationReadyEvent::class)
- open fun init() {
+ open fun init() = runBlocking {
if (bluePrintLoadConfiguration.loadInitialData) {
initModelTypes()
initResourceDictionary()
@@ -41,23 +42,22 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
} else {
log.info("Initial data load is disabled")
}
+
}
- open fun initModelTypes() {
+ 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 {
- runBlocking {
- modelTypeLoadService.loadPathsModelType(paths)
- }
+ modelTypeLoadService.loadPathsModelType(paths)
}
}
}
- open fun initResourceDictionary() {
+ open suspend fun initResourceDictionary() {
log.info("resource dictionary load configuration(${bluePrintLoadConfiguration.loadResourceDictionary}) " +
"under paths(${bluePrintLoadConfiguration.loadResourceDictionaryPaths})")
@@ -69,7 +69,7 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
}
}
- open fun initBluePrintCatalog() {
+ open suspend fun initBluePrintCatalog() {
log.info("blueprint load configuration(${bluePrintLoadConfiguration.loadBluePrint}) " +
"under paths(${bluePrintLoadConfiguration.loadBluePrintPaths})")
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt
index c3533979b..ff87ad465 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -17,18 +18,21 @@
package org.onap.ccsdk.cds.controllerblueprints.service.load
import com.att.eelf.configuration.EELFManager
-import kotlinx.coroutines.*
+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.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.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler
import org.springframework.stereotype.Service
import java.io.File
-import java.nio.charset.Charset
@Service
open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) {
@@ -37,65 +41,57 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
private val updateBySystem = "System"
open suspend fun loadPathsModelType(modelTypePaths: List<String>) {
- modelTypePaths.forEach { runBlocking { loadPathModelType(it) } }
+ 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) = runBlocking {
+ open suspend fun loadPathModelType(modelTypePath: String) {
log.info(" *************************** loadModelType **********************")
try {
val errorBuilder = StrBuilder()
coroutineScope {
- val dataTypeFiles = File("$modelTypePath/data_type").listFiles()
-
- val deferredResults = mutableListOf<Deferred<Unit>>()
-
- for (file in dataTypeFiles) deferredResults += async {
- loadModelType(file, DataType::class.java, errorBuilder)
+ val dataTypeFiles = normalizedFile("$modelTypePath", "data_type").listFiles()
+ val deferred = dataTypeFiles.map {
+ async {
+ loadModelType(it, DataType::class.java, errorBuilder)
+ }
}
-
- deferredResults.awaitAll()
+ deferred.awaitAll()
}
coroutineScope {
- val artifactTypeFiles = File("$modelTypePath/artifact_type").listFiles()
-
- val deferredResults = mutableListOf<Deferred<Unit>>()
-
- for (file in artifactTypeFiles) deferredResults += async {
- loadModelType(file,
- ArtifactType::class.java, errorBuilder)
+ val artifactTypeFiles = normalizedFile("$modelTypePath", "artifact_type").listFiles()
+ val deferred = artifactTypeFiles.map {
+ async {
+ loadModelType(it, ArtifactType::class.java, errorBuilder)
+ }
}
-
- deferredResults.awaitAll()
+ deferred.awaitAll()
}
coroutineScope {
- val relationshipTypeFiles = File("$modelTypePath/relationship_type").listFiles()
-
- val deferredResults = mutableListOf<Deferred<Unit>>()
-
- for (file in relationshipTypeFiles) deferredResults += async {
- loadModelType(file,
- RelationshipType::class.java, errorBuilder)
+ val relationshipTypeFiles = normalizedFile("$modelTypePath", "relationship_type").listFiles()
+ val deferred = relationshipTypeFiles.map {
+ async {
+ loadModelType(it, RelationshipType::class.java, errorBuilder)
+ }
}
-
- deferredResults.awaitAll()
+ deferred.awaitAll()
}
coroutineScope {
- val nodeTypeFiles = File("$modelTypePath/node_type").listFiles()
-
- val deferredResults = mutableListOf<Deferred<Unit>>()
-
- for (file in nodeTypeFiles) deferredResults += async {
- loadModelType(file,
- NodeType::class.java, errorBuilder)
+ val nodeTypeFiles = normalizedFile("$modelTypePath", "node_type").listFiles()
+ val deferred = nodeTypeFiles.map {
+ async {
+ loadModelType(it, NodeType::class.java, errorBuilder)
+ }
}
- deferredResults.awaitAll()
+ deferred.awaitAll()
}
if (!errorBuilder.isEmpty) {
@@ -106,11 +102,11 @@ open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler)
}
}
- private inline fun <reified T> loadModelType(file: File, classType: Class<T>, errorBuilder: StrBuilder) {
+ 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.readText(Charset.defaultCharset())
+ val definitionContent = file.readNBText()
val definition = JacksonUtils.readValue(definitionContent, classType) as EntityType
//checkNotNull(definition) { "failed to get data type from file : ${file.name}" }
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
index e07552592..69b7c643c 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -17,57 +18,56 @@
package org.onap.ccsdk.cds.controllerblueprints.service.load
import com.att.eelf.configuration.EELFManager
-import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
-import kotlinx.coroutines.runBlocking
+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.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.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler
import org.springframework.stereotype.Service
import java.io.File
-import java.nio.charset.Charset
@Service
open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java)
- open fun loadPathsResourceDictionary(paths: List<String>) {
- paths.forEach { loadPathResourceDictionary(it) }
+ open suspend fun loadPathsResourceDictionary(paths: List<String>) {
+ paths.forEach {
+ loadPathResourceDictionary(it)
+ }
}
- open fun loadPathResourceDictionary(path: String) {
+ open suspend fun loadPathResourceDictionary(path: String) {
log.info(" *************************** loadResourceDictionary **********************")
- val files = File(path).listFiles()
-
- runBlocking {
- val errorBuilder = StrBuilder()
- val deferredResults = mutableListOf<Deferred<Unit>>()
+ val files = normalizedFile(path).listFiles()
+ val errorBuilder = StrBuilder()
- for (file in files) {
- deferredResults += async {
- loadResourceDictionary(errorBuilder, file)
+ coroutineScope() {
+ val deferred = files.map {
+ async {
+ loadResourceDictionary(errorBuilder, it)
}
}
+ deferred.awaitAll()
+ }
- for (deferredResult in deferredResults) {
- deferredResult.await()
- }
-
- if (!errorBuilder.isEmpty) {
- log.error(errorBuilder.toString())
- }
+ if (!errorBuilder.isEmpty) {
+ log.error(errorBuilder.toString())
}
+
}
- private fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) {
+ private suspend fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) {
try {
- log.trace("Loading NodeType(${file.name}")
- val definitionContent = file.readText(Charset.defaultCharset())
+ log.trace("Loading NodeType(${file.name}}")
+ val definitionContent = file.readNBText()
val resourceDefinition = JacksonUtils.readValue(definitionContent, ResourceDefinition::class.java)
if (resourceDefinition != null) {
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.kt
new file mode 100644
index 000000000..bf77af66c
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.kt
@@ -0,0 +1,63 @@
+/*
+ * 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.controllerblueprints.service.repository
+
+import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
+import org.springframework.data.jpa.repository.JpaRepository
+import org.springframework.stereotype.Repository
+import java.util.*
+
+/**
+ * ControllerBlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Repository
+interface ControllerBlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, Long> {
+
+ /**
+ * This is a findById method
+ *
+ * @param id id
+ * @return Optional<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ fun findById(id: String): Optional<BlueprintModelSearch>
+
+ /**
+ * This is a findAll method
+ * @return List<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ override fun findAll(): List<BlueprintModelSearch>
+
+ /**
+ * This is a findByArtifactNameAndArtifactVersion method
+ *
+ * @param artifactName artifactName
+ * @param artifactVersion artifactVersion
+ * @return Optional<AsdcArtifacts>
+ </AsdcArtifacts> */
+ fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): Optional<BlueprintModelSearch>
+
+ /**
+ * This is a findByTagsContainingIgnoreCase method
+ *
+ * @param tags
+ * @return Optional<BlueprintModelSearch>
+ </BlueprintModelSearch> */
+ fun findByTagsContainingIgnoreCase(tags: String): List<BlueprintModelSearch>
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt
deleted file mode 100644
index 5758fb7fb..000000000
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.controllerblueprints.service.repository
-
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
-import org.springframework.stereotype.Service
-import reactor.core.publisher.Flux
-import reactor.core.publisher.Mono
-import reactor.core.scheduler.Schedulers
-
-/**
- * ResourceDictionaryReactRepository.
- *
- * @author Brinda Santh
- */
-@Service
-open class ResourceDictionaryReactRepository(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
-
- fun save(resourceDictionary: ResourceDictionary): Mono<ResourceDictionary> {
- return Mono.justOrEmpty(resourceDictionaryRepository.save(resourceDictionary))
- }
-
- fun findByName(name: String): Mono<ResourceDictionary> {
- return Mono.justOrEmpty(resourceDictionaryRepository.findByName(name))
- }
-
- fun findByNameIn(names: List<String>): Flux<ResourceDictionary> {
- return Flux.fromIterable(resourceDictionaryRepository.findByNameIn(names))
- .subscribeOn(Schedulers.elastic())
- }
-
- fun findByTagsContainingIgnoreCase(tags: String): Flux<ResourceDictionary> {
- return Flux.fromIterable(resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags))
- .subscribeOn(Schedulers.elastic())
- }
-
- fun deleteByName(name: String): Mono<Void> {
- resourceDictionaryRepository.deleteByName(name)
- return Mono.empty()
- }
-
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepository.kt
new file mode 100644
index 000000000..b1b633a10
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/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.controllerblueprints.service.repository
+
+import org.onap.ccsdk.cds.controllerblueprints.service.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/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.java
deleted file mode 100644
index 12652c916..000000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.controllerblueprints.service;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-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.controllerblueprints.TestApplication;
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.test.annotation.Commit;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-@RunWith(SpringRunner.class)
-@DataJpaTest
-@Transactional(propagation = Propagation.NOT_SUPPORTED)
-@ContextConfiguration(classes = {TestApplication.class})
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class ModelTypeServiceTest {
- private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeServiceTest.class);
- @Autowired
- private ModelTypeHandler modelTypeHandler;
-
- String modelName = "test-datatype";
-
- @Test
- @Commit
- public void test01SaveModelType() throws Exception {
- log.info("**************** test01SaveModelType ********************");
-
- String content = JacksonUtils.Companion.getClassPathFileContent("model_type/data_type/datatype-property.json");
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT);
- modelType.setDescription("Definition for Sample Datatype ");
- modelType.setDefinition(JacksonUtils.Companion.jsonNode(content));
- modelType.setModelName(modelName);
- modelType.setVersion("1.0.0");
- modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setUpdatedBy("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.getModelName());
-
- ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelType.getModelName());
- Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")",
- dbModelType);
-
- // Model Update
- modelType.setUpdatedBy("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.getUpdatedBy());
-
- }
-
- @Test
- public void test02SearchModelTypes() throws Exception {
- log.info("*********************** test02SearchModelTypes ***************************");
-
- String tags = "test-datatype";
-
- List<ModelType> 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
- public void test03GetModelType() throws Exception {
- log.info("************************* test03GetModelType *********************************");
- ModelType 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.getModelName());
-
- List<ModelType> 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);
-
- List<ModelType> 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
- public void test04DeleteModelType() throws Exception {
- log.info(
- "************************ test03DeleteModelType ***********************");
- ModelType 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.getModelName());
-
- modelTypeHandler.deleteByModelName(dbResourceMapping.getModelName());
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
deleted file mode 100644
index 37e0549fa..000000000
--- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.service.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.controllerblueprints.TestApplication;
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition;
-import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
-import org.springframework.test.annotation.Commit;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * ResourceDictionaryReactRepositoryTest.
- *
- * @author Brinda Santh
- */
-
-@RunWith(SpringRunner.class)
-@DataJpaTest
-@ContextConfiguration(classes = {TestApplication.class})
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class ResourceDictionaryReactRepositoryTest {
-
- private String sourceName = "test-source";
-
- @Autowired
- protected ResourceDictionaryReactRepository resourceDictionaryReactRepository;
-
- @Test
- @Commit
- public void test01Save() {
- ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-primary-db-source.json", ResourceDefinition.class);
- Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition);
- resourceDefinition.setName(sourceName);
-
- ResourceDictionary resourceDictionary = transformResourceDictionary(resourceDefinition);
- ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.save(resourceDictionary).block();
- Assert.assertNotNull("Failed to save ResourceDictionary", dbResourceDictionary);
- }
-
- @Test
- public void test02FindByNameReact() {
- ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.findByName(sourceName).block();
- Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary);
- }
-
- @Test
- public void test03FindByNameInReact() {
- List<ResourceDictionary> dbResourceDictionaries =
- resourceDictionaryReactRepository.findByNameIn(Arrays.asList(sourceName)).collectList().block();
- Assert.assertNotNull("Failed to query React Resource Dictionary by Names", dbResourceDictionaries);
- }
-
- @Test
- public void test04FindByTagsContainingIgnoreCaseReact() {
- List<ResourceDictionary> dbTagsResourceDictionaries =
- resourceDictionaryReactRepository.findByTagsContainingIgnoreCase(sourceName).collectList().block();
- Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries);
- }
-
- @Test
- @Commit
- public void test05Delete() {
- resourceDictionaryReactRepository.deleteByName(sourceName).block();
- }
-
- private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) {
- ResourceDictionary resourceDictionary = new ResourceDictionary();
- resourceDictionary.setName(resourceDefinition.getName());
- resourceDictionary.setDataType(resourceDefinition.getProperty().getType());
- resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription());
- resourceDictionary.setTags(resourceDefinition.getTags());
- resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy());
- resourceDictionary.setDefinition(resourceDefinition);
- return resourceDictionary;
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt
new file mode 100644
index 000000000..741431840
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/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.controllerblueprints.service
+
+import com.att.eelf.configuration.EELFManager
+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.controllerblueprints.TestApplication
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
+import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.transaction.annotation.Propagation
+import org.springframework.transaction.annotation.Transactional
+
+
+@RunWith(SpringRunner::class)
+@DataJpaTest
+@Transactional(propagation = Propagation.NOT_SUPPORTED)
+@ContextConfiguration(classes = [TestApplication::class])
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+class ModelTypeServiceTest {
+ @Autowired
+ private val modelTypeHandler: ModelTypeHandler? = null
+
+ internal var modelName = "test-datatype"
+
+ private val log = EELFManager.getInstance().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/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.kt
new file mode 100644
index 000000000..b35a86b37
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/repository/ResourceDictionaryRepositoryTest.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.controllerblueprints.service.repository
+
+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.controllerblueprints.TestApplication
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
+import org.springframework.test.annotation.Commit
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@DataJpaTest
+@ContextConfiguration(classes = [TestApplication::class])
+@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-primary-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
+ @Commit
+ fun test05Delete() {
+ runBlocking {
+ 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
+ }
+} \ No newline at end of file