04b93c38861e5a6305ea44aa36c1fceae3a006cb
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / AllottedResourceCustomization.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.Id;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.PrePersist;
34 import javax.persistence.Table;
35 import javax.persistence.Temporal;
36 import javax.persistence.TemporalType;
37
38 import com.fasterxml.jackson.annotation.JsonFormat;
39 import org.apache.commons.lang3.builder.EqualsBuilder;
40 import org.apache.commons.lang3.builder.HashCodeBuilder;
41 import org.apache.commons.lang3.builder.ToStringBuilder;
42
43 import com.openpojo.business.annotation.BusinessKey;
44
45 import uk.co.blackpepper.bowman.annotation.LinkedResource;
46
47 @Entity
48 @Table(name = "allotted_resource_customization")
49 public class AllottedResourceCustomization implements Serializable {
50
51         private static final long serialVersionUID = 768026109321305392L;
52
53         @BusinessKey
54         @Id
55         @Column(name = "MODEL_CUSTOMIZATION_UUID")
56         private String modelCustomizationUUID;
57
58         @Column(name = "CREATION_TIMESTAMP", updatable = false)
59         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
60         @Temporal(TemporalType.TIMESTAMP)
61         private Date created;
62
63         @Column(name = "MODEL_INSTANCE_NAME")
64         private String modelInstanceName;
65
66         @Column(name = "PROVIDING_SERVICE_MODEL_INVARIANT_UUID")
67         private String providingServiceModelInvariantUUID;
68
69         @Column(name = "PROVIDING_SERVICE_MODEL_UUID")
70         private String providingServiceModelUUID;
71
72         @Column(name = "PROVIDING_SERVICE_MODEL_NAME")
73         private String providingServiceModelName;
74
75         @Column(name = "TARGET_NETWORK_ROLE")
76         private String targetNetworkRole;
77
78         @Column(name = "NF_FUNCTION")
79         private String nfFunction;
80
81         @Column(name = "NF_TYPE")
82         private String nfType;
83
84         @Column(name = "NF_ROLE")
85         private String nfRole;
86
87         @Column(name = "NF_NAMING_CODE")
88         private String nfNamingCode;
89
90         @Column(name = "MIN_INSTANCES")
91         private Integer minInstances;
92
93         @Column(name = "MAX_INSTANCES")
94         private Integer maxInstances;
95
96         @Column(name = "RESOURCE_INPUT")
97         private String resourceInput;
98
99         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
100         @JoinColumn(name = "AR_MODEL_UUID")
101         private AllottedResource allottedResource;
102
103         @Override
104         public String toString() {
105                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
106                                 .append("created", created).append("modelInstanceName", modelInstanceName)
107                                 .append("providingServiceModelInvariantUUID", providingServiceModelInvariantUUID)
108                                 .append("providingServiceModelUUID", providingServiceModelUUID)
109                                 .append("providingServiceModelName", providingServiceModelName)
110                                 .append("targetNetworkRole", targetNetworkRole).append("nfFunction", nfFunction)
111                                 .append("nfType", nfType).append("nfRole", nfRole).append("nfNamingCode", nfNamingCode)
112                                 .append("minInstances", minInstances).append("maxInstances", maxInstances)
113                                 .append("allottedResource", allottedResource).toString();
114         }
115
116         @PrePersist
117         protected void onCreate() {
118                 this.created = new Date();
119         }
120
121         @Override
122         public boolean equals(final Object other) {
123                 if (!(other instanceof AllottedResourceCustomization)) {
124                         return false;
125                 }
126                 AllottedResourceCustomization castOther = (AllottedResourceCustomization) other;
127                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
128         }
129
130         @Override
131         public int hashCode() {
132                 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
133         }
134
135         public String getProvidingServiceModelUUID() {
136                 return providingServiceModelUUID;
137         }
138
139         public void setProvidingServiceModelUUID(String providingServiceModelUUID) {
140                 this.providingServiceModelUUID = providingServiceModelUUID;
141         }
142
143         public String getProvidingServiceModelName() {
144                 return providingServiceModelName;
145         }
146
147         public void setProvidingServiceModelName(String providingServiceModelName) {
148                 this.providingServiceModelName = providingServiceModelName;
149         }
150
151         public AllottedResourceCustomization() {
152                 super();
153         }
154
155         public String getModelCustomizationUUID() {
156                 return this.modelCustomizationUUID;
157         }
158
159         public void setModelCustomizationUUID(String modelCustomizationUUID) {
160                 this.modelCustomizationUUID = modelCustomizationUUID;
161         }
162
163         public Date getCreated() {
164                 return this.created;
165         }
166
167         public String getModelInstanceName() {
168                 return this.modelInstanceName;
169         }
170
171         public void setModelInstanceName(String modelInstanceName) {
172                 this.modelInstanceName = modelInstanceName;
173         }
174
175         @LinkedResource
176         public AllottedResource getAllottedResource() {
177                 return this.allottedResource;
178         }
179
180         public void setAllottedResource(AllottedResource allottedResource) {
181                 this.allottedResource = allottedResource;
182         }
183
184         public String getProvidingServiceModelInvariantUUID() {
185                 return this.providingServiceModelInvariantUUID;
186         }
187
188         public void setProvidingServiceModelInvariantUUID(String providingServiceModelInvariantUUID) {
189                 this.providingServiceModelInvariantUUID = providingServiceModelInvariantUUID;
190         }
191
192         public String getTargetNetworkRole() {
193                 return this.targetNetworkRole;
194         }
195
196         public void setTargetNetworkRole(String targetNetworkRole) {
197                 this.targetNetworkRole = targetNetworkRole;
198         }
199
200         public String getNfFunction() {
201                 return this.nfFunction;
202         }
203
204         public void setNfFunction(String nfFunction) {
205                 this.nfFunction = nfFunction;
206         }
207
208         public String getNfType() {
209                 return this.nfType;
210         }
211
212         public void setNfType(String nfType) {
213                 this.nfType = nfType;
214         }
215
216         public String getNfRole() {
217                 return this.nfRole;
218         }
219
220         public void setNfRole(String nfRole) {
221                 this.nfRole = nfRole;
222         }
223
224         public String getNfNamingCode() {
225                 return this.nfNamingCode;
226         }
227
228         public void setNfNamingCode(String nfNamingCode) {
229                 this.nfNamingCode = nfNamingCode;
230         }
231
232         public Integer getMinInstances() {
233                 return this.minInstances;
234         }
235
236         public void setMinInstances(Integer minInstances) {
237                 this.minInstances = minInstances;
238         }
239
240         public Integer getMaxInstances() {
241                 return this.maxInstances;
242         }
243
244         public void setMaxInstances(Integer maxInstances) {
245                 this.maxInstances = maxInstances;
246         }
247
248         public String getResourceInput() {
249                 return resourceInput;
250         }
251
252         public void setResourceInput(String resourceInput) {
253                 this.resourceInput = resourceInput;
254         }
255 }