4175068fce679711b21677ecee3c001e42b91080
[policy/drools-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * feature-active-standby-management
4  * ================================================================================
5  * Copyright (C) 2017-2019 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.policy.drools.activestandby;
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.NamedQueries;
30 import javax.persistence.NamedQuery;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import lombok.Getter;
34 import lombok.Setter;
35 import org.onap.policy.common.im.MonitorTime;
36 import org.onap.policy.drools.activestandby.DroolsPdpObject;
37
38 @Entity
39 //@Table(name="DroolsPdpEntity")
40
41 @NamedQueries({
42     @NamedQuery(name = "DroolsPdpEntity.findAll", query = "SELECT e FROM DroolsPdpEntity e "),
43     @NamedQuery(name = "DroolsPdpEntity.deleteAll", query = "DELETE FROM DroolsPdpEntity WHERE 1=1")
44     })
45 @Getter
46 @Setter
47 public class DroolsPdpEntity extends DroolsPdpObject implements Serializable {
48
49     private static final long serialVersionUID = 1L;
50
51     @Id
52     @Column(name = "pdpId", nullable = false)
53     private String pdpId = "-1";
54
55     @Column(name = "designated", nullable = false)
56     private boolean designated = false;
57
58     @Column(name = "priority", nullable = false)
59     private int priority = 0;
60
61     @Temporal(TemporalType.TIMESTAMP)
62     @Column(name = "updatedDate", nullable = false)
63     private Date updatedDate;
64
65     @Temporal(TemporalType.TIMESTAMP)
66     @Column(name = "designatedDate",nullable = false)
67     private Date designatedDate;
68
69     @Column(name = "site", nullable = true, length = 50)
70     private String site;
71
72     /**
73      * Constructor.
74      */
75     public DroolsPdpEntity() {
76         updatedDate = MonitorTime.getInstance().getDate();
77         //When this is translated to a TimeStamp in MySQL, it assumes the date is relative
78         //to the local timezone.  So, a value of Date(0) is actually Dec 31 18:00:00 CST 1969
79         //which is an invalid value for the MySql TimeStamp
80         designatedDate = new Date(864000000);
81     }
82
83     @Override
84     public int hashCode() {
85         return super.hashCode();
86     }
87
88     @Override
89     public boolean equals(Object obj) {
90         return super.equals(obj);
91     }
92 }