2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.etsi.nfvo.ns.lcm.database.beans;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.EnumType;
26 import javax.persistence.Enumerated;
27 import javax.persistence.FetchType;
28 import javax.persistence.Id;
29 import javax.persistence.OneToMany;
30 import javax.persistence.Table;
31 import java.time.LocalDateTime;
32 import java.util.ArrayList;
33 import java.util.List;
34 import java.util.Objects;
35 import java.util.UUID;
36 import static org.onap.so.etsi.nfvo.ns.lcm.database.beans.utils.Utils.toIndentedString;
39 * @author Waqas Ikram (waqas.ikram@est.tech)
43 @Table(name = "NS_INST")
44 public class NfvoNsInst {
47 @Column(name = "NS_INST_ID")
48 private String nsInstId;
50 @Column(name = "NAME")
53 @Column(name = "NS_PACKAGE_ID")
54 private String nsPackageId;
56 @Column(name = "NSD_ID")
59 @Column(name = "NSD_INVARIANT_ID")
60 private String nsdInvariantId;
62 @Column(name = "DESCRIPTION", columnDefinition = "LONGTEXT")
63 private String description;
65 @Enumerated(EnumType.STRING)
66 @Column(name = "STATUS")
69 @Column(name = "STATUS_UPDATED_TIME")
70 private LocalDateTime statusUpdatedTime;
72 @Column(name = "GLOBAL_CUSTOMER_ID")
73 private String globalCustomerId;
75 @Column(name = "SERVICE_TYPE")
76 private String serviceType;
78 @OneToMany(mappedBy = "nsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
79 private List<NfvoNfInst> nfvoNfInsts = new ArrayList<>();
81 @OneToMany(mappedBy = "nfvoNsInst", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
82 private List<NsLcmOpOcc> nsLcmOpOccs = new ArrayList<>();
85 this.nsInstId = UUID.randomUUID().toString();
88 public String getNsInstId() {
92 public void setNsInstId(final String nsInstId) {
93 this.nsInstId = nsInstId;
96 public NfvoNsInst nsInstId(final String nsInstId) {
97 this.nsInstId = nsInstId;
101 public String getName() {
105 public void setName(final String name) {
109 public NfvoNsInst name(final String name) {
114 public String getNsPackageId() {
118 public void setNsPackageId(final String nsPackageId) {
119 this.nsPackageId = nsPackageId;
122 public NfvoNsInst nsPackageId(final String nsPackageId) {
123 this.nsPackageId = nsPackageId;
127 public String getNsdId() {
131 public void setNsdId(final String nsdId) {
135 public NfvoNsInst nsdId(final String nsdId) {
140 public String getNsdInvariantId() {
141 return nsdInvariantId;
144 public void setNsdInvariantId(final String nsdInvariantId) {
145 this.nsdInvariantId = nsdInvariantId;
148 public NfvoNsInst nsdInvariantId(final String nsdInvariantId) {
149 this.nsdInvariantId = nsdInvariantId;
153 public String getDescription() {
157 public void setDescription(final String description) {
158 this.description = description;
161 public NfvoNsInst description(final String description) {
162 this.description = description;
166 public State getStatus() {
170 public void setStatus(final State status) {
171 this.status = status;
174 public NfvoNsInst status(final State status) {
175 this.status = status;
179 public LocalDateTime getStatusUpdatedTime() {
180 return statusUpdatedTime;
183 public void setStatusUpdatedTime(final LocalDateTime statusUpdatedTime) {
184 this.statusUpdatedTime = statusUpdatedTime;
187 public NfvoNsInst statusUpdatedTime(final LocalDateTime statusUpdatedTime) {
188 this.statusUpdatedTime = statusUpdatedTime;
192 public String getGlobalCustomerId() {
193 return globalCustomerId;
196 public void setGlobalCustomerId(final String globalCustomerId) {
197 this.globalCustomerId = globalCustomerId;
200 public NfvoNsInst globalCustomerId(final String globalCustomerId) {
201 this.globalCustomerId = globalCustomerId;
205 public String getServiceType() {
209 public void setServiceType(final String serviceType) {
210 this.serviceType = serviceType;
213 public NfvoNsInst serviceType(final String serviceType) {
214 this.serviceType = serviceType;
218 public List<NfvoNfInst> getNfvoNfInsts() {
222 public void setNfvoNfInsts(final List<NfvoNfInst> nfvoNfInsts) {
223 this.nfvoNfInsts = nfvoNfInsts;
226 public NfvoNsInst nfvoNfInsts(final NfvoNfInst nfvoNfInsts) {
227 nfvoNfInsts.nfvoNsInst(this);
228 this.nfvoNfInsts.add(nfvoNfInsts);
232 public List<NsLcmOpOcc> getNsLcmOpOccs() {
236 public void setNsLcmOpOccs(final List<NsLcmOpOcc> nsLcmOpOccs) {
237 this.nsLcmOpOccs = nsLcmOpOccs;
240 public NfvoNsInst nsLcmOpOccs(final NsLcmOpOcc nsLcmOpOcc) {
241 nsLcmOpOcc.nfvoNsInst(this);
242 this.nsLcmOpOccs.add(nsLcmOpOcc);
247 public int hashCode() {
248 return Objects.hash(nsInstId, name, nsPackageId, nsdId, nsdInvariantId, description, status, statusUpdatedTime,
249 globalCustomerId, serviceType, nfvoNfInsts, nsLcmOpOccs);
253 public boolean equals(final Object obj) {
254 if (obj instanceof NfvoNsInst) {
255 final NfvoNsInst other = (NfvoNsInst) obj;
256 return Objects.equals(nsInstId, other.nsInstId) && Objects.equals(name, other.name)
257 && Objects.equals(nsPackageId, other.nsPackageId) && Objects.equals(nsdId, other.nsdId)
258 && Objects.equals(nsdInvariantId, other.nsdInvariantId)
259 && Objects.equals(description, other.description) && Objects.equals(status, other.status)
260 && Objects.equals(statusUpdatedTime, other.statusUpdatedTime)
261 && Objects.equals(globalCustomerId, other.globalCustomerId)
262 && Objects.equals(serviceType, other.serviceType) && Objects.equals(nfvoNfInsts, other.nfvoNfInsts)
263 && Objects.equals(nsLcmOpOccs, other.nsLcmOpOccs);
269 public String toString() {
270 final StringBuilder sb = new StringBuilder();
271 sb.append("class NfvoNsInst {\n");
272 sb.append(" nsInstId: ").append(toIndentedString(nsInstId)).append("\n");
273 sb.append(" name: ").append(toIndentedString(name)).append("\n");
274 sb.append(" nsPackageId: ").append(toIndentedString(nsPackageId)).append("\n");
275 sb.append(" nsdId: ").append(toIndentedString(nsdId)).append("\n");
276 sb.append(" nsdInvariantId: ").append(toIndentedString(nsdInvariantId)).append("\n");
277 sb.append(" description: ").append(toIndentedString(description)).append("\n");
278 sb.append(" status: ").append(toIndentedString(status)).append("\n");
279 sb.append(" statusUpdatedTime: ").append(toIndentedString(statusUpdatedTime)).append("\n");
280 sb.append(" globalCustomerId: ").append(toIndentedString(globalCustomerId)).append("\n");
281 sb.append(" serviceType: ").append(toIndentedString(serviceType)).append("\n");
282 sb.append(" nfvoNfInsts: ").append(toIndentedString(nfvoNfInsts)).append("\n");
283 sb.append(" nsLcmOpOccs: ").append(toIndentedString(nsLcmOpOccs)).append("\n");
286 return sb.toString();