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