0b02c11701444126beae4f200f59200a054b4882
[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 import java.util.List;
26
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.MapsId;
35 import javax.persistence.OneToMany;
36 import javax.persistence.OneToOne;
37 import javax.persistence.PrePersist;
38 import javax.persistence.Table;
39 import javax.persistence.Temporal;
40 import javax.persistence.TemporalType;
41
42 import org.apache.commons.lang3.builder.EqualsBuilder;
43 import org.apache.commons.lang3.builder.HashCodeBuilder;
44 import org.apache.commons.lang3.builder.ToStringBuilder;
45
46 import com.openpojo.business.annotation.BusinessKey;
47
48 import uk.co.blackpepper.bowman.annotation.LinkedResource;
49
50 @Entity
51 @Table(name = "configuration_customization")
52 public class ConfigurationResourceCustomization implements Serializable {
53
54         /**
55          * 
56          */
57         private static final long serialVersionUID = 1230671937560638856L;
58
59         @BusinessKey
60         @Id
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_FUNCTION")
68         private String nfFunction;
69
70         @Column(name = "CONFIGURATION_TYPE")
71         private String nfType;
72
73         @Column(name = "CONFIGURATION_ROLE")
74         private String nfRole;
75
76         @Column(name = "CREATION_TIMESTAMP", updatable = false)
77         @Temporal(TemporalType.TIMESTAMP)
78         private Date created;
79
80         @Column(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID")
81         private String serviceProxyResourceCustomizationUUID;
82                 
83         @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
84         @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID")
85         private ConfigurationResourceCustomization configResourceCustomization;
86
87         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
88         @JoinColumn(name = "CONFIGURATION_MODEL_UUID")
89         private ConfigurationResource configurationResource;
90
91         @PrePersist
92         protected void onCreate() {
93                 this.created = new Date();
94         }
95
96         public String getModelCustomizationUUID() {
97                 return modelCustomizationUUID;
98         }
99
100         public void setModelCustomizationUUID(String modelCustomizationUUID) {
101                 this.modelCustomizationUUID = modelCustomizationUUID;
102         }
103
104         public String getModelInstanceName() {
105                 return modelInstanceName;
106         }
107
108         public void setModelInstanceName(String modelInstanceName) {
109                 this.modelInstanceName = modelInstanceName;
110         }
111
112         public String getNfFunction() {
113                 return nfFunction;
114         }
115
116         public void setNfFunction(String nfFunction) {
117                 this.nfFunction = nfFunction;
118         }
119
120         public String getNfType() {
121                 return nfType;
122         }
123
124         public void setNfType(String nfType) {
125                 this.nfType = nfType;
126         }
127
128         public String getNfRole() {
129                 return nfRole;
130         }
131
132         public void setNfRole(String nfRole) {
133                 this.nfRole = nfRole;
134         }
135
136         public Date getCreated() {
137                 return created;
138         }
139                 
140         public String getServiceProxyResourceCustomizationUUID() {
141                 return serviceProxyResourceCustomizationUUID;
142         }
143
144         public void setServiceProxyResourceCustomizationUUID(String serviceProxyResourceCustomizationUUID) {
145                 this.serviceProxyResourceCustomizationUUID = serviceProxyResourceCustomizationUUID;
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 }