aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-03-21 14:01:50 +0100
committerWojciech Sliwka <wojciech.sliwka@nokia.com>2019-04-08 13:03:31 +0200
commit8e3b16a64b98b1774c4e2c2159e71668de2883c4 (patch)
tree87932d6e8d3162c28000c30af723dfd6cfcbb2cd /vid-app-common/src/main
parent56d27d6651babd9223ee8e3a3deddda9d702dcd1 (diff)
align logic to new so api
Change-Id: Ic1a975eb6d3d9487fc2e006d2f171fa044806ef3 Issue-ID: VID-400 Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java5
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/SOWorkflows.kt60
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java74
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java3
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java72
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java6
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java70
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js127
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js68
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html2
14 files changed, 308 insertions, 196 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
index a472268a3..a82dfab75 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoConfig.java
@@ -30,7 +30,6 @@ import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoBusinessLogicImpl;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
import org.onap.vid.mso.rest.MsoRestClientNew;
import org.onap.vid.services.CloudOwnerService;
import org.onap.vid.services.CloudOwnerServiceImpl;
@@ -54,10 +53,6 @@ public class MsoConfig {
MsoProperties.MSO_SERVER_URL),httpsAuthClient);
}
- @Bean
- public MockedWorkflowsRestClient mockedWorkflowsClient(ObjectMapper unirestObjectMapper){
- return new MockedWorkflowsRestClient(new SyncRestClient(unirestObjectMapper), "http://vid-simulator:1080/");
- }
@Bean
public MsoBusinessLogic getMsoBusinessLogic(MsoInterface msoClient, FeatureManager featureManager){
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
index a6ad92321..1d0ff95bc 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/WorkflowsController.java
@@ -62,10 +62,6 @@ public class WorkflowsController extends VidRestrictedBaseController {
return externalWorkflowsService.getWorkflows(vnfModelId);
}
- @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET)
- SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) {
- return externalWorkflowsService.getWorkflowParameterDefinitions(id);
- }
@RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
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 b88c3f6f6..00cc7b943 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
@@ -20,9 +20,18 @@
package org.onap.vid.model
+import com.google.common.collect.Lists
+
+enum class WorkflowSource(val source: String) {
+ SDC("sdc"), NATIVE("native")
+}
+
data class SOWorkflow constructor(
- val id: Long,
- val name: String) {
+ val id: String,
+ val name: String,
+ val source: WorkflowSource,
+ val workflowInputParameters: List<WorkflowInputParameter>
+) {
fun clone(): SOWorkflow {
return copy()
}
@@ -79,3 +88,50 @@ data class LocalWorkflowParameterDefinitions constructor(
}
}
+
+data class ArtifactInfo constructor(
+ val artifactType: String,
+ val artifactUuid: String,
+ val artifactName: String,
+ val artifactVersion: String,
+ val artifactDescription: String? = null,
+ val workflowName: String,
+ val operationName: String? = null,
+ val workflowSource: String,
+ val workflowResourceTarget: String
+)
+
+data class ActivitySequenceItem constructor(
+ val name: String,
+ val description: String
+)
+
+data class WorkflowInputParameter constructor(
+ val label: String,
+ val inputType: String,
+ val required: Boolean,
+ val validation: List<InputParameterValidation>? = Lists.newArrayList(),
+ val soFieldName: String,
+ val soPayloadLocation: String?,
+ val description: String?
+
+)
+
+data class InputParameterValidation constructor(
+ val maxLength: String?,
+ val allowableChars: String?
+)
+
+data class WorkflowSpecification constructor(
+ val artifactInfo: ArtifactInfo,
+ val activitySequence: List<ActivitySequenceItem>? = Lists.newArrayList(),
+ val workflowInputParameters: List<WorkflowInputParameter>
+)
+
+data class WorkflowSpecificationWrapper constructor(
+ val workflowSpecification: WorkflowSpecification
+)
+
+data class SOWorkflowList constructor(
+ val workflowSpecificationList: List<WorkflowSpecificationWrapper>? = Lists.newArrayList()
+)
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
index 1ff30f03c..3b2cdb1bf 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogic.java
@@ -3,6 +3,7 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright 2019 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@ package org.onap.vid.mso;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.controller.OperationalEnvironmentController;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
@@ -138,4 +140,5 @@ public interface MsoBusinessLogic {
MsoResponseWrapper2 activateFabricConfiguration(String serviceInstanceId, RequestDetails requestDetails);
+ SOWorkflowList getWorkflowListByModelId(String modelVersionId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index ad07eacae..64c405a39 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -8,9 +8,9 @@
* 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.
@@ -26,26 +26,44 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import io.joshworks.restclient.http.HttpResponse;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.ChangeManagementRequest;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.changeManagement.UIWorkflowsRequest;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
-import org.onap.vid.controller.ControllersUtils;
import org.onap.vid.controller.OperationalEnvironmentController;
import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.model.SoftDeleteRequest;
-import org.onap.vid.mso.model.*;
+import org.onap.vid.mso.model.CloudConfiguration;
+import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentActivateInfo;
+import org.onap.vid.mso.model.OperationalEnvironmentDeactivateInfo;
+import org.onap.vid.mso.model.RequestInfo;
+import org.onap.vid.mso.model.RequestParameters;
import org.onap.vid.mso.rest.OperationalEnvironment.OperationEnvironmentRequestDetails;
-import org.onap.vid.mso.rest.*;
+import org.onap.vid.mso.rest.RelatedInstance;
+import org.onap.vid.mso.rest.Request;
+import org.onap.vid.mso.rest.RequestDetails;
+import org.onap.vid.mso.rest.RequestList;
+import org.onap.vid.mso.rest.RequestWrapper;
+import org.onap.vid.mso.rest.Task;
+import org.onap.vid.mso.rest.TaskList;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
import org.togglz.core.manager.FeatureManager;
import javax.ws.rs.BadRequestException;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -54,8 +72,16 @@ import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;
import static org.apache.commons.lang.StringUtils.upperCase;
import static org.onap.vid.changeManagement.ChangeManagementRequest.MsoChangeManagementRequest;
-import static org.onap.vid.controller.MsoController.*;
-import static org.onap.vid.mso.MsoProperties.*;
+import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
+import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
+import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
+import static org.onap.vid.controller.MsoController.WORKFLOW_ID;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_CLOUD_RESOURCES_REQUEST_STATUS;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_ACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_CREATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_OPERATIONAL_ENVIRONMENT_DEACTIVATE;
+import static org.onap.vid.mso.MsoProperties.MSO_REST_API_WORKFLOW_SPECIFICATIONS;
import static org.onap.vid.properties.Features.FLAG_UNASSIGN_SERVICE;
import static org.onap.vid.utils.Logging.debugRequestDetails;
@@ -97,7 +123,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
this.featureManager = featureManager;
}
- public static String validateEndpointPath(String endpointEnvVariable) {
+ public static String validateEndpointPath(String endpointEnvVariable) {
String endpoint = SystemProperties.getProperty(endpointEnvVariable);
if (endpoint == null || endpoint.isEmpty()) {
throw new GenericUncheckedException(endpointEnvVariable + " env variable is not defined");
@@ -404,7 +430,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
}
}
- private List<Task> deserializeManualTasksJson(String manualTasksJson) {
+ private List<Task> deserializeManualTasksJson(String manualTasksJson) {
logInvocationInDebug("deserializeManualTasksJson");
ObjectMapper mapper = new ObjectMapper();
@@ -558,6 +584,20 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
return new MsoResponseWrapper2<>(msoClientInterface.post(path, new RequestDetailsWrapper<>(requestDetails), RequestReferencesContainer.class));
}
+ @Override
+ public SOWorkflowList getWorkflowListByModelId(String modelVersionId) {
+ logInvocationInDebug("getWorkflowListByModelId");
+ String pathTemplate = validateEndpointPath(MSO_REST_API_WORKFLOW_SPECIFICATIONS);
+ String path = pathTemplate.replaceFirst("<model_version_id>", modelVersionId);
+
+ HttpResponse<SOWorkflowList> workflowListByModelId = msoClientInterface.getWorkflowListByModelId(path);
+ if (!isSuccessful(workflowListByModelId)) {
+ logger.error(EELFLoggerDelegate.errorLogger, workflowListByModelId.getStatusText());
+ throw new WorkflowListException(String.format("Get worklflow list for id: %s failed due to %s", modelVersionId, workflowListByModelId.getStatusText()));
+ }
+ return workflowListByModelId.getBody();
+ }
+
@Override
public MsoResponseWrapperInterface updateVnfSoftware(org.onap.vid.changeManagement.RequestDetails requestDetails, String serviceInstanceId, String vnfInstanceId) {
@@ -842,6 +882,18 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
}
+ private boolean isSuccessful(HttpResponse<SOWorkflowList> workflowListByModelId) {
+ int status = workflowListByModelId.getStatus();
+ return HttpStatus.OK.value() == status || HttpStatus.ACCEPTED.value() == status;
+ }
+
+ static class WorkflowListException extends RuntimeException{
+
+ WorkflowListException(String message) {
+ super(message);
+ }
+ }
+
enum RequestType {
CREATE_INSTANCE("createInstance"),
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 904ba13e4..9befc0f90 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -22,6 +22,7 @@ package org.onap.vid.mso;
import io.joshworks.restclient.http.HttpResponse;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.mso.rest.RequestDetails;
@@ -114,6 +115,8 @@ public interface MsoInterface {
MsoResponseWrapper addRelationshipToServiceInstance(RequestDetails requestDetails, String addRelationshipsPath);
+ HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint);
+
MsoResponseWrapper invokeWorkflow(WorkflowRequestDetail requestDetails,String invokeWorkflowsPath, Map<String, String> extraHeaders);
<T> HttpResponse<T> get(String path, Class<T> responseClass);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
index 47cb95f2f..4e6258c16 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoProperties.java
@@ -125,4 +125,6 @@ public class MsoProperties extends SystemProperties {
/** The Constant MSO_REST_API_SERVICE_INSTANCE_ASSIGN */
public static final String MSO_REST_API_SERVICE_INSTANCE_ASSIGN = "mso.restapi.serviceInstanceAssign";
+
+ public static final String MSO_REST_API_WORKFLOW_SPECIFICATIONS= "mso.restapi.changeManagement.workflowSpecifications";
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
deleted file mode 100644
index 54ee6464f..000000000
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MockedWorkflowsRestClient.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.vid.mso.rest;
-
-import java.util.Collections;
-import org.jetbrains.annotations.NotNull;
-import org.onap.vid.client.SyncRestClient;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-
-public class MockedWorkflowsRestClient {
-
- private SyncRestClient syncRestClient;
- private String baseUrl;
-
- public MockedWorkflowsRestClient(SyncRestClient syncRestClient, String baseUrl) {
- this.syncRestClient = syncRestClient;
- this.baseUrl = baseUrl;
- }
-
- public MsoResponseWrapper2<SOWorkflows> getWorkflows(String vnfName) {
- // Temporary skip vnfName and call mocked service
- return new MsoResponseWrapper2<>(syncRestClient
- .get(getWorkflowsUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflows.class));
- }
-
- public MsoResponseWrapper2<SOWorkflowParameterDefinitions> getWorkflowParameterDefinitions(Long workflowId) {
- return new MsoResponseWrapper2<>(syncRestClient
- .get((workflowId <= 3 && workflowId > 0) ? getParametersUrl(workflowId) : getParametersUrl(),
- Collections.emptyMap(),
- Collections.emptyMap(),
- SOWorkflowParameterDefinitions.class));
- }
-
- @NotNull
- private String getWorkflowsUrl() {
- return baseUrl + "so/workflows";
- }
-
-
- @NotNull
- private String getParametersUrl() {
- return baseUrl + "so/workflow-parameters";
- }
-
- @NotNull
- private String getParametersUrl(Long workflowId) {
- return baseUrl + "so/workflow-parameters/" + workflowId;
- }
-}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index ff7acffcf..0c05b80e2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -21,6 +21,7 @@
package org.onap.vid.mso.rest;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
import io.joshworks.restclient.http.HttpResponse;
import io.joshworks.restclient.http.JsonNode;
import java.text.DateFormat;
@@ -40,6 +41,7 @@ import org.onap.vid.changeManagement.RequestDetailsWrapper;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.RequestReferencesContainer;
+import org.onap.vid.model.SOWorkflowList;
import org.onap.vid.mso.MsoInterface;
import org.onap.vid.mso.MsoProperties;
import org.onap.vid.mso.MsoResponseWrapper;
@@ -473,6 +475,12 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
+ public HttpResponse<SOWorkflowList> getWorkflowListByModelId(String endpoint){
+ String path = baseUrl + endpoint;
+
+ return client.get(path, commonHeaders, Maps.newHashMap(), SOWorkflowList.class);
+ }
+
private MsoResponseWrapper createInstance(Object request, String path) {
String methodName = "createInstance";
logger.debug(methodName + START);
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
index 2eae52f4f..4620eed34 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +22,8 @@ package org.onap.vid.services;
import java.util.List;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
+
public interface ExternalWorkflowsService {
List<SOWorkflow> getWorkflows(String vnfModelId);
-
- SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId);
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
index e03b5463a..0648b6ac9 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/ExternalWorkflowsServiceImpl.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
* ================================================================================
* 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.
@@ -20,60 +20,48 @@
package org.onap.vid.services;
-import java.util.List;
+import org.onap.vid.model.ArtifactInfo;
import org.onap.vid.model.SOWorkflow;
-import org.onap.vid.model.SOWorkflowParameterDefinitions;
-import org.onap.vid.model.SOWorkflows;
-import org.onap.vid.mso.MsoResponseWrapper2;
-import org.onap.vid.mso.rest.MockedWorkflowsRestClient;
+import org.onap.vid.model.SOWorkflowList;
+import org.onap.vid.model.WorkflowSource;
+import org.onap.vid.model.WorkflowSpecification;
+import org.onap.vid.mso.MsoBusinessLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
@Service
public class ExternalWorkflowsServiceImpl implements ExternalWorkflowsService {
- private MockedWorkflowsRestClient mockedWorkflowsRestClient;
+ private MsoBusinessLogic msoService;
@Autowired
- public ExternalWorkflowsServiceImpl(MockedWorkflowsRestClient mockedWorkflowsRestClient) {
- this.mockedWorkflowsRestClient = mockedWorkflowsRestClient;
+ public ExternalWorkflowsServiceImpl(MsoBusinessLogic msoService) {
+ this.msoService = msoService;
}
@Override
public List<SOWorkflow> getWorkflows(String vnfModelId) {
- MsoResponseWrapper2<SOWorkflows> msoResponse = mockedWorkflowsRestClient.getWorkflows(vnfModelId);
- validateSOResponse(msoResponse, SOWorkflows.class);
- return convertMsoResponseToWorkflowList(msoResponse);
- }
+ SOWorkflowList workflowListByModelId = msoService.getWorkflowListByModelId(vnfModelId);
+ List<SOWorkflow> soWorkflows = new ArrayList<>();
+ Objects.requireNonNull(workflowListByModelId
+ .getWorkflowSpecificationList())
+ .forEach(
+ workflow -> soWorkflows.add(convertWorkflow(workflow.getWorkflowSpecification()))
+ );
- @Override
- public SOWorkflowParameterDefinitions getWorkflowParameterDefinitions(Long workflowId) {
- MsoResponseWrapper2<SOWorkflowParameterDefinitions> msoResponse = mockedWorkflowsRestClient.getWorkflowParameterDefinitions(workflowId);
- validateSOResponse(msoResponse, SOWorkflowParameterDefinitions.class);
- return (SOWorkflowParameterDefinitions) msoResponse.getEntity();
+ return soWorkflows;
}
- private List<SOWorkflow> convertMsoResponseToWorkflowList(MsoResponseWrapper2<SOWorkflows> msoResponse) {
- SOWorkflows soWorkflows = (SOWorkflows) msoResponse.getEntity();
- return soWorkflows.getWorkflows();
- }
+ private SOWorkflow convertWorkflow(WorkflowSpecification workflow) {
+ ArtifactInfo artifactInfo = workflow.getArtifactInfo();
- private void validateSOResponse(MsoResponseWrapper2 response, Class<?> expectedResponseClass){
- if (response.getStatus() >= 400 || !expectedResponseClass.isInstance(response.getEntity())) {
- throw new BadResponseFromMso(response);
- }
+ return new SOWorkflow(artifactInfo.getArtifactUuid(),
+ artifactInfo.getWorkflowName(),
+ WorkflowSource.valueOf(artifactInfo.getWorkflowSource().toUpperCase()),
+ workflow.getWorkflowInputParameters());
}
-
- public static class BadResponseFromMso extends RuntimeException {
- private final MsoResponseWrapper2<?> msoResponse;
-
- BadResponseFromMso(MsoResponseWrapper2<?> msoResponse) {
- this.msoResponse = msoResponse;
- }
-
- public MsoResponseWrapper2<?> getMsoResponse() {
- return msoResponse;
- }
- }
-
}
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 f8202fbf2..246834cdd 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
@@ -390,11 +390,9 @@
workflowParameters.requestDetails.cloudConfiguration = vm.changeManagement.vnfNames[0].cloudConfiguration;
let parameters = vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow);
- let i = 1;
parameters.forEach((parameter)=>{
- let inputField = document.getElementById('so-workflow-parameter-'+i);
- i++;
- workflowParameters.requestDetails.requestParameters.userParams[0][parameter.name]=inputField.value;
+ let inputField = document.getElementById('so-workflow-parameter-'+parameter.soFieldName);
+ workflowParameters.requestDetails.requestParameters.userParams[0][parameter.soFieldName]=inputField.value;
});
return workflowParameters;
@@ -402,40 +400,60 @@
vm.openModal = function () {
if(vm.hasScheduler) { //scheduling supported
- $scope.widgetParameter = ""; // needed by the scheduler?
-
- // properties needed by the scheduler so it knows whether to show
- // policy or sniro related features on the scheduler UI or not.
- vm.changeManagement.policyYN = "Y";
- vm.changeManagement.sniroYN = "Y";
-
- if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
- vm.changeManagement.testApi = DataService.getMsoRequestParametersTestApi();
- }
- var data = {
- widgetName: 'Portal-Common-Scheduler',
- widgetData: vm.changeManagement,
- widgetParameter: $scope.widgetParameter
- };
-
- window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ vm.scheduleWorkflow();
} else {
- //no scheduling support
- var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement);
- if(dataToSo) {
- var vnfName = vm.changeManagement.vnfNames[0].name;
- changeManagementService.postChangeManagementNow(dataToSo, vnfName);
- }
+ //no scheduling support
+ vm.executeWorkflow();
+ }
+ };
+
+ vm.scheduleWorkflow = function () {
+ $scope.widgetParameter = ""; // needed by the scheduler?
+
+ // properties needed by the scheduler so it knows whether to show
+ // policy or sniro related features on the scheduler UI or not.
+ vm.changeManagement.policyYN = "Y";
+ vm.changeManagement.sniroYN = "Y";
+
+ if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_ADD_MSO_TESTAPI_FIELD)) {
+ vm.changeManagement.testApi = DataService.getMsoRequestParametersTestApi();
+ }
+ var data = {
+ widgetName: 'Portal-Common-Scheduler',
+ widgetData: vm.changeManagement,
+ widgetParameter: $scope.widgetParameter
+ };
+
+ window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ };
+ vm.executeWorkflow = function () {
+ if (vm.localWorkflows && vm.localWorkflows.length > 0) {
+ vm.triggerLocalWorkflow();
+ } else {
+ vm.triggerRemoteWorkflow();
+ }
+ };
+
+ vm.triggerLocalWorkflow = function () {
+ var dataToSo = extractChangeManagementCallbackDataStr(vm.changeManagement);
+ if (dataToSo) {
+ var vnfName = vm.changeManagement.vnfNames[0].name;
+ changeManagementService.postChangeManagementNow(dataToSo, vnfName);
+ }
+ };
+
+ vm.triggerRemoteWorkflow = function () {
+ let cachedWorkflowDetails = vm.getCachedWorkflowDetails(vm.changeManagement.workflow);
+ if (cachedWorkflowDetails.length > 0) {
let workflowParameters = getWorkflowParametersFromForm();
- if(workflowParameters){
+ if (workflowParameters) {
let servieInstanceId = vm.changeManagement.vnfNames[0]['service-instance-node'][0].properties['service-instance-id'];
let vnfInstanceId = vm.changeManagement.vnfNames[0].id;
- let workflow_UUID = vm.changeManagement.fromVNFVersion;
-
- changeManagementService.postWorkflowsParametersNow(servieInstanceId,vnfInstanceId,workflow_UUID,workflowParameters);
+ let workflow_UUID = cachedWorkflowDetails[0].id;
+ changeManagementService.postWorkflowsParametersNow(servieInstanceId, vnfInstanceId, workflow_UUID, workflowParameters);
}
- }
+ }
};
vm.loadSubscribers = function () {
@@ -728,13 +746,37 @@
};
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);
- });
+ let parameters = [];
+ workflow.workflowInputParameters
+ .filter( function (param) {
+ return param.soPayloadLocation === "userParams"
+ })
+ .forEach(function (param) {
+ let workflowParams = vm.repackAttributes(param);
+ if (param.validation.length > 0) {
+ let validation = param.validation[0];
+ if ('maxLength' in validation) {
+ workflowParams.maxLength = validation.maxLength;
+ }
+ if ('allowableChars' in validation) {
+ workflowParams.pattern = validation.allowableChars;
+ }
+ }
+ parameters.push(workflowParams);
+ }
+ );
+ vm.remoteWorkflowsParameters.set(workflow.name, parameters);
+ };
+
+ vm.repackAttributes = function (workflowParam){
+ return {
+ name: workflowParam.label,
+ required: workflowParam.required,
+ id: workflowParam.soFieldName,
+ soFieldName: workflowParam.soFieldName,
+ maxLength: '500',
+ pattern: '.*'
+ }
};
vm.getRemoteWorkFlowParameters = function (workflow) {
@@ -757,6 +799,13 @@
}
};
+ vm.getCachedWorkflowDetails = function (workflow) {
+ return vm.remoteWorkflows.filter( function (remoteWorkflow) {
+ return remoteWorkflow.name === workflow;
+ });
+
+ };
+
//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) {
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 9810c0013..5989ffdd6 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
@@ -100,32 +100,59 @@ describe('Testing workFlows from SO', () => {
}
],
}});
- let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]});
- let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data":[{
- $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ "id": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "name": "inPlaceSoftwareUpdate",
+ "source": "sdc",
+ "workflowInputParameters": [
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams",
+ "validation":[]
+ }
+ ]
+ }]
+ });
+
+ $controller.changeManagement.vnfNames = [{modelVersionId: 'test1', name:'test'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
- $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub;
// when
return $controller.loadWorkFlows().then(() => {
- expect($controller.workflows).toContain('workflow 1');
- expect($controller.workflows).toContain('workflow 2');
+ expect($controller.workflows).toContain('inPlaceSoftwareUpdate');
+ expect($controller.localWorkflowsParameters).toBeUndefined();
});
});
- test('Verify load workflows will call load workflows parameters from SO', () => {
+ test('Verify load workflows will set workflows and parameters', () => {
// given
let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}});
let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}});
- 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]*"}]}});
+ let getSOWorkflowsPromiseStub = Promise.resolve({"data":[{
- $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}];
+ "id": "ab6478e4-ea33-3346-ac12-ab121484a333",
+ "workflowName": "inPlaceSoftwareUpdate",
+ "name": "inPlaceSoftwareUpdate",
+ "source": "sdc",
+ "workflowInputParameters": [
+ {
+ "label": "New Software Version",
+ "inputType": "text",
+ "required": true,
+ "soFieldName": "new_software_version",
+ "soPayloadLocation": "userParams",
+ "validation":[]
+ }
+ ]
+ }]
+ });
+ $controller.changeManagement.vnfNames = [{modelVersionId: 'test1', name:'test'}];
$changeManagementService.getWorkflows = () => getWorkflowsStub;
$changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
$changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub;
@@ -133,10 +160,17 @@ describe('Testing workFlows from SO', () => {
// 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"}]]]));
+ expect($controller.workflows).toEqual(["inPlaceSoftwareUpdate"]);
+ expect($controller.remoteWorkflowsParameters).toEqual(new Map([["inPlaceSoftwareUpdate",
+ [{
+ "name": "New Software Version",
+ "required": true,
+ "id": "new_software_version",
+ "soFieldName": "new_software_version",
+ "maxLength": '500',
+ "pattern": '.*'
+ }]]
+ ]));
});
});
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 9fb978c42..a5a6d1610 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
@@ -97,7 +97,7 @@
<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 ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}">
+ <input ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" maxlength="{{item.maxLength}}" ng-required="{{item.required}}" soFieldName="{{item.soFieldName}}">
</div>
</div>