2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T 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=========================================================
21 package org.onap.vid.services;
23 import java.util.List;
24 import org.onap.vid.model.Workflow;
25 import org.springframework.stereotype.Service;
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.Collection;
30 import java.util.stream.Collectors;
33 public class WorkflowServiceImpl implements WorkflowService {
34 //TODO: Add the list of workflows hard coded or from DB.
35 private List<Workflow> workflows = Arrays.asList(
36 new Workflow(0, "Upgrade", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3", "VNF4"))),
37 new Workflow(1, "Clean", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3"))),
38 new Workflow(2, "Reinstall", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF4"))),
39 new Workflow(3, "Dump", new ArrayList<>(Arrays.asList("VNF1", "VNF3", "VNF4"))),
40 new Workflow(4, "Flush", new ArrayList<>(Arrays.asList("VNF2", "VNF3", "VNF4")))
44 public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) {
45 return workflows.stream()
46 .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames))
47 .map(Workflow::getWorkflowName)
49 .collect(Collectors.toList());
53 public Collection<String> getAllWorkflows() {
54 return workflows.stream()
55 .map(Workflow::getWorkflowName)
57 .collect(Collectors.toList());