Merge "Fix issue where user cannot create a recipe via"
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VnfcCustomization.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.so.db.catalog.beans;
23
24 import com.fasterxml.jackson.annotation.JsonFormat;
25 import com.openpojo.business.annotation.BusinessKey;
26 import org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28 import org.apache.commons.lang3.builder.ToStringBuilder;
29 import javax.persistence.CascadeType;
30 import javax.persistence.Column;
31 import javax.persistence.Entity;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.OneToMany;
36 import javax.persistence.PrePersist;
37 import javax.persistence.Table;
38 import javax.persistence.Temporal;
39 import javax.persistence.TemporalType;
40 import java.io.Serializable;
41 import java.util.Date;
42 import java.util.List;
43
44 @Entity
45 @Table(name = "vnfc_customization")
46 public class VnfcCustomization implements Serializable {
47
48     private static final long serialVersionUID = -3772469944364616486L;
49
50     @BusinessKey
51     @Id
52     @Column(name = "MODEL_CUSTOMIZATION_UUID")
53     private String modelCustomizationUUID;
54
55     @Column(name = "MODEL_INSTANCE_NAME")
56     private String modelInstanceName;
57
58     @Column(name = "MODEL_UUID")
59     private String modelUUID;
60
61     @Column(name = "MODEL_INVARIANT_UUID")
62     private String modelInvariantUUID;
63
64     @Column(name = "MODEL_VERSION")
65     private String modelVersion;
66
67     @Column(name = "MODEL_NAME")
68     private String modelName;
69
70     @Column(name = "TOSCA_NODE_TYPE")
71     private String toscaNodeType;
72
73     @Column(name = "DESCRIPTION")
74     private String description;
75
76     @Column(name = "RESOURCE_INPUT")
77     private String resourceInput;
78
79     @Column(name = "CREATION_TIMESTAMP", updatable = false)
80     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
81     @Temporal(TemporalType.TIMESTAMP)
82     private Date created;
83
84     @OneToMany(cascade = CascadeType.ALL, mappedBy = "vnfcCustomization")
85     private List<CvnfcCustomization> cvnfcCustomization;
86
87     @ManyToOne(cascade = CascadeType.ALL)
88     @JoinColumn(name = "VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID")
89     private VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization;
90
91     @Override
92     public boolean equals(final Object other) {
93         if (!(other instanceof VnfcCustomization)) {
94             return false;
95         }
96         VnfcCustomization castOther = (VnfcCustomization) other;
97         return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
98     }
99
100     @Override
101     public int hashCode() {
102         return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
103     }
104
105     @Override
106     public String toString() {
107         return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
108                 .append("modelInstanceName", modelInstanceName).append("modelUUID", modelUUID)
109                 .append("modelInvariantUUID", modelInvariantUUID).append("modelVersion", modelVersion)
110                 .append("modelName", modelName).append("toscaNodeType", toscaNodeType)
111                 .append("description", description).append("created", created)
112                 .append("cvnfcCustomization", cvnfcCustomization).toString();
113     }
114
115     @PrePersist
116     protected void onCreate() {
117         this.created = new Date();
118     }
119
120     public String getModelCustomizationUUID() {
121         return modelCustomizationUUID;
122     }
123
124     public void setModelCustomizationUUID(String modelCustomizationUUID) {
125         this.modelCustomizationUUID = modelCustomizationUUID;
126     }
127
128     public String getModelInstanceName() {
129         return modelInstanceName;
130     }
131
132     public void setModelInstanceName(String modelInstanceName) {
133         this.modelInstanceName = modelInstanceName;
134     }
135
136     public String getModelUUID() {
137         return modelUUID;
138     }
139
140     public void setModelUUID(String modelUUID) {
141         this.modelUUID = modelUUID;
142     }
143
144     public String getModelInvariantUUID() {
145         return modelInvariantUUID;
146     }
147
148     public void setModelInvariantUUID(String modelInvariantUUID) {
149         this.modelInvariantUUID = modelInvariantUUID;
150     }
151
152     public String getModelVersion() {
153         return modelVersion;
154     }
155
156     public void setModelVersion(String modelVersion) {
157         this.modelVersion = modelVersion;
158     }
159
160     public String getModelName() {
161         return modelName;
162     }
163
164     public void setModelName(String modelName) {
165         this.modelName = modelName;
166     }
167
168     public String getToscaNodeType() {
169         return toscaNodeType;
170     }
171
172     public void setToscaNodeType(String toscaNodeType) {
173         this.toscaNodeType = toscaNodeType;
174     }
175
176     public String getDescription() {
177         return description;
178     }
179
180     public void setDescription(String description) {
181         this.description = description;
182     }
183
184     public Date getCreated() {
185         return created;
186     }
187
188     public void setCreated(Date created) {
189         this.created = created;
190     }
191
192     public List<CvnfcCustomization> getCvnfcCustomization() {
193         return cvnfcCustomization;
194     }
195
196     public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) {
197         this.cvnfcCustomization = cvnfcCustomization;
198     }
199
200     public VnfcInstanceGroupCustomization getVnfcInstanceGroupCustomization() {
201         return vnfcInstanceGroupCustomization;
202     }
203
204     public void setVnfcInstanceGroupCustomization(VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization) {
205         this.vnfcInstanceGroupCustomization = vnfcInstanceGroupCustomization;
206     }
207
208     public String getResourceInput() {
209         return resourceInput;
210     }
211
212     public void setResourceInput(String resourceInput) {
213         this.resourceInput = resourceInput;
214     }
215 }