2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.vid.services;
22 import static java.util.Collections.emptyList;
24 import com.google.common.collect.ImmutableList;
25 import com.google.common.collect.ImmutableMap;
27 import org.onap.vid.model.LocalWorkflowParameterDefinition;
28 import org.onap.vid.model.LocalWorkflowParameterDefinitions;
29 import org.onap.vid.model.LocalWorkflowType;
30 import org.springframework.stereotype.Service;
33 public class LocalWorkflowsServiceImpl implements LocalWorkflowsService {
35 Map<String, LocalWorkflowParameterDefinitions> WORKFLOWS_WITH_PARAMETERS = ImmutableMap.<String, LocalWorkflowParameterDefinitions>builder()
36 .put("VNF Scale Out", new LocalWorkflowParameterDefinitions(
38 new LocalWorkflowParameterDefinition(1, "configurationParameters", "Configuration Parameters", true, LocalWorkflowType.text,".*")
41 .put("VNF In Place Software Update", new LocalWorkflowParameterDefinitions(
43 new LocalWorkflowParameterDefinition(2, "operationTimeout", "Operations timeout", true, LocalWorkflowType.text,"[0-9]+"),
44 new LocalWorkflowParameterDefinition(3, "existingSoftwareVersion", "Existing software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+"),
45 new LocalWorkflowParameterDefinition(4, "newSoftwareVersion", "New software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+")
47 )).put("PNF Software Upgrade", new LocalWorkflowParameterDefinitions(
49 new LocalWorkflowParameterDefinition(6, "targetSoftwareVersion", "Target software version", true, LocalWorkflowType.text, "[-a-zA-Z0-9.]+")
52 .put("VNF Config Update", new LocalWorkflowParameterDefinitions(
54 new LocalWorkflowParameterDefinition(5, "configUpdateFile", "Attach configuration file", true, LocalWorkflowType.FILE, ".*", "Invalid file type. Please select a file with a CSV extension.", "Invalid file structure.", ".csv")
60 private LocalWorkflowParameterDefinitions defaultEmptyParams() {
61 return new LocalWorkflowParameterDefinitions(emptyList());
65 public LocalWorkflowParameterDefinitions getWorkflowParameterDefinitions(String workflowName) {
66 return WORKFLOWS_WITH_PARAMETERS.getOrDefault(workflowName, defaultEmptyParams());