Add a position field to BaseResource
[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                 @JsonProperty("position") Integer position) {
63
64                 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
65                         position);
66                 this.productFamilyId = productFamilyId;
67                 this.platformName = platformName;
68                 this.lineOfBusiness = lineOfBusiness;
69                 this.vfModules = vfModules==null ? Collections.emptyMap() : vfModules;
70         }
71
72         public String getProductFamilyId() {
73                 return productFamilyId;
74         }
75
76         public String getPlatformName() {
77                 return platformName;
78         }
79
80         public String getLineOfBusiness() {
81                 return lineOfBusiness;
82         }
83
84         public  Map<String, Map<String, VfModule>> getVfModules() {
85                 return vfModules;
86         }
87
88         @Override
89         protected String getModelType() {
90                 return "vnf";
91         }
92
93         @Override
94         public Collection<BaseResource> getChildren() {
95                 return getVfModules().values().stream()
96                                 .filter(Objects::nonNull)
97                                 .flatMap(x->x.values().stream())
98                                 .collect(toList());
99         }
100
101         @Override
102         public JobType getJobType() {
103                 return JobType.VnfInstantiation;
104         }
105 }