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, Network> networks;
64 private final Map<String, InstanceGroup> vnfGroups;
66 private final boolean isPause;
70 private final String testApi;
72 private final boolean isALaCarte;
74 private final VidNotions vidNotions;
75 private Map<String, VrfEntry> vrfs;
77 public ServiceInstantiation(@JsonProperty("modelInfo") ModelInfo modelInfo,
78 @JsonProperty("owningEntityId") String owningEntityId,
79 @JsonProperty("owningEntityName") String owningEntityName,
80 @JsonProperty("projectName") String projectName,
81 @JsonProperty("globalSubscriberId") String globalSubscriberId,
82 @JsonProperty("subscriberName") String subscriberName,
83 @JsonProperty("productFamilyId") String productFamilyId,
84 @JsonProperty("instanceName") String instanceName,
85 @JsonProperty("subscriptionServiceType") String subscriptionServiceType,
86 @JsonProperty("lcpCloudRegionId") String lcpCloudRegionId,
87 @JsonProperty("legacyRegion") String legacyRegion,
88 @JsonProperty("tenantId") String tenantId,
89 @JsonProperty("tenantName") String tenantName,
90 @JsonProperty("aicZoneId") String aicZoneId,
91 @JsonProperty("aicZoneName") String aicZoneName,
92 @JsonProperty("vnfs") Map<String, Vnf> vnfs,
93 @JsonProperty("networks") Map<String, Network> networks,
94 @JsonProperty("vnfGroups") Map<String, InstanceGroup> vnfGroups,
95 @JsonProperty("vrfs") Map<String, VrfEntry> vrfs,
96 @JsonProperty("instanceParams") List<Map<String, String>> instanceParams,
97 @JsonProperty("pause") boolean isPause,
98 @JsonProperty("bulkSize") int bulkSize,
99 @JsonProperty("rollbackOnFailure") boolean rollbackOnFailure,
100 @JsonProperty("isALaCarte") boolean isALaCarte,
101 @JsonProperty("testApi") String testApi,
102 @JsonProperty("instanceId") String instanceId,
103 @JsonProperty("action") String action,
104 @JsonProperty("trackById") String trackById,
105 @JsonProperty("isFailed") Boolean isFailed,
106 @JsonProperty("statusMessage") String statusMessage,
107 @JsonProperty("vidNotions") VidNotions vidNotions,
108 @JsonProperty("originalName") String originalName) {
109 super(modelInfo, instanceName, action, lcpCloudRegionId, legacyRegion, tenantId, instanceParams, rollbackOnFailure, instanceId, trackById, isFailed, statusMessage,
110 null, null, originalName);
111 this.owningEntityId = owningEntityId;
112 this.owningEntityName = owningEntityName;
113 this.projectName = projectName;
114 this.globalSubscriberId = globalSubscriberId;
115 this.subscriberName = subscriberName;
116 this.productFamilyId = productFamilyId;
117 this.subscriptionServiceType = subscriptionServiceType;
118 this.tenantName = tenantName;
119 this.aicZoneId = aicZoneId;
120 this.aicZoneName = aicZoneName;
122 this.networks = networks;
123 this.vnfGroups = vnfGroups;
125 this.isPause = isPause;
126 this.bulkSize = bulkSize;
127 this.isALaCarte = isALaCarte;
128 this.testApi = isALaCarte ? testApi : null;
129 this.vidNotions = vidNotions;
133 @JsonSerialize(using=BooleanAsStringSerializer.class)
134 public boolean isRollbackOnFailure() {
135 // this override is for the BooleanAsStringSerializer annotation,
136 // but for Service-Instance level only
137 return super.isRollbackOnFailure();
140 public String getOwningEntityId() {
141 return owningEntityId;
144 public String getOwningEntityName() {
145 return owningEntityName;
148 public String getProjectName() {
152 public String getGlobalSubscriberId() {
153 return globalSubscriberId;
156 public String getSubscriberName() {
157 return subscriberName;
160 public String getProductFamilyId() {
161 return productFamilyId;
164 public String getSubscriptionServiceType() {
165 return subscriptionServiceType;
168 public String getTenantName() {
172 public String getAicZoneId() {
176 public String getAicZoneName() {
180 public Map<String, Vnf> getVnfs() {
181 return emptyMapIfNull(vnfs);
184 public Map<String, Network> getNetworks() {
185 return emptyMapIfNull(networks);
188 public Map<String, InstanceGroup> getVnfGroups() {
189 return emptyMapIfNull(vnfGroups);
192 public Map<String, VrfEntry> getVrfs() {
193 return emptyMapIfNull(vrfs);
196 public boolean isPause() {
200 public int getBulkSize() { return bulkSize; }
202 public void setBulkSize(int bulkSize) {
203 this.bulkSize = bulkSize;
206 public VidNotions getVidNotions() {
211 protected String getModelType() {
216 public Collection<BaseResource> getChildren() {
217 return Stream.of(getNetworks().values(), getVnfs().values(), getVnfGroups().values()).flatMap(Collection::stream).collect(Collectors.toList());
220 @JsonProperty("isALaCarte")
221 public boolean isALaCarte() {
225 public String getTestApi() {
230 public JobType getJobType() {
231 return JobType.ALaCarteService;
234 private <T> Map<String, T> emptyMapIfNull(Map<String, T> map) {
235 return ObjectUtils.defaultIfNull(map, Collections.emptyMap());