org.genesys.blocks.auditlog.model.TransactionAuditLog Maven / Gradle / Ivy
/*
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.blocks.auditlog.model;
import org.genesys.blocks.model.ClassPK;
/**
* Temporary audit log.
*/
public class TransactionAuditLog {
/** Class name of the referenced entity. */
private ClassPK classPk;
/** ID of the referenced entity. */
private long entityId;
/** The name of the property modified. */
private String propertyName;
/** The type of entity referenced in the changed property. */
private ClassPK referencedEntity;
/** String representation of the previous state. */
private String previousState;
/** String representation of the updated state. */
private String newState;
/** The previous object */
private Object previousObject;
/** The new object */
private Object newObject;
/** The action. */
private AuditAction action;
/**
* Gets the class pk.
*
* @return the class pk
*/
public ClassPK getClassPk() {
return classPk;
}
/**
* Sets the class pk.
*
* @param classPk the new class pk
*/
public void setClassPk(final ClassPK classPk) {
this.classPk = classPk;
}
/**
* Gets the entity id.
*
* @return the entity id
*/
public long getEntityId() {
return entityId;
}
/**
* Sets the entity id.
*
* @param entityId the new entity id
*/
public void setEntityId(final long entityId) {
this.entityId = entityId;
}
/**
* Sets the property name.
*
* @param propertyName the new property name
*/
public void setPropertyName(final String propertyName) {
this.propertyName = propertyName;
}
/**
* Gets the property name.
*
* @return the property name
*/
public String getPropertyName() {
return propertyName;
}
/**
* Sets the referenced entity.
*
* @param referencedEntity the new referenced entity
*/
public void setReferencedEntity(final ClassPK referencedEntity) {
this.referencedEntity = referencedEntity;
}
/**
* Gets the referenced entity.
*
* @return the referenced entity
*/
public ClassPK getReferencedEntity() {
return referencedEntity;
}
/**
* Sets the previous state.
*
* @param previousState the new previous state
*/
public void setPreviousState(final String previousState) {
this.previousState = previousState;
}
/**
* Gets the previous state.
*
* @return the previous state
*/
public String getPreviousState() {
return previousState;
}
/**
* Sets the new state.
*
* @param newState the new new state
*/
public void setNewState(final String newState) {
this.newState = newState;
}
/**
* Gets the new state.
*
* @return the new state
*/
public String getNewState() {
return newState;
}
/**
* Sets the action.
*
* @param action the new action
*/
public void setAction(final AuditAction action) {
this.action = action;
}
/**
* Gets the action.
*
* @return the action
*/
public AuditAction getAction() {
return action;
}
/**
* @return the previousObject
*/
public Object getPreviousObject() {
return previousObject;
}
/**
* @param previousObject the previousObject to set
*/
public void setPreviousObject(Object previousObject) {
this.previousObject = previousObject;
}
/**
* @return the newObject
*/
public Object getNewObject() {
return newObject;
}
/**
* @param newObject the newObject to set
*/
public void setNewObject(Object newObject) {
this.newObject = newObject;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((classPk == null) ? 0 : classPk.hashCode());
result = prime * result + (int) (entityId ^ (entityId >>> 32));
result = prime * result + ((propertyName == null) ? 0 : propertyName.hashCode());
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TransactionAuditLog other = (TransactionAuditLog) obj;
if (classPk == null) {
if (other.classPk != null)
return false;
} else if (!classPk.equals(other.classPk))
return false;
if (entityId != other.entityId)
return false;
if (propertyName == null) {
if (other.propertyName != null)
return false;
} else if (!propertyName.equals(other.propertyName))
return false;
return true;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(action.toString()).append(" shortname=").append(classPk.getShortName()).append(" id=").append(entityId).append(" ").append(propertyName).append("='").append(previousState).append(
"' -> '").append(newState).append("'");
return sb.toString();
}
}