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