d725c505ffccb588871717eaa3eb6994fab4945f
[so.git] / mso-catalog-db / src / main / java / org / onap / so / db / catalog / beans / ServiceProxyResourceCustomization.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.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.JoinTable;
36 import javax.persistence.ManyToOne;
37 import javax.persistence.OneToMany;
38 import javax.persistence.OneToOne;
39 import javax.persistence.PrePersist;
40 import javax.persistence.Table;
41 import javax.persistence.Temporal;
42 import javax.persistence.TemporalType;
43
44 import org.apache.commons.lang3.builder.EqualsBuilder;
45 import org.apache.commons.lang3.builder.HashCodeBuilder;
46 import org.apache.commons.lang3.builder.ToStringBuilder;
47
48 import com.openpojo.business.annotation.BusinessKey;
49
50 import uk.co.blackpepper.bowman.annotation.LinkedResource;
51
52 @Entity
53 @Table(name = "service_proxy_customization")
54 public class ServiceProxyResourceCustomization implements Serializable {
55
56         /**
57          * 
58          */
59         private static final long serialVersionUID = -2822457299134903084L;
60         
61         @BusinessKey
62         @Id
63         @Column(name = "MODEL_CUSTOMIZATION_UUID")
64         private String modelCustomizationUUID;
65
66         @Column(name = "MODEL_INSTANCE_NAME")
67         private String modelInstanceName;
68         
69         @Column(name = "MODEL_UUID")
70         private String modelUUID;
71         
72         @Column(name = "MODEL_INVARIANT_UUID")
73         private String modelInvariantUUID;
74         
75         @Column(name = "MODEL_VERSION")
76         private String modelVersion;
77         
78         @Column(name = "MODEL_NAME")
79         private String modelName;
80
81         @Column(name = "TOSCA_NODE_TYPE")
82         private String toscaNodeType;
83         
84         @Column(name = "DESCRIPTION")
85         private String description;
86
87         @Column(name = "CREATION_TIMESTAMP", updatable = false)
88         @Temporal(TemporalType.TIMESTAMP)
89         private Date created;
90
91         @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
92         @JoinColumn(name = "SOURCE_SERVICE_MODEL_UUID")
93         private Service sourceService;
94                                         
95         @PrePersist
96         protected void onCreate() {
97                 this.created = new Date();
98         }
99         
100         public String getModelCustomizationUUID() {
101                 return modelCustomizationUUID;
102         }
103
104         public void setModelCustomizationUUID(String modelCustomizationUUID) {
105                 this.modelCustomizationUUID = modelCustomizationUUID;
106         }
107
108         public String getModelInstanceName() {
109                 return modelInstanceName;
110         }
111
112         public void setModelInstanceName(String modelInstanceName) {
113                 this.modelInstanceName = modelInstanceName;
114         }
115
116         public String getToscaNodeType() {
117                 return toscaNodeType;
118         }
119
120         public void setToscaNodeType(String toscaNodeType) {
121                 this.toscaNodeType = toscaNodeType;
122         }
123
124         public Date getCreated() {
125                 return created;
126         }
127
128         @LinkedResource
129         public Service getSourceService() {
130                 return sourceService;
131         }
132
133         public void setSourceService(Service sourceService) {
134                 this.sourceService = sourceService;
135         }
136         
137         public String getModelUUID() {
138                 return modelUUID;
139         }
140
141         public void setModelUUID(String modelUUID) {
142                 this.modelUUID = modelUUID;
143         }
144
145         public String getModelInvariantUUID() {
146                 return modelInvariantUUID;
147         }
148
149         public void setModelInvariantUUID(String modelInvariantUUID) {
150                 this.modelInvariantUUID = modelInvariantUUID;
151         }
152
153         public String getModelVersion() {
154                 return modelVersion;
155         }
156
157         public void setModelVersion(String modelVersion) {
158                 this.modelVersion = modelVersion;
159         }
160
161         public String getModelName() {
162                 return modelName;
163         }
164
165         public void setModelName(String modelName) {
166                 this.modelName = modelName;
167         }
168
169         public String getDescription() {
170                 return description;
171         }
172
173         public void setDescription(String description) {
174                 this.description = description;
175         }
176         
177         
178         @Override
179         public String toString() {
180                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
181                                 .append("modelInstanceName", modelInstanceName).append("toscaNodeType", toscaNodeType)
182                                 .append("modelUUID", modelUUID)
183                                 .append("modelInvariantUUID",modelInvariantUUID).append("modelName",modelName)
184                                 .append("description",description)
185                                 .append("created", created).append("sourceService", sourceService).toString();
186         }
187
188         @Override
189         public boolean equals(final Object other) {
190                 if (!(other instanceof ServiceProxyResourceCustomization)) {
191                         return false;
192                 }
193                 ServiceProxyResourceCustomization castOther = (ServiceProxyResourceCustomization) other;
194                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
195         }
196
197         @Override
198         public int hashCode() {
199                 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
200         }
201 }