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.model.serviceInstantiation;
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
29 import java.util.stream.Collectors;
30 import java.util.stream.Stream;
31 import org.apache.commons.lang3.ObjectUtils;
32 import org.onap.vid.job.JobAdapter;
33 import org.onap.vid.job.JobType;
34 import org.onap.vid.model.VidNotions;
35 import org.onap.vid.mso.model.ModelInfo;
36 import org.onap.vid.utils.jackson.BooleanAsStringSerializer;
38 public class ServiceInstantiation extends BaseResource implements JobAdapter.AsyncJobRequest {
40 private final String owningEntityId;
42 private final String owningEntityName;
44 private final String projectName;
46 private final String subscriberName;
48 private final String globalSubscriberId;
50 private final String productFamilyId;
52 private final String subscriptionServiceType;
54 private final String tenantName;
56 private final String aicZoneId;
58 private final String aicZoneName;
60 private final Map<String, Vnf> vnfs;
62 private final Map<String, Pnf> pnfs;
64 private final Map<String, Network> networks;
66 private final Map<String, InstanceGroup> vnfGroups;
68 private final boolean isPause;
72 private final String testApi;
74 private final boolean isALaCarte;
76 private final VidNotions vidNotions;
77 private Map<String, VrfEntry> vrfs;
79 public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo,
80 @JsonProperty("owningEntityId") String owningEntityId,
81 @JsonProperty("owningEntityName") String owningEntityName,
82 @JsonProperty("projectName") String projectName,
83 @JsonProperty("globalSubscriberId") String globalSubscriberId,
84 @JsonProperty("subscriberName") String subscriberName,
85 @JsonProperty("productFamilyId") String productFamilyId,
86 @JsonProperty("instanceName") String instanceName,
87 @JsonProperty("subscriptionServiceType") String subscriptionServiceType,
88 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
89 @JsonProperty("legacyRegion") String legacyRegion,
90 @JsonProperty("tenantId") String tenantId,
91 @JsonProperty("tenantName") String tenantName,
92 @JsonProperty("aicZoneId") String aicZoneId,
93 @JsonProperty("aicZoneName") String aicZoneName,
94 @JsonProperty("vnfs") Map<String, Vnf> vnfs,
95 @JsonProperty("pnfs") Map<String, Pnf> pnfs,
96 @JsonProperty("networks") Map<String, Network> networks,
97 @JsonProperty("vnfGroups") Map<String, InstanceGroup> vnfGroups,
98 @JsonProperty("vrfs") Map<String, VrfEntry> vrfs,
99 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
100 @JsonProperty("pause") boolean isPause,
101 @JsonProperty("bulkSize") int bulkSize,
102 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
103 @JsonProperty("isALaCarte") boolean isALaCarte,
104 @JsonProperty("testApi") String testApi,
105 @JsonProperty("instanceId") String instanceId,
106 @JsonProperty("action") String action,
107 @JsonProperty("trackById") String trackById,
108 @JsonProperty("isFailed") Boolean isFailed,
109 @JsonProperty("statusMessage") String statusMessage,
110 @JsonProperty("vidNotions") VidNotions vidNotions,
111 @JsonProperty("originalName") String originalName) {
112 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
113 null, null, originalName);
114 this.owningEntityId = owningEntityId;
115 this.owningEntityName = owningEntityName;
116 this.projectName = projectName;
117 this.globalSubscriberId = globalSubscriberId;
118 this.subscriberName = subscriberName;
119 this.productFamilyId = productFamilyId;
120 this.subscriptionServiceType = subscriptionServiceType;
121 this.tenantName = tenantName;
122 this.aicZoneId = aicZoneId;
123 this.aicZoneName = aicZoneName;
126 this.networks = networks;
127 this.vnfGroups = vnfGroups;
129 this.isPause = isPause;
130 this.bulkSize = bulkSize;
131 this.isALaCarte = isALaCarte;
132 this.testApi = isALaCarte ? testApi : null;
133 this.vidNotions = vidNotions;
137 @JsonSerialize(using=BooleanAsStringSerializer.class)
138 public boolean isRollbackOnFailure() {
139 // this override is for the BooleanAsStringSerializer annotation,
140 // but for Service-Instance level only
141 return super.isRollbackOnFailure();
144 public String getOwningEntityId() {
145 return owningEntityId;
148 public String getOwningEntityName() {
149 return owningEntityName;
152 public String getProjectName() {
156 public String getGlobalSubscriberId() {
157 return globalSubscriberId;
160 public String getSubscriberName() {
161 return subscriberName;
164 public String getProductFamilyId() {
165 return productFamilyId;
168 public String getSubscriptionServiceType() {
169 return subscriptionServiceType;
172 public String getTenantName() {
176 public String getAicZoneId() {
180 public String getAicZoneName() {
184 public Map<String, Vnf> getVnfs() {
185 return emptyMapIfNull(vnfs);
188 public Map<String, Pnf> getPnfs() {
189 return emptyMapIfNull(pnfs);
192 public Map<String, Network> getNetworks() {
193 return emptyMapIfNull(networks);
196 public Map<String, InstanceGroup> getVnfGroups() {
197 return emptyMapIfNull(vnfGroups);
200 public Map<String, VrfEntry> getVrfs() {
201 return emptyMapIfNull(vrfs);
204 public boolean isPause() {
208 public int getBulkSize() { return bulkSize; }
210 public void setBulkSize(int bulkSize) {
211 this.bulkSize = bulkSize;
214 public VidNotions getVidNotions() {
219 protected String getModelType() {
224 public Collection<BaseResource> getChildren() {
225 return Stream.of(getNetworks().values(), getVnfs().values(), getVnfGroups().values()).flatMap(Collection::stream).collect(Collectors.toList());
228 @JsonProperty("isALaCarte")
229 public boolean isALaCarte() {
233 public String getTestApi() {
238 public JobType getJobType() {
239 return JobType.ALaCarteService;
242 private <T> Map<String, T> emptyMapIfNull(Map<String, T> map) {
243 return ObjectUtils.defaultIfNull(map, Collections.emptyMap());