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