Containerization feature of SO
[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
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 = "service_proxy_customization")
49 public class ServiceProxyResourceCustomization implements Serializable {
50
51         /**
52          * 
53          */
54         private static final long serialVersionUID = -2822457299134903084L;
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 = "TOSCA_NODE_TYPE")
65         private String toscaNodeType;
66
67         @Column(name = "CREATION_TIMESTAMP", updatable = false)
68         @Temporal(TemporalType.TIMESTAMP)
69         private Date created;
70
71         @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
72         @JoinColumn(name = "SOURCE_SERVICE_MODEL_UUID")
73         private Service sourceService;
74
75         @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
76         @JoinColumn(name = "SERVICE_PROXY_MODEL_UUID")
77         private ServiceProxyResource serviceProxyResource;
78
79         @OneToOne(mappedBy = "serviceProxyResourceCustomization")
80         private ConfigurationResourceCustomization configResourceCustomization;
81
82         @PrePersist
83         protected void onCreate() {
84                 this.created = new Date();
85         }
86
87         public String getModelCustomizationUUID() {
88                 return modelCustomizationUUID;
89         }
90
91         public void setModelCustomizationUUID(String modelCustomizationUUID) {
92                 this.modelCustomizationUUID = modelCustomizationUUID;
93         }
94
95         public String getModelInstanceName() {
96                 return modelInstanceName;
97         }
98
99         public void setModelInstanceName(String modelInstanceName) {
100                 this.modelInstanceName = modelInstanceName;
101         }
102
103         public String getToscaNodeType() {
104                 return toscaNodeType;
105         }
106
107         public void setToscaNodeType(String toscaNodeType) {
108                 this.toscaNodeType = toscaNodeType;
109         }
110
111         public Date getCreated() {
112                 return created;
113         }
114
115         @LinkedResource
116         public Service getSourceService() {
117                 return sourceService;
118         }
119
120         public void setSourceService(Service sourceService) {
121                 this.sourceService = sourceService;
122         }
123
124         @LinkedResource
125         public ServiceProxyResource getServiceProxyResource() {
126                 return serviceProxyResource;
127         }
128
129         public void setServiceProxyResource(ServiceProxyResource serviceProxyResource) {
130                 this.serviceProxyResource = serviceProxyResource;
131         }
132
133         @LinkedResource
134         public ConfigurationResourceCustomization getConfigResourceCustomization() {
135                 return configResourceCustomization;
136         }
137
138         public void setConfigResourceCustomization(ConfigurationResourceCustomization configResourceCustomization) {
139                 this.configResourceCustomization = configResourceCustomization;
140         }
141
142         @Override
143         public String toString() {
144                 return new ToStringBuilder(this).append("modelCustomizationUUID", modelCustomizationUUID)
145                                 .append("modelInstanceName", modelInstanceName).append("toscaNodeType", toscaNodeType)
146                                 .append("created", created).append("sourceService", sourceService)
147                                 .append("serviceProxyResource", serviceProxyResource)
148                                 .append("configResourceCustomization", configResourceCustomization).toString();
149         }
150
151         @Override
152         public boolean equals(final Object other) {
153                 if (!(other instanceof ServiceProxyResourceCustomization)) {
154                         return false;
155                 }
156                 ServiceProxyResourceCustomization castOther = (ServiceProxyResourceCustomization) other;
157                 return new EqualsBuilder().append(modelCustomizationUUID, castOther.modelCustomizationUUID).isEquals();
158         }
159
160         @Override
161         public int hashCode() {
162                 return new HashCodeBuilder().append(modelCustomizationUUID).toHashCode();
163         }
164 }