7ce657c5c7ac89fc03f2d6b808a00015639e2e38
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / VnfVfmoduleCvnfcConfigurationCustomization.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.so.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.CascadeType;
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.FetchType;
30 import javax.persistence.GeneratedValue;
31 import javax.persistence.GenerationType;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.ManyToOne;
35 import javax.persistence.PrePersist;
36 import javax.persistence.Table;
37 import javax.persistence.Temporal;
38 import javax.persistence.TemporalType;
39
40 import org.apache.commons.lang3.builder.EqualsBuilder;
41 import org.apache.commons.lang3.builder.HashCodeBuilder;
42 import org.apache.commons.lang3.builder.ToStringBuilder;
43
44 import com.fasterxml.jackson.annotation.JsonFormat;
45 import com.openpojo.business.annotation.BusinessKey;
46
47 import uk.co.blackpepper.bowman.annotation.LinkedResource;
48
49 @Entity
50 @Table(name = "vnf_vfmodule_cvnfc_configuration_customization")
51 public class VnfVfmoduleCvnfcConfigurationCustomization implements Serializable {
52
53         private static final long serialVersionUID = -3153216266280581103L;
54
55         @Id
56         @Column(name = "ID")
57         @GeneratedValue(strategy = GenerationType.IDENTITY)
58         private Integer id;
59         
60         @BusinessKey
61         @Column(name = "MODEL_CUSTOMIZATION_UUID")
62         private String modelCustomizationUUID;
63         
64         @Column(name = "MODEL_INSTANCE_NAME")
65         private String modelInstanceName;       
66         
67         @Column(name = "CONFIGURATION_TYPE")
68         private String configurationType;       
69         
70         @Column(name = "CONFIGURATION_ROLE")
71         private String configurationRole;       
72
73         @Column(name = "CONFIGURATION_FUNCTION")
74         private String configurationFunction;   
75
76         @Column(name = "POLICY_NAME")
77         private String policyName;      
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         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
85         @JoinColumn(name = "CONFIGURATION_MODEL_UUID")
86         private ConfigurationResource configurationResource;
87         
88         @BusinessKey
89         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
90         @JoinColumn(name = "CVNFC_MODEL_CUSTOMIZATION_UUID", referencedColumnName = "MODEL_CUSTOMIZATION_UUID")
91         private CvnfcCustomization cvnfcCustomization;
92         
93         @BusinessKey
94         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
95         @JoinColumn(name = "VF_MODULE_MODEL_CUSTOMIZATION_UUID")
96         private VfModuleCustomization vfModuleCustomization;
97
98         @BusinessKey
99         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
100         @JoinColumn(name = "VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID")
101         private VnfResourceCustomization vnfResourceCustomization;
102
103         @Override
104         public boolean equals(final Object other) {
105                 if (!(other instanceof VnfVfmoduleCvnfcConfigurationCustomization)) {
106                         return false;
107                 }
108                 VnfVfmoduleCvnfcConfigurationCustomization castOther = (VnfVfmoduleCvnfcConfigurationCustomization) other;
109                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID)
110                                 .append(cvnfcCustomization, castOther.cvnfcCustomization)
111                                 .append(vfModuleCustomization, castOther.vfModuleCustomization)
112                                 .append(vnfResourceCustomization, castOther.vnfResourceCustomization).isEquals();
113         }
114
115
116
117         @Override
118         public int hashCode() {
119                 return new HashCodeBuilder().append(modelCustomizationUUID).append(cvnfcCustomization)
120                                 .append(vfModuleCustomization).append(vnfResourceCustomization).toHashCode();
121         }
122
123
124
125         @Override
126         public String toString() {
127                 return new ToStringBuilder(this).append("id", id).append("modelCustomizationUUID", modelCustomizationUUID)
128                                 .append("modelInstanceName", modelInstanceName).append("configurationType", configurationType)
129                                 .append("configurationRole", configurationRole).append("configurationFunction", configurationFunction)
130                                 .append("policyName", policyName).append("created", created)
131                                 .append("configurationResource", configurationResource).append("cvnfcCustomization", cvnfcCustomization)
132                                 .append("vfModuleCustomization", vfModuleCustomization)
133                                 .append("vnfResourceCustomization", vnfResourceCustomization).toString();
134         }
135
136
137         
138         @PrePersist
139         protected void onCreate() {
140                 this.created = new Date();
141         }
142         
143         public Integer getId() {
144                 return id;
145         }
146
147         public void setId(Integer id) {
148                 this.id = id;
149         }
150
151         public String getModelCustomizationUUID() {
152                 return modelCustomizationUUID;
153         }
154
155         public void setModelCustomizationUUID(String modelCustomizationUUID) {
156                 this.modelCustomizationUUID = modelCustomizationUUID;
157         }
158
159         public String getModelInstanceName() {
160                 return modelInstanceName;
161         }
162
163         public void setModelInstanceName(String modelInstanceName) {
164                 this.modelInstanceName = modelInstanceName;
165         }
166
167         public String getConfigurationType() {
168                 return configurationType;
169         }
170
171         public void setConfigurationType(String configurationType) {
172                 this.configurationType = configurationType;
173         }
174
175         public String getConfigurationRole() {
176                 return configurationRole;
177         }
178
179         public void setConfigurationRole(String configurationRole) {
180                 this.configurationRole = configurationRole;
181         }
182
183         public String getConfigurationFunction() {
184                 return configurationFunction;
185         }
186
187         public void setConfigurationFunction(String configurationFunction) {
188                 this.configurationFunction = configurationFunction;
189         }
190
191         public String getPolicyName() {
192                 return policyName;
193         }
194
195         public void setPolicyName(String policyName) {
196                 this.policyName = policyName;
197         }
198
199         public Date getCreated() {
200                 return created;
201         }
202
203         public void setCreated(Date created) {
204                 this.created = created;
205         }
206
207         @LinkedResource
208         public ConfigurationResource getConfigurationResource() {
209                 return configurationResource;
210         }
211
212         public void setConfigurationResource(ConfigurationResource configurationResource) {
213                 this.configurationResource = configurationResource;
214         }
215
216         @LinkedResource
217         public CvnfcCustomization getCvnfcCustomization() {
218                 return cvnfcCustomization;
219         }
220
221         public void setCvnfcCustomization(CvnfcCustomization cvnfcCustomization) {
222                 this.cvnfcCustomization = cvnfcCustomization;
223         }
224
225         public VfModuleCustomization getVfModuleCustomization() {
226                 return vfModuleCustomization;
227         }
228
229         public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
230                 this.vfModuleCustomization = vfModuleCustomization;
231         }
232
233         public VnfResourceCustomization getVnfResourceCustomization() {
234                 return vnfResourceCustomization;
235         }
236
237         public void setVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) {
238                 this.vnfResourceCustomization = vnfResourceCustomization;
239         }
240 }