Containerization feature of SO
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / WatchdogComponentDistributionStatus.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.request.beans;
22
23 import java.io.Serializable;
24 import java.util.Date;
25
26 import javax.persistence.Column;
27 import javax.persistence.Entity;
28 import javax.persistence.Id;
29 import javax.persistence.IdClass;
30 import javax.persistence.PrePersist;
31 import javax.persistence.PreUpdate;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import java.util.Objects;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37
38 @IdClass(WatchdogComponentDistributionStatusId.class)
39 @Entity
40 @Table(name = "watchdog_per_component_distribution_status")
41 public class WatchdogComponentDistributionStatus implements Serializable {
42
43
44         /**
45          * Serialization id.
46          */
47         private static final long serialVersionUID = -4344508954204488669L;
48         @Id
49         @Column(name = "DISTRIBUTION_ID", length=45)
50         private String distributionId;
51         @Id
52         @Column(name = "COMPONENT_NAME", length=45)
53         private String componentName;
54         @Column(name = "COMPONENT_DISTRIBUTION_STATUS", length=45)
55         private String componentDistributionStatus;
56         @Column(name = "CREATE_TIME", updatable=false)
57         @Temporal(TemporalType.TIMESTAMP)
58         private Date createTime;
59         @Column(name = "MODIFY_TIME")
60         @Temporal(TemporalType.TIMESTAMP)
61         private Date modifyTime;
62         
63         public WatchdogComponentDistributionStatus() {
64                 
65         }
66         
67         public WatchdogComponentDistributionStatus(String distributionId, String componentName) {
68                 this.distributionId = distributionId;
69                 this.componentName = componentName;
70         }
71
72         public String getDistributionId() {
73                 return distributionId;
74         }
75         
76         public void setDistributionId(String distributionId) {
77                 this.distributionId = distributionId;
78         }
79         
80         public String getComponentName() {
81                 return componentName;
82         }
83
84         public void setComponentName(String componentName) {
85                 this.componentName = componentName;
86         }
87
88         public String getComponentDistributionStatus() {
89                 return componentDistributionStatus;
90         }
91
92         public void setComponentDistributionStatus(String componentDistributionStatus) {
93                 this.componentDistributionStatus = componentDistributionStatus;
94         }
95         
96         public Date getCreateTime() {
97                 return createTime;
98         }
99
100         public Date getModifyTime() {
101                 return modifyTime;
102         }
103         
104         @PrePersist
105         protected void onCreate() {
106                 this.createTime = this.modifyTime = new Date();
107         }
108
109         @PreUpdate
110         protected void onUpdate() {
111                 this.modifyTime = new Date();
112         }
113
114         @Override
115         public boolean equals(final Object other) {
116                 if (this == other) {
117                         return true;
118                 }
119                 if (!(other instanceof WatchdogComponentDistributionStatus)) {
120                         return false;
121                 }
122                 WatchdogComponentDistributionStatus castOther = (WatchdogComponentDistributionStatus) other;
123                 return Objects.equals(getDistributionId(), castOther.getDistributionId())
124                                 && Objects.equals(getComponentName(), castOther.getComponentName());
125         }
126
127         @Override
128         public int hashCode() {
129                 return Objects.hash(getDistributionId(), getComponentName());
130         }
131
132         @Override
133         public String toString() {
134                 return new ToStringBuilder(this).append("distributionId", getDistributionId())
135                                 .append("componentName", getComponentName())
136                                 .append("componentDistributionStatus", getComponentDistributionStatus())
137                                 .append("createTime", getCreateTime()).append("modifyTime", getModifyTime()).toString();
138         }
139
140 }