summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt19
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js1
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js41
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js27
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html5
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js7
7 files changed, 86 insertions, 17 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
index 8fe7c1fa1..2456ebd0f 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WebConfig.java
@@ -22,6 +22,7 @@
package org.onap.vid.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.module.kotlin.KotlinModule;
import io.joshworks.restclient.http.mapper.ObjectMapper;
import org.onap.vid.aai.*;
import org.onap.vid.aai.model.PortDetailsTranslator;
@@ -55,7 +56,7 @@ public class WebConfig {
*/
@Bean
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() {
- return new com.fasterxml.jackson.databind.ObjectMapper();
+ return new com.fasterxml.jackson.databind.ObjectMapper().registerModule(new KotlinModule());
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
index 25125cea6..82c720eed 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt
@@ -1,21 +1,26 @@
package org.onap.vid.model
-data class SOWorkflow @JvmOverloads constructor(var id: Long? = null, var name: String? = null) {
+data class SOWorkflow constructor(val id: Long, val name: String) {
fun clone(): SOWorkflow {
return copy()
}
}
-data class SOWorkflows @JvmOverloads constructor(var workflows: List<SOWorkflow>? = emptyList()) {
+data class SOWorkflows @JvmOverloads constructor(val workflows: List<SOWorkflow> = emptyList()) {
fun clone(): SOWorkflows {
- return copy(workflows?.toMutableList())
+ return copy(workflows.toMutableList())
}
}
-
-enum class SOWorkflowType(var type: String? = "STRING") {
+enum class SOWorkflowType(val type: String) {
STRING("STRING")
}
-data class SOWorkflowParameterDefinition(var id: Long? = null, var name: String? = null, var pattern: String? = null, var type: SOWorkflowType? = null, val required: Boolean? = null)
-data class SOWorkflowParameterDefinitions(var parameterDefinitions: List<SOWorkflowParameterDefinition>? = null) \ No newline at end of file
+data class SOWorkflowParameterDefinition constructor(val id: Long, val name: String, val pattern: String,
+ val type: SOWorkflowType, val required: Boolean)
+
+data class SOWorkflowParameterDefinitions constructor(val parameterDefinitions: List<SOWorkflowParameterDefinition> = emptyList()) {
+ fun clone(): SOWorkflowParameterDefinitions {
+ return copy(parameterDefinitions.toMutableList())
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
index 8ee2d062c..dff51ee2b 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js
@@ -116,6 +116,7 @@ appDS2
CHANGE_MANAGEMENT_OPERATION_NO_SCHEDULER: "change-management/workflow/@vnfName",
GET_WORKFLOW: "change-management/get_vnf_workflow_relation",
GET_SO_WORKFLOWS: "workflows-management/workflows",
+ GET_SO_WORKFLOW_PARAMETER: "workflows-management/workflow-parameters/@workflowID",
GET_MSO_WORKFLOWS: "change-management/mso",
GET_SCHEDULER_CHANGE_MANAGEMENTS: "change-management/scheduler",
CANCEL_SCHEDULE_REQUEST: "change-management/scheduler/schedules",
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index 11f5cd6e5..c85f0fc55 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -43,6 +43,7 @@
var init = function () {
vm.changeManagement = {};
+ vm.changeManagement.workflowParameters = new Map();
loadServicesCatalog();
fetchAttUid().then(registerVNFNamesWatcher);
@@ -619,11 +620,13 @@
vm.loadWorkFlows = function () {
// Should be corrected when VID-397 will be closed. At the moment there is a need
// to merge local and remote workflows not to broke current functionality.
- return vm.loadLocalWorkFlows()
- .then(vm.loadRemoteWorkFlows)
- .then(function () {
- vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name));
- });
+ return vm.loadLocalWorkFlows()
+ .then(vm.loadRemoteWorkFlows)
+ .then(function () {
+ vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name));
+ }).then(function () {
+ vm.loadRemoteWorkFlowsParameters();
+ });
};
vm.loadLocalWorkFlows = function () {
@@ -645,6 +648,30 @@
});
};
+ vm.loadRemoteWorkFlowsParameters = function () {
+ vm.remoteWorkflowsParameters = new Map();
+ vm.remoteWorkflows.forEach(function(workflow) {
+ vm.loadRemoteWorkFlowParameters(workflow);
+ });
+ };
+
+ vm.loadRemoteWorkFlowParameters = function (workflow) {
+ changeManagementService.getSOWorkflowParameter(workflow.id)
+ .then(function (response) {
+ vm.remoteWorkflowsParameters.set(workflow.name, response.data.parameterDefinitions);
+ })
+ .catch(function (error) {
+ $log.error(error);
+ });
+ };
+
+ vm.getRemoteWorkFlowParameters = function (workflow) {
+ if (workflow && vm.remoteWorkflowsParameters.has(workflow)) {
+ return vm.remoteWorkflowsParameters.get(workflow)
+ }
+ return [];
+ };
+
//Must be $scope because we bind to the onchange of the html (cannot attached to vm variable).
$scope.selectFileForVNFName = function (fileInput) {
if (fileInput && fileInput.id) {
@@ -669,11 +696,11 @@
vm.isConfigUpdate = function () {
return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfConfigUpdate;
- }
+ };
vm.isScaleOut = function () {
return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfScaleOut;
- }
+ };
vm.shouldShowVnfInPlaceFields = function () {
return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfInPlace;
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
index c4b940641..7f21ddaf5 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js
@@ -50,7 +50,7 @@ describe('Testing workFlows from SO', () => {
// when
return $controller.loadRemoteWorkFlows()
.then(() => {
- remoteWorkflows = $controller.remoteWorkflows.map(item => item.name)
+ remoteWorkflows = $controller.remoteWorkflows.map(item => item.name);
expect(remoteWorkflows).toContain('workflow 1');
expect(remoteWorkflows).toContain('workflow 2');
}
@@ -61,10 +61,12 @@ describe('Testing workFlows from SO', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]});
+ let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}});
$controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
+ $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows().then(() => {
expect($controller.workflows).toContain('workflow 0');
@@ -73,6 +75,29 @@ describe('Testing workFlows from SO', () => {
});
});
+ test('Verify load workflows will call load workflows parameters from SO', () => {
+ // given
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]});
+ let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [
+ {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"},
+ {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"},
+ {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
+ $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ expect($controller.remoteWorkflowsParameters).toEqual(new Map([["workflow 0",
+ [{"id": 1, "name": "parameter 1", "pattern": "[0-9]*", "required": true, "type": "STRING"},
+ {"id": 2, "name": "parameter 2", "pattern": ".*", "required": true, "type": "STRING"},
+ {"id": 3, "name": "parameter 3", "pattern": "[0-9]*", "required": false, "type": "STRING"}]]]));
+ });
+ });
+
test('Verify broken SO workflows wont change content of local workflows', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
index 21f9c5d3f..f83a267dc 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html
@@ -86,7 +86,10 @@
<label class="control-label">New software version</label>
<input class="form-control" ng-model="vm.changeManagement.newSoftwareVersion" name="newSoftwareVersion" type="text" id="new-software-version" pattern="{{vm.softwareVersionRegex}}" required>
</div>
-
+ </div>
+ <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow)">
+ <label for="so-workflow-parameter-{{item.id}}" class="control-label">{{item.name}}</label>
+ <input class="form-control" ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
</div>
</div>
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
index 699868477..38b85f973 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js
@@ -30,6 +30,13 @@
});
};
+ this.getSOWorkflowParameter = function (workflowID){
+ return $http.get(COMPONENT.GET_SO_WORKFLOW_PARAMETER.replace('@workflowID', workflowID))
+ .success(function (response) {
+ return {data: response.parameterDefinitions}
+ });
+ };
+
this.getMSOChangeManagements = function() {
var deferred = $q.defer();