Containerization feature of SO
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ServiceProxyResource.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.Set;
26
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.Id;
31 import javax.persistence.OneToMany;
32 import javax.persistence.PrePersist;
33 import javax.persistence.Table;
34 import javax.persistence.Temporal;
35 import javax.persistence.TemporalType;
36
37 import org.apache.commons.lang3.builder.EqualsBuilder;
38 import org.apache.commons.lang3.builder.HashCodeBuilder;
39 import org.apache.commons.lang3.builder.ToStringBuilder;
40
41 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
42 import com.openpojo.business.annotation.BusinessKey;
43
44 import uk.co.blackpepper.bowman.annotation.LinkedResource;
45
46 @JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
47 @Entity
48 @Table(name = "service_proxy")
49 public class ServiceProxyResource implements Serializable {
50
51         /**
52          * 
53          */
54         private static final long serialVersionUID = 8113564204017394906L;
55
56         @BusinessKey
57         @Id
58         @Column(name = "MODEL_UUID")
59         private String modelUUID;
60
61         @Column(name = "MODEL_INVARIANT_UUID")
62         private String modelInvariantUUID;
63
64         @Column(name = "MODEL_VERSION")
65         private String modelVersion;
66
67         @Column(name = "MODEL_NAME")
68         private String modelName;
69
70         @Column(name = "DESCRIPTION")
71         private String description;
72
73         @Column(name = "CREATION_TIMESTAMP", updatable = false)
74         @Temporal(TemporalType.TIMESTAMP)
75         private Date created;
76
77         @OneToMany(cascade = CascadeType.ALL, mappedBy = "serviceProxyResource")
78         private Set<ServiceProxyResourceCustomization> serviceProxyCustomization;
79
80         @PrePersist
81         protected void onCreate() {
82                 this.created = new Date();
83         }
84
85         public String getModelUUID() {
86                 return modelUUID;
87         }
88
89         public void setModelUUID(String modelUUID) {
90                 this.modelUUID = modelUUID;
91         }
92
93         public String getModelInvariantUUID() {
94                 return modelInvariantUUID;
95         }
96
97         public void setModelInvariantUUID(String modelInvariantUUID) {
98                 this.modelInvariantUUID = modelInvariantUUID;
99         }
100
101         public String getModelVersion() {
102                 return modelVersion;
103         }
104
105         public void setModelVersion(String modelVersion) {
106                 this.modelVersion = modelVersion;
107         }
108
109         public String getModelName() {
110                 return modelName;
111         }
112
113         public void setModelName(String modelName) {
114                 this.modelName = modelName;
115         }
116
117         public String getDescription() {
118                 return description;
119         }
120
121         public void setDescription(String description) {
122                 this.description = description;
123         }
124
125         public Date getCreated() {
126                 return created;
127         }
128
129         @LinkedResource
130         public Set<ServiceProxyResourceCustomization> getServiceProxyCustomization() {
131                 return serviceProxyCustomization;
132         }
133
134         public void setServiceProxyCustomization(Set<ServiceProxyResourceCustomization> serviceProxyCustomization) {
135                 this.serviceProxyCustomization = serviceProxyCustomization;
136         }
137
138         @Override
139         public String toString() {
140                 return new ToStringBuilder(this).append("modelUUID", modelUUID).append("modelInvariantUUID", modelInvariantUUID)
141                                 .append("modelVersion", modelVersion).append("modelName", modelName).append("description", description)
142                                 .append("created", created).append("serviceProxyCustomization", serviceProxyCustomization).toString();
143         }
144
145         @Override
146         public boolean equals(final Object other) {
147                 if (!(other instanceof ServiceProxyResource)) {
148                         return false;
149                 }
150                 ServiceProxyResource castOther = (ServiceProxyResource) other;
151                 return new EqualsBuilder().append(modelUUID, castOther.modelUUID).isEquals();
152         }
153
154         @Override
155         public int hashCode() {
156                 return new HashCodeBuilder().append(modelUUID).toHashCode();
157         }
158 }