Implant vid-app-common org.onap.vid.job (main and test)
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / serviceInstantiation / Vnf.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 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.model.serviceInstantiation;
22
23
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import org.onap.vid.job.JobAdapter;
26 import org.onap.vid.job.JobType;
27 import org.onap.vid.mso.model.ModelInfo;
28
29 import java.util.*;
30
31 import static java.util.stream.Collectors.toList;
32
33 /**
34  * The Class VNF.
35  */
36 public class Vnf extends BaseResource implements JobAdapter.AsyncJobRequest {
37
38         private final String productFamilyId;
39
40         private final String platformName;
41
42         private final String lineOfBusiness;
43
44         private final Map<String, Map<String, VfModule>> vfModules;
45
46         public Vnf(@JsonProperty("modelInfo") ModelInfo modelInfo,
47                            @JsonProperty("productFamilyId") String productFamilyId,
48                            @JsonProperty("instanceName") String instanceName,
49                            @JsonProperty("action") String action,
50                            @JsonProperty("platformName") String platformName,
51                            @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
52                            @JsonProperty("legacyRegion") String legacyRegion,
53                            @JsonProperty("tenantId") String tenantId,
54                            @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
55                            @JsonProperty("lineOfBusinessName") String lineOfBusiness,
56                            @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
57                            @JsonProperty("instanceId") String instanceId,
58                            @JsonProperty("vfModules") Map<String, Map<String, VfModule>> vfModules,
59                            @JsonProperty("trackById") String trackById,
60                            @JsonProperty("isFailed") Boolean isFailed,
61                            @JsonProperty("statusMessage") String statusMessage) {
62
63                 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage);
64                 this.productFamilyId = productFamilyId;
65                 this.platformName = platformName;
66                 this.lineOfBusiness = lineOfBusiness;
67                 this.vfModules = vfModules==null ? Collections.emptyMap() : vfModules;
68         }
69
70         public String getProductFamilyId() {
71                 return productFamilyId;
72         }
73
74         public String getPlatformName() {
75                 return platformName;
76         }
77
78         public String getLineOfBusiness() {
79                 return lineOfBusiness;
80         }
81
82         public  Map<String, Map<String, VfModule>> getVfModules() {
83                 return vfModules;
84         }
85
86         @Override
87         protected String getModelType() {
88                 return "vnf";
89         }
90
91         @Override
92         public Collection<BaseResource> getChildren() {
93                 return getVfModules().values().stream()
94                                 .filter(Objects::nonNull)
95                                 .flatMap(x->x.values().stream())
96                                 .collect(toList());
97         }
98
99         @Override
100         public JobType getJobType() {
101                 return JobType.VnfInstantiation;
102         }
103 }