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