[SO] Release so 1.13.0 image
[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 javax.persistence.CascadeType;
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.FetchType;
29 import javax.persistence.GeneratedValue;
30 import javax.persistence.GenerationType;
31 import javax.persistence.Id;
32 import javax.persistence.JoinColumn;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.OneToOne;
35 import javax.persistence.PrePersist;
36 import javax.persistence.Table;
37 import javax.persistence.Temporal;
38 import javax.persistence.TemporalType;
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 import com.openpojo.business.annotation.BusinessKey;
43 import uk.co.blackpepper.bowman.annotation.LinkedResource;
44 import uk.co.blackpepper.bowman.annotation.RemoteResource;
45
46 @Entity
47 @RemoteResource("/configurationResourceCustomization")
48 @Table(name = "configuration_customization")
49 public class ConfigurationResourceCustomization implements Serializable {
50
51     /**
52      * 
53      */
54     private static final long serialVersionUID = 1230671937560638856L;
55
56     @Id
57     @BusinessKey
58     @Column(name = "ID")
59     @GeneratedValue(strategy = GenerationType.IDENTITY)
60     private Integer id;
61
62     @Column(name = "MODEL_CUSTOMIZATION_UUID")
63     private String modelCustomizationUUID;
64
65     @Column(name = "MODEL_INSTANCE_NAME")
66     private String modelInstanceName;
67
68     @Column(name = "CONFIGURATION_FUNCTION")
69     private String function;
70
71     @Column(name = "CONFIGURATION_TYPE")
72     private String type;
73
74     @Column(name = "CONFIGURATION_ROLE")
75     private String role;
76
77     @Column(name = "CREATION_TIMESTAMP", updatable = false)
78     @Temporal(TemporalType.TIMESTAMP)
79     private Date created;
80
81     @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
82     @JoinColumn(name = "SERVICE_PROXY_CUSTOMIZATION_MODEL_CUSTOMIZATION_UUID")
83     private ServiceProxyResourceCustomization serviceProxyResourceCustomization;
84
85     @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
86     @JoinColumn(name = "CONFIGURATION_CUSTOMIZATION_MODEL_CUSTOMIZATION_ID")
87     private ConfigurationResourceCustomization configResourceCustomization;
88
89     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
90     @JoinColumn(name = "CONFIGURATION_MODEL_UUID")
91     private ConfigurationResource configurationResource;
92
93     @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
94     @JoinColumn(name = "SERVICE_MODEL_UUID")
95     private Service service;
96
97     @PrePersist
98     protected void onCreate() {
99         this.created = new Date();
100     }
101
102     public Integer getId() {
103         return id;
104     }
105
106     public void setId(Integer id) {
107         this.id = id;
108     }
109
110     public String getModelCustomizationUUID() {
111         return modelCustomizationUUID;
112     }
113
114     public void setModelCustomizationUUID(String modelCustomizationUUID) {
115         this.modelCustomizationUUID = modelCustomizationUUID;
116     }
117
118     public String getModelInstanceName() {
119         return modelInstanceName;
120     }
121
122     public void setModelInstanceName(String modelInstanceName) {
123         this.modelInstanceName = modelInstanceName;
124     }
125
126     public String getFunction() {
127         return function;
128     }
129
130     public void setFunction(String function) {
131         this.function = function;
132     }
133
134     public String getType() {
135         return type;
136     }
137
138     public void setType(String type) {
139         this.type = type;
140     }
141
142     public String getRole() {
143         return role;
144     }
145
146     public void setRole(String role) {
147         this.role = role;
148     }
149
150     public Date getCreated() {
151         return created;
152     }
153
154     @LinkedResource
155     public ServiceProxyResourceCustomization getServiceProxyResourceCustomization() {
156         return serviceProxyResourceCustomization;
157     }
158
159     public void setServiceProxyResourceCustomization(
160             ServiceProxyResourceCustomization serviceProxyResourceCustomization) {
161         this.serviceProxyResourceCustomization = serviceProxyResourceCustomization;
162     }
163
164
165     @LinkedResource
166     public ConfigurationResourceCustomization getConfigResourceCustomization() {
167         return configResourceCustomization;
168     }
169
170     public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) {
171         this.configResourceCustomization = configResourceCustomization;
172     }
173
174     @LinkedResource
175     public ConfigurationResource getConfigurationResource() {
176         return configurationResource;
177     }
178
179     public void setConfigurationResource(ConfigurationResource configurationResource) {
180         this.configurationResource = configurationResource;
181     }
182
183     public Service getService() {
184         return service;
185     }
186
187     public void setService(Service service) {
188         this.service = service;
189     }
190
191     @Override
192     public String toString() {
193         return new ToStringBuilder(this).append("id", id).append("modelCustomizationUUID", modelCustomizationUUID)
194                 .append("modelInstanceName", modelInstanceName).append("function", function).append("type", type)
195                 .append("role", role).append("created", created)
196                 // .append("serviceProxyResourceCustomization", serviceProxyResourceCustomization)
197                 .append("configResourceCustomization", configResourceCustomization)
198                 .append("configurationResource", configurationResource).append("service", service).toString();
199     }
200
201     @Override
202     public boolean equals(final Object other) {
203         if (!(other instanceof ConfigurationResourceCustomization)) {
204             return false;
205         }
206         ConfigurationResourceCustomization castOther = (ConfigurationResourceCustomization) other;
207         return new EqualsBuilder().append(id, castOther.id).isEquals();
208     }
209
210     @Override
211     public int hashCode() {
212         return new HashCodeBuilder().append(id).toHashCode();
213     }
214
215 }