| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| AuditEntry |
|
| 0.0;0 |
| 1 | /* |
|
| 2 | * ============================================================================ |
|
| 3 | * GNU Lesser General Public License |
|
| 4 | * ============================================================================ |
|
| 5 | * |
|
| 6 | * Taylor - The Java Enterprise Application Framework. |
|
| 7 | * Copyright (C) 2005 John Gilbert jgilbert01@users.sourceforge.net |
|
| 8 | * |
|
| 9 | * This library is free software; you can redistribute it and/or |
|
| 10 | * modify it under the terms of the GNU Lesser General Public |
|
| 11 | * License as published by the Free Software Foundation; either |
|
| 12 | * version 2.1 of the License, or (at your option) any later version. |
|
| 13 | * |
|
| 14 | * This library is distributed in the hope that it will be useful, |
|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 17 | * Lesser General Public License for more details. |
|
| 18 | * |
|
| 19 | * You should have received a copy of the GNU Lesser General Public |
|
| 20 | * License along with this library; if not, write to the Free Software |
|
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|
| 22 | * |
|
| 23 | * John Gilbert |
|
| 24 | * Email: jgilbert01@users.sourceforge.net |
|
| 25 | */ |
|
| 26 | package net.taylor.audit.entity; |
|
| 27 | ||
| 28 | ||
| 29 | import java.io.Serializable; |
|
| 30 | import java.util.Date; |
|
| 31 | import java.util.List; |
|
| 32 | ||
| 33 | import javax.persistence.CascadeType; |
|
| 34 | import javax.persistence.Entity; |
|
| 35 | import javax.persistence.EnumType; |
|
| 36 | import javax.persistence.Enumerated; |
|
| 37 | import javax.persistence.FetchType; |
|
| 38 | import javax.persistence.GeneratedValue; |
|
| 39 | import javax.persistence.GenerationType; |
|
| 40 | import javax.persistence.Id; |
|
| 41 | import javax.persistence.OneToMany; |
|
| 42 | import javax.persistence.Temporal; |
|
| 43 | import javax.persistence.TemporalType; |
|
| 44 | import javax.persistence.Transient; |
|
| 45 | ||
| 46 | import net.taylor.audit.BypassAudit; |
|
| 47 | ||
| 48 | import org.apache.commons.lang.builder.ToStringBuilder; |
|
| 49 | import org.apache.commons.lang.builder.ToStringStyle; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @todo add comment for javadoc |
|
| 53 | * |
|
| 54 | * @author jgilbert |
|
| 55 | * @generated |
|
| 56 | */ |
|
| 57 | @Entity |
|
| 58 | @BypassAudit |
|
| 59 | public class AuditEntry implements Serializable, Cloneable { |
|
| 60 | /** @generated */ |
|
| 61 | private static final long serialVersionUID = 1L; |
|
| 62 | ||
| 63 | /** @generated */ |
|
| 64 | 198 | public AuditEntry() { |
| 65 | 198 | } |
| 66 | ||
| 67 | /** |
|
| 68 | * ------------------------------------------------------------------------ |
|
| 69 | * The primary key. |
|
| 70 | * ------------------------------------------------------------------------ |
|
| 71 | * @generated |
|
| 72 | */ |
|
| 73 | @Id |
|
| 74 | @GeneratedValue(strategy = GenerationType.AUTO) |
|
| 75 | public Long getId() { |
|
| 76 | 423 | return id; |
| 77 | } |
|
| 78 | ||
| 79 | /** @generated */ |
|
| 80 | public void setId(final Long id) { |
|
| 81 | 180 | this.id = id; |
| 82 | 180 | } |
| 83 | ||
| 84 | /** @generated */ |
|
| 85 | 198 | private Long id = null; |
| 86 | ||
| 87 | /** |
|
| 88 | * ------------------------------------------------------------------------ |
|
| 89 | * @todo add comment for javadoc |
|
| 90 | * ------------------------------------------------------------------------ |
|
| 91 | * @generated |
|
| 92 | */ |
|
| 93 | ||
| 94 | public String getUser() { |
|
| 95 | 438 | return user; |
| 96 | } |
|
| 97 | ||
| 98 | /** @generated */ |
|
| 99 | public void setUser(final String user) { |
|
| 100 | 234 | this.user = user; |
| 101 | 234 | } |
| 102 | ||
| 103 | /** @generated */ |
|
| 104 | 198 | private String user = null; |
| 105 | ||
| 106 | /** |
|
| 107 | * ------------------------------------------------------------------------ |
|
| 108 | * @todo add comment for javadoc |
|
| 109 | * ------------------------------------------------------------------------ |
|
| 110 | * @generated |
|
| 111 | */ |
|
| 112 | @Temporal(value = TemporalType.TIMESTAMP) |
|
| 113 | public Date getTimestamp() { |
|
| 114 | 438 | return timestamp; |
| 115 | } |
|
| 116 | ||
| 117 | /** @generated */ |
|
| 118 | public void setTimestamp(final Date timestamp) { |
|
| 119 | 234 | this.timestamp = timestamp; |
| 120 | 234 | } |
| 121 | ||
| 122 | /** @generated */ |
|
| 123 | 198 | private Date timestamp = null; |
| 124 | ||
| 125 | /** |
|
| 126 | * ------------------------------------------------------------------------ |
|
| 127 | * @todo add comment for javadoc |
|
| 128 | * ------------------------------------------------------------------------ |
|
| 129 | * @generated |
|
| 130 | */ |
|
| 131 | ||
| 132 | public String getEntityName() { |
|
| 133 | 513 | return entityName; |
| 134 | } |
|
| 135 | ||
| 136 | /** @generated */ |
|
| 137 | public void setEntityName(final String entityName) { |
|
| 138 | 234 | this.entityName = entityName; |
| 139 | 234 | } |
| 140 | ||
| 141 | /** @generated */ |
|
| 142 | 198 | private String entityName = null; |
| 143 | ||
| 144 | /** |
|
| 145 | * ------------------------------------------------------------------------ |
|
| 146 | * @todo add comment for javadoc |
|
| 147 | * ------------------------------------------------------------------------ |
|
| 148 | * @generated |
|
| 149 | */ |
|
| 150 | ||
| 151 | public Long getEntityId() { |
|
| 152 | 468 | return entityId; |
| 153 | } |
|
| 154 | ||
| 155 | /** @generated */ |
|
| 156 | public void setEntityId(final Long entityId) { |
|
| 157 | 234 | this.entityId = entityId; |
| 158 | 234 | } |
| 159 | ||
| 160 | /** @generated */ |
|
| 161 | 198 | private Long entityId = null; |
| 162 | ||
| 163 | /** |
|
| 164 | * ------------------------------------------------------------------------ |
|
| 165 | * @todo add comment for javadoc |
|
| 166 | * ------------------------------------------------------------------------ |
|
| 167 | * @generated |
|
| 168 | */ |
|
| 169 | @Enumerated(value = EnumType.STRING) |
|
| 170 | public Action getAction() { |
|
| 171 | 468 | return action; |
| 172 | } |
|
| 173 | ||
| 174 | /** @generated */ |
|
| 175 | public void setAction(final Action action) { |
|
| 176 | 234 | this.action = action; |
| 177 | 234 | } |
| 178 | ||
| 179 | /** @generated */ |
|
| 180 | @Transient |
|
| 181 | public boolean isInsert() { |
|
| 182 | 0 | return Action.INSERT.equals(action); |
| 183 | } |
|
| 184 | ||
| 185 | /** @generated */ |
|
| 186 | @Transient |
|
| 187 | public boolean isUpdate() { |
|
| 188 | 0 | return Action.UPDATE.equals(action); |
| 189 | } |
|
| 190 | ||
| 191 | /** @generated */ |
|
| 192 | @Transient |
|
| 193 | public boolean isDelete() { |
|
| 194 | 0 | return Action.DELETE.equals(action); |
| 195 | } |
|
| 196 | ||
| 197 | /** @generated */ |
|
| 198 | 198 | private Action action = null; |
| 199 | ||
| 200 | /** |
|
| 201 | * ------------------------------------------------------------------------ |
|
| 202 | * @todo add comment for javadoc |
|
| 203 | * ------------------------------------------------------------------------ |
|
| 204 | * @generated |
|
| 205 | */ |
|
| 206 | @OneToMany(fetch = FetchType.LAZY, mappedBy = "entry", cascade = CascadeType.ALL) |
|
| 207 | public List<AuditField> getFields() { |
|
| 208 | 561 | if (this.fields == null) { |
| 209 | 48 | this.fields = new java.util.ArrayList<AuditField>(); |
| 210 | } |
|
| 211 | 561 | return fields; |
| 212 | } |
|
| 213 | ||
| 214 | /** @generated */ |
|
| 215 | public void setFields(final List<AuditField> fields) { |
|
| 216 | 186 | this.fields = fields; |
| 217 | 186 | } |
| 218 | ||
| 219 | /** |
|
| 220 | * Associate AuditEntry with AuditField |
|
| 221 | * @generated |
|
| 222 | */ |
|
| 223 | public void addField(AuditField field) { |
|
| 224 | 30 | if (field == null) return; |
| 225 | 30 | getFields().add(field); |
| 226 | 30 | field.setEntry(this); |
| 227 | 30 | } |
| 228 | ||
| 229 | /** |
|
| 230 | * Unassociate AuditEntry from AuditField |
|
| 231 | * @generated |
|
| 232 | */ |
|
| 233 | public void removeField(AuditField field) { |
|
| 234 | 0 | if (field == null) return; |
| 235 | 0 | getFields().remove(field); |
| 236 | 0 | field.setEntry(null); |
| 237 | 0 | } |
| 238 | ||
| 239 | /** |
|
| 240 | * @generated |
|
| 241 | */ |
|
| 242 | public void removeAllFields() { |
|
| 243 | 0 | List<AuditField> remove = new java.util.ArrayList<AuditField>(); |
| 244 | 0 | remove.addAll(getFields()); |
| 245 | 0 | for (AuditField element : remove) { |
| 246 | 0 | removeField(element); |
| 247 | 0 | } |
| 248 | 0 | } |
| 249 | ||
| 250 | /** @generated */ |
|
| 251 | 198 | private List<AuditField> fields = null; |
| 252 | ||
| 253 | // ------------------------------------------------------------------------ |
|
| 254 | // Utils |
|
| 255 | // ------------------------------------------------------------------------ |
|
| 256 | ||
| 257 | ||
| 258 | /** @generated */ |
|
| 259 | public String toString() { |
|
| 260 | 357 | return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE); |
| 261 | } |
|
| 262 | ||
| 263 | /** @generated */ |
|
| 264 | public AuditEntry deepClone() throws Exception { |
|
| 265 | 0 | AuditEntry clone = (AuditEntry) super.clone(); |
| 266 | 0 | clone.setId(null); |
| 267 | ||
| 268 | 0 | clone.setFields(null); |
| 269 | 0 | for (AuditField kid : this.getFields()) { |
| 270 | 0 | clone.addField(kid.deepClone()); |
| 271 | 0 | } |
| 272 | 0 | return clone; |
| 273 | } |
|
| 274 | ||
| 275 | /** @generated */ |
|
| 276 | @Override |
|
| 277 | public int hashCode() { |
|
| 278 | 2013 | final int PRIME = 31; |
| 279 | 2013 | int result = 1; |
| 280 | 2013 | result = PRIME * result + ((id == null) ? super.hashCode() : id.hashCode()); |
| 281 | 2013 | return result; |
| 282 | } |
|
| 283 | ||
| 284 | /** @generated */ |
|
| 285 | @Override |
|
| 286 | public boolean equals(Object obj) { |
|
| 287 | 75 | if (this == obj) |
| 288 | 6 | return true; |
| 289 | 69 | if (obj == null) |
| 290 | 6 | return false; |
| 291 | 63 | if (!(obj instanceof AuditEntry)) |
| 292 | 63 | return false; |
| 293 | 0 | final AuditEntry other = (AuditEntry) obj; |
| 294 | 0 | if (id == null) { |
| 295 | 0 | if (other.getId() != null) |
| 296 | 0 | return false; |
| 297 | 0 | } else if (!id.equals(other.getId())) |
| 298 | 0 | return false; |
| 299 | 0 | return true; |
| 300 | } |
|
| 301 | } |