Containerization feature of SO
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ConfigurationResourceCustomization.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.OneToOne;
34 import javax.persistence.PrePersist;
35 import javax.persistence.Table;
36 import javax.persistence.Temporal;
37 import javax.persistence.TemporalType;
38
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 = "configuration_customization")
49 public class ConfigurationResourceCustomization implements Serializable {
50
51         /**
52          * 
53          */
54         private static final long serialVersionUID = 1230671937560638856L;
55
56         @BusinessKey
57         @Id
58         @Column(name = "MODEL_CUSTOMIZATION_UUID")
59         private String modelCustomizationUUID;
60
61         @Column(name = "MODEL_INSTANCE_NAME")
62         private String modelInstanceName;
63
64         @Column(name = "CONFIGURATION_FUNCTION")
65         private String nfFunction;
66
67         @Column(name = "CONFIGURATION_TYPE")
68         private String nfType;
69
70         @Column(name = "CONFIGURATION_ROLE")
71         private String nfRole;
72
73         @Column(name = "CREATION_TIMESTAMP", updatable = false)
74         @Temporal(TemporalType.TIMESTAMP)
75         private Date created;
76
77         @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
78         @JoinColumn(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID")
79         private ServiceProxyResourceCustomization serviceProxyResourceCustomization;
80
81         @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
82         @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID")
83         private ConfigurationResourceCustomization configResourceCustomization;
84
85         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
86         @JoinColumn(name = "CONFIGURATION_MODEL_UUID")
87         private ConfigurationResource configurationResource;
88
89         @PrePersist
90         protected void onCreate() {
91                 this.created = new Date();
92         }
93
94         public String getModelCustomizationUUID() {
95                 return modelCustomizationUUID;
96         }
97
98         public void setModelCustomizationUUID(String modelCustomizationUUID) {
99                 this.modelCustomizationUUID = modelCustomizationUUID;
100         }
101
102         public String getModelInstanceName() {
103                 return modelInstanceName;
104         }
105
106         public void setModelInstanceName(String modelInstanceName) {
107                 this.modelInstanceName = modelInstanceName;
108         }
109
110         public String getNfFunction() {
111                 return nfFunction;
112         }
113
114         public void setNfFunction(String nfFunction) {
115                 this.nfFunction = nfFunction;
116         }
117
118         public String getNfType() {
119                 return nfType;
120         }
121
122         public void setNfType(String nfType) {
123                 this.nfType = nfType;
124         }
125
126         public String getNfRole() {
127                 return nfRole;
128         }
129
130         public void setNfRole(String nfRole) {
131                 this.nfRole = nfRole;
132         }
133
134         public Date getCreated() {
135                 return created;
136         }
137
138         @LinkedResource
139         public ServiceProxyResourceCustomization getServiceProxyResourceCustomization() {
140                 return serviceProxyResourceCustomization;
141         }
142
143         public void setServiceProxyResourceCustomization(
144                         ServiceProxyResourceCustomization serviceProxyResourceCustomization) {
145                 this.serviceProxyResourceCustomization = serviceProxyResourceCustomization;
146         }
147
148         @LinkedResource
149         public ConfigurationResourceCustomization getConfigResourceCustomization() {
150                 return configResourceCustomization;
151         }
152
153         public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) {
154                 this.configResourceCustomization = configResourceCustomization;
155         }
156
157         @LinkedResource
158         public ConfigurationResource getConfigurationResource() {
159                 return configurationResource;
160         }
161
162         public void setConfigurationResource(ConfigurationResource configurationResource) {
163                 this.configurationResource = configurationResource;
164         }
165
166         @Override
167         public String toString() {
168                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
169                                 .append("modelInstanceName", modelInstanceName).append("nfFunction", nfFunction)
170                                 .append("nfType", nfType).append("nfRole", nfRole).append("created", created)
171                                 .append("serviceProxyResourceCustomization", serviceProxyResourceCustomization)
172                                 .append("configResourceCustomization", configResourceCustomization)
173                                 .append("configurationResource", configurationResource).toString();
174         }
175
176         @Override
177         public boolean equals(final Object other) {
178                 if (!(other instanceof ConfigurationResourceCustomization)) {
179                         return false;
180                 }
181                 ConfigurationResourceCustomization castOther = (ConfigurationResourceCustomization) other;
182                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
183         }
184
185         @Override
186         public int hashCode() {
187                 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
188         }
189
190 }