Fix for Penetration test _ Session and cookie management
[vid.git] / vid-app-common / src / main / java / org / onap / vid / services / WorkflowServiceImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.vid.services;
22
23 import java.util.List;
24 import org.onap.vid.model.Workflow;
25 import org.springframework.stereotype.Service;
26
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.Collection;
30 import java.util.stream.Collectors;
31
32 @Service
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")))
41     );
42
43     @Override
44     public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) {
45         return workflows.stream()
46                 .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames))
47                 .map(Workflow::getWorkflowName)
48                 .distinct()
49                 .collect(Collectors.toList());
50     }
51
52     @Override
53     public Collection<String> getAllWorkflows() {
54         return workflows.stream()
55                 .map(Workflow::getWorkflowName)
56                 .distinct()
57                 .collect(Collectors.toList());
58     }
59 }