View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.backend.jpa.access;
20  
21  import java.sql.Timestamp;
22  
23  import jakarta.persistence.Column;
24  import jakarta.persistence.Entity;
25  import jakarta.persistence.Id;
26  import jakarta.persistence.Table;
27  
28  @Entity
29  @Table(name = "MCRACCESSRULE")
30  public class MCRACCESSRULE {
31  
32      @Id
33      @Column(name = "RID")
34      private String rid;
35  
36      @Column(name = "CREATOR", length = 64, nullable = false)
37      private String creator;
38  
39      @Column(name = "CREATIONDATE", length = 64, nullable = false)
40      private Timestamp creationdate;
41  
42      @Column(name = "RULE", length = 2048000, nullable = false)
43      private String rule;
44  
45      @Column(name = "DESCRIPTION", length = 255, nullable = false)
46      private String description;
47  
48      public Timestamp getCreationdate() {
49          return creationdate;
50      }
51  
52      public void setCreationdate(Timestamp creationdate) {
53          this.creationdate = creationdate;
54      }
55  
56      public String getCreator() {
57          return creator;
58      }
59  
60      public void setCreator(String creator) {
61          this.creator = creator;
62      }
63  
64      public String getDescription() {
65          return description;
66      }
67  
68      public void setDescription(String description) {
69          this.description = description;
70      }
71  
72      public String getRid() {
73          return rid;
74      }
75  
76      public void setRid(String rid) {
77          this.rid = rid;
78      }
79  
80      public String getRule() {
81          return rule;
82      }
83  
84      public void setRule(String rule) {
85          this.rule = rule;
86      }
87  
88      @Override
89      public int hashCode() {
90          final int prime = 31;
91          int result = 1;
92          result = prime * result + (creationdate == null ? 0 : creationdate.hashCode());
93          result = prime * result + (creator == null ? 0 : creator.hashCode());
94          result = prime * result + (description == null ? 0 : description.hashCode());
95          result = prime * result + (rid == null ? 0 : rid.hashCode());
96          result = prime * result + (rule == null ? 0 : rule.hashCode());
97          return result;
98      }
99  
100     @Override
101     public boolean equals(Object obj) {
102         System.out.println("EQUALS");
103         if (this == obj) {
104             return true;
105         }
106         if (obj == null) {
107             return false;
108         }
109         if (!(obj instanceof MCRACCESSRULE)) {
110             return false;
111         }
112         final MCRACCESSRULE other = (MCRACCESSRULE) obj;
113         if (creationdate == null) {
114             if (other.getCreationdate() != null) {
115                 return false;
116             }
117         } else {
118             if (other.getCreationdate() == null) {
119                 return false;
120             }
121             // We will remove milliseconds as they don't need to be saved
122             long thisLong = creationdate.getTime() / 1000;
123             long otherLong = other.getCreationdate().getTime() / 1000;
124             if (thisLong != otherLong) {
125                 return false;
126             }
127         }
128         if (creator == null) {
129             if (other.getCreator() != null) {
130                 return false;
131             }
132         } else if (!creator.equals(other.getCreator())) {
133             return false;
134         }
135         if (description == null) {
136             if (other.getDescription() != null) {
137                 return false;
138             }
139         } else if (!description.equals(other.getDescription())) {
140             return false;
141         }
142         if (rid == null) {
143             if (other.getRid() != null) {
144                 return false;
145             }
146         } else if (!rid.equals(other.getRid())) {
147             return false;
148         }
149         if (rule == null) {
150             return other.getRule() == null;
151         } else {
152             return rule.equals(other.getRule());
153         }
154     }
155 }