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