Removed MsoLogger class
[so.git] / mso-api-handlers / mso-requests-db / src / main / java / org / onap / so / db / request / beans / SiteStatus.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
24 import java.time.format.DateTimeFormatter;
25 import java.util.Date;
26
27 import javax.persistence.Column;
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.PrePersist;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34
35 import java.util.Objects;
36 import org.apache.commons.lang3.builder.ToStringBuilder;
37
38 @Entity
39 @Table(name = "site_status")
40 public class SiteStatus {
41     
42         @Column(name = "STATUS")
43     private boolean status;
44         @Id
45         @Column(name = "SITE_NAME")
46     private String siteName;
47         @Column(name = "CREATION_TIMESTAMP", insertable = false, updatable = false)
48     @Temporal(TemporalType.TIMESTAMP)
49     private Date created;
50
51     public SiteStatus() {
52     }
53
54     public SiteStatus(String siteName) {
55                 this.siteName = siteName;
56         }
57
58         public Date getCreated() {
59         return created;
60     }
61
62     public String getSiteName() {
63         return siteName;
64     }
65
66     public void setSiteName(String siteName) {
67         this.siteName = siteName;
68     }
69
70     public void setStatus(boolean status) {
71         this.status = status;
72     }
73
74     public boolean getStatus() {
75         return status;
76     }
77
78     @PrePersist
79     protected void createdAt() {
80         this.created = new Date();
81     }
82     @Override
83         public boolean equals(final Object other) {
84                 if (this == other) {
85                         return true;
86                 }
87                 if (!(other instanceof SiteStatus)) {
88                         return false;
89                 }
90                 SiteStatus castOther = (SiteStatus) other;
91                 return Objects.equals(getSiteName(), castOther.getSiteName());
92         }
93
94         @Override
95         public int hashCode() {
96                 return Objects.hash(getSiteName());
97         }
98
99         @Override
100         public String toString() {
101                 return new ToStringBuilder(this).append("status", getStatus()).append("siteName", getSiteName())
102                                 .append("created", getCreated()).toString();
103         }
104 }