fixes bug #0008366
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@66693 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
af56d3d70f
commit
d7f9cb4591
|
@ -0,0 +1,220 @@
|
||||||
|
package com.rjconsultores.ventaboletos.auditoria;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
|
||||||
|
public class AuditControl {
|
||||||
|
private String currentActionService;
|
||||||
|
private Boolean checkModuleAudit;
|
||||||
|
private AuditService currentService;
|
||||||
|
private static Gson gson;
|
||||||
|
private static SimpleDateFormat sdf;
|
||||||
|
|
||||||
|
AuditControl(String currentActionService) {
|
||||||
|
this.currentActionService = currentActionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toJson(Object object) throws IllegalArgumentException, IllegalAccessException, ParseException {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||||
|
sdf.applyPattern("dd/MM/yyyy hh:mm:ss");
|
||||||
|
|
||||||
|
StringBuilder json = new StringBuilder();
|
||||||
|
json.append("{");
|
||||||
|
|
||||||
|
List<Object> lsClazz = new ArrayList<Object>();
|
||||||
|
List<String> lsFieldName = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (Field field : object.getClass().getDeclaredFields()) {
|
||||||
|
if ((!field.isAnnotationPresent(Column.class) && !field.isAnnotationPresent(Id.class) &&
|
||||||
|
!field.isAnnotationPresent(ManyToOne.class)) || field.getType().getSimpleName().equalsIgnoreCase("byte[]")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!field.isAnnotationPresent(ManyToOne.class)) {
|
||||||
|
if (json.length() > 1) {
|
||||||
|
json.append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
json.append("\"".concat(field.getName().concat("\":")));
|
||||||
|
} else {
|
||||||
|
lsFieldName.add("\"".concat(field.getName().concat("\":")));
|
||||||
|
}
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
if (field.getType().getName().contains("String") || field.getType().getName().contains("Date")) {
|
||||||
|
json.append("\"");
|
||||||
|
|
||||||
|
Date date = null;
|
||||||
|
|
||||||
|
if (field.getType().getName().equals("java.util.Date")) {
|
||||||
|
date = (java.util.Date) field.get(object);
|
||||||
|
json.append(date == null ? "null" : sdf.format(date));
|
||||||
|
} else if (field.getType().getName().equals("java.sql.Date")) {
|
||||||
|
date = (Date) field.get(object);
|
||||||
|
json.append(date == null ? "null" : sdf.format(date));
|
||||||
|
} else if (field.getType().getName().contains("String")) {
|
||||||
|
json.append((String) field.get(object));
|
||||||
|
}
|
||||||
|
|
||||||
|
json.append("\"");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.isAnnotationPresent(ManyToOne.class)) {
|
||||||
|
lsClazz.add(field.get(object));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
json.append(field.get(object) == null ? "null" : field.get(object).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < lsClazz.size(); i++) {
|
||||||
|
json.append(",");
|
||||||
|
|
||||||
|
json.append(lsFieldName.get(i));
|
||||||
|
json.append(AuditControl.toJson(lsClazz.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
json.append("}");
|
||||||
|
|
||||||
|
return json.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Gson getGson() {
|
||||||
|
if (AuditControl.gson == null) {
|
||||||
|
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
|
gsonBuilder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
|
||||||
|
DateFormat df = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||||
|
|
||||||
|
public Date deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context)
|
||||||
|
throws JsonParseException {
|
||||||
|
try {
|
||||||
|
return df.parse(json.getAsString());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gson = gsonBuilder.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
return gson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatJson(Object clazz, boolean mainClass) throws IllegalArgumentException, IllegalAccessException {
|
||||||
|
String init = "{";
|
||||||
|
String fim = "}";
|
||||||
|
String tab = "\t";
|
||||||
|
String ql = "\r";
|
||||||
|
|
||||||
|
String ret = init.concat(ql).concat(tab);
|
||||||
|
|
||||||
|
List<Object> lsClazz = new ArrayList<Object>();
|
||||||
|
List<String> lsNameFd = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (Field field : clazz.getClass().getDeclaredFields()) {
|
||||||
|
if (!field.isAnnotationPresent(Column.class) && !field.isAnnotationPresent(Id.class) &&
|
||||||
|
!field.isAnnotationPresent(ManyToOne.class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
if (field.isAnnotationPresent(ManyToOne.class) && field.get(clazz) != null) {
|
||||||
|
lsNameFd.add(field.getName());
|
||||||
|
lsClazz.add(field.get(clazz));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!mainClass) {
|
||||||
|
ret += tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret += field.getName().concat(":");
|
||||||
|
|
||||||
|
String fieldValue = null;
|
||||||
|
|
||||||
|
if (field.getType().getSimpleName().equalsIgnoreCase("date") && field.get(clazz) != null) {
|
||||||
|
fieldValue = AuditControl.convertDateObjectToString(field.get(clazz));
|
||||||
|
} else {
|
||||||
|
fieldValue = (field.get(clazz) == null ? "null" : field.get(clazz)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
ret += fieldValue;
|
||||||
|
ret += ql.concat(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < lsClazz.size(); i++) {
|
||||||
|
ret += lsNameFd.get(i).concat(tab.concat(":").concat(tab));
|
||||||
|
ret += formatJson(lsClazz.get(i), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mainClass) {
|
||||||
|
ret += ql.concat(fim);
|
||||||
|
} else {
|
||||||
|
ret += ql.concat(tab.concat(fim).concat(",").concat(ql).concat(tab));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertDateObjectToString(Object dateObject) throws RuntimeException {
|
||||||
|
if (sdf == null) {
|
||||||
|
sdf = new SimpleDateFormat();
|
||||||
|
sdf.applyPattern("dd/MM/yyyy hh:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dateObject.getClass().getName().contains("util")) {
|
||||||
|
Date date = (Date) dateObject;
|
||||||
|
return sdf.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dateObject.getClass().getName().contains("sql")) {
|
||||||
|
java.sql.Date date = (java.sql.Date) dateObject;
|
||||||
|
return sdf.format(new Date(date.getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException("Não foi possível realizar a conversão de data.\rClass: " + AuditControl.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCurrentActionService() {
|
||||||
|
return currentActionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditService getCurrentService() {
|
||||||
|
return currentService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentService(AuditService currentService) {
|
||||||
|
this.currentService = currentService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCheckModuleAudit() {
|
||||||
|
return checkModuleAudit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheckModuleAudit(Boolean checkModuleAudit) {
|
||||||
|
this.checkModuleAudit = checkModuleAudit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.rjconsultores.ventaboletos.auditoria;
|
||||||
|
|
||||||
|
public class AuditManager {
|
||||||
|
private static AuditControl INSTANCE;
|
||||||
|
|
||||||
|
public static AuditControl getINSTANCE(String currentActionService) {
|
||||||
|
INSTANCE = new AuditControl(currentActionService);
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuditControl getINSTANCE() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
package com.rjconsultores.ventaboletos.auditoria.interceptor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
import javax.enterprise.context.SessionScoped;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.EmptyInterceptor;
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.hibernate.type.Type;
|
||||||
|
import org.jfree.util.Log;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditControl;
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditManager;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.FuncionSistema;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Sistema;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.auditoria.EnumAuditAction;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@SessionScoped
|
||||||
|
public class AuditInterceptor extends EmptyInterceptor {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(AuditInterceptor.class);
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// Considera que o ADM sempre tenha o ID igual a 1
|
||||||
|
private Integer SISTEMA_ID = 1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
||||||
|
try {
|
||||||
|
genAudit(entity, EnumAuditAction.CRIACAO);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onSave(entity, id, state, propertyNames, types);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
|
||||||
|
try {
|
||||||
|
genAudit(entity, EnumAuditAction.ALTERACAO);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) {
|
||||||
|
try {
|
||||||
|
genAudit(entity, EnumAuditAction.EXCLUSAO);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onDelete(entity, id, state, propertyNames, types);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getAuditModuleService() {
|
||||||
|
|
||||||
|
if (!AuditManager.getINSTANCE().getCheckModuleAudit()) {
|
||||||
|
return AuditManager.getINSTANCE().getCurrentService() != null ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuditService auditService = null;
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
||||||
|
Session session = sessionFactory.openSession();
|
||||||
|
|
||||||
|
Criteria criteriaFuncionSistema = session.createCriteria(FuncionSistema.class);
|
||||||
|
criteriaFuncionSistema.add(Restrictions.eq("descruta", AuditManager.getINSTANCE().getCurrentActionService()));
|
||||||
|
FuncionSistema funcionSistema = (FuncionSistema) criteriaFuncionSistema.uniqueResult();
|
||||||
|
|
||||||
|
if (funcionSistema == null) {
|
||||||
|
Log.info("Função sistema " + funcionSistema + " não encontrada na base de dados.");
|
||||||
|
AuditManager.getINSTANCE().setCurrentService(auditService);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Criteria criteriaService = session.createCriteria(AuditService.class);
|
||||||
|
criteriaService.add(Restrictions.eq("funcionSistema", funcionSistema));
|
||||||
|
auditService = (AuditService) criteriaService.uniqueResult();
|
||||||
|
|
||||||
|
if (auditService == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AuditManager.getINSTANCE().setCurrentService(auditService);
|
||||||
|
AuditManager.getINSTANCE().setCheckModuleAudit(Boolean.FALSE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void genAudit(Object entity, EnumAuditAction action) {
|
||||||
|
if (!getAuditModuleService()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Ignorado caso a entidade for de auditoria e se não for encontrado o módulo no banco
|
||||||
|
*/
|
||||||
|
if (!(entity instanceof AuditLog)) {
|
||||||
|
|
||||||
|
AuditService service = AuditManager.getINSTANCE().getCurrentService();
|
||||||
|
|
||||||
|
if (!(entity instanceof AuditLog) && service != null && service.getModule() != null) {
|
||||||
|
/**
|
||||||
|
* A auditoria não será realizada nos seguintes cenários: 1) Não for encontrado o serviço no banco de dados 2) O serviço for encontrado, porém não está habilitado para auditoria
|
||||||
|
*/
|
||||||
|
if (service.getModule().getIndAuditable()) {
|
||||||
|
AuditLog audit = new AuditLog();
|
||||||
|
audit.setCreatedDate(new Date(System.currentTimeMillis()));
|
||||||
|
audit.setEntityName(entity.getClass().getSimpleName());
|
||||||
|
audit.setService(service);
|
||||||
|
audit.setEntityDetail(AuditControl.toJson(entity));
|
||||||
|
|
||||||
|
Sistema sistema = new Sistema();
|
||||||
|
sistema.setSistemaId(SISTEMA_ID);
|
||||||
|
audit.setSistema(sistema);
|
||||||
|
|
||||||
|
audit.setAction(action.getId());
|
||||||
|
audit.setUsuario(UsuarioLogado.getUsuarioLogado());
|
||||||
|
|
||||||
|
SessionFactory sessionFactory = DBUtil.getInstance().getSessionFactory();
|
||||||
|
Session session = sessionFactory.openSession();
|
||||||
|
|
||||||
|
session.persist(audit);
|
||||||
|
session.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
|
||||||
|
public interface AuditLogDAO extends GenericDAO<AuditLog, Long> {
|
||||||
|
public List<AuditLog> carregarLog(AuditModule modulo);
|
||||||
|
|
||||||
|
public List<AuditLog> filtrarLog(AuditLog log);
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
|
||||||
|
public interface AuditModuleDAO extends GenericDAO<AuditModule, Long>{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
|
||||||
|
public interface AuditServiceDAO extends GenericDAO<AuditService, Long> {
|
||||||
|
public AuditService carregarService(AuditService auditService);
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.criterion.MatchMode;
|
||||||
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditLogDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
|
||||||
|
@Repository("auditLogDAO")
|
||||||
|
public class AuditLogHibernateDAO extends GenericHibernateDAO<AuditLog, Long>
|
||||||
|
implements AuditLogDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AuditLogHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditLog> carregarLog(AuditModule modulo) {
|
||||||
|
|
||||||
|
List<AuditService> services = recuperarServices(modulo);
|
||||||
|
|
||||||
|
List<Long> ids = new ArrayList<Long>();
|
||||||
|
|
||||||
|
for (AuditService service : services) {
|
||||||
|
ids.add(service.getAuditServiceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.in("service.auditServiceId", ids));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AuditService> recuperarServices(AuditModule module) {
|
||||||
|
Criteria c = getSession().createCriteria(AuditService.class);
|
||||||
|
c.add(Restrictions.eq("module", module));
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditLog> filtrarLog(AuditLog log) {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
|
||||||
|
if (log.getSistema() != null) {
|
||||||
|
c.add(Restrictions.eq("sistema", log.getSistema()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.getAction() != null) {
|
||||||
|
c.add(Restrictions.eq("action", log.getAction()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.getEntityDetail() != null) {
|
||||||
|
c.add(Restrictions.like("entityDetail", log.getEntityDetail(), MatchMode.ANYWHERE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.getUsuario() != null) {
|
||||||
|
c.add(Restrictions.eq("usuario", log.getUsuario()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.getService() != null && log.getService().getModule() != null) {
|
||||||
|
c.add(Restrictions.eq("service.module", log.getService().getModule()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.getDataInicio() != null && log.getDataFim() != null) {
|
||||||
|
c.add(Restrictions.between("createDate", log.getDataInicio(), log.getDataFim()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditModuleDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
|
||||||
|
@Repository("auditModuleDAO")
|
||||||
|
public class AuditModuleHibernateDAO extends GenericHibernateDAO<AuditModule, Long>
|
||||||
|
implements AuditModuleDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AuditModuleHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditModule> obtenerTodos() {
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
return c.list();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditServiceDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
|
||||||
|
@Repository("auditServiceDAO")
|
||||||
|
public class AuditServiceHibernateDAO extends GenericHibernateDAO<AuditService, Long>
|
||||||
|
implements AuditServiceDAO {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AuditServiceHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
|
setSessionFactory(factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditService carregarService(AuditService auditService) {
|
||||||
|
AuditService service = null;
|
||||||
|
|
||||||
|
Criteria criteriaService = getSession().createCriteria(AuditService.class);
|
||||||
|
|
||||||
|
if (auditService.getFuncionSistema() != null && auditService.getFuncionSistema().getDescruta() != null) {
|
||||||
|
criteriaService.add(Restrictions.eq("funcionSistema", auditService.getFuncionSistema().getDescruta()));
|
||||||
|
service = (AuditService) criteriaService.uniqueResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.SequenceGenerator;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@SequenceGenerator(name = "AUDITLOG_SEQ", sequenceName = "AUDIT_LOG_SEQ", allocationSize = 1)
|
||||||
|
@Table(name = "AUDIT_LOG")
|
||||||
|
public class AuditLog implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "AUDITLOG_ID")
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "AUDITLOG_SEQ")
|
||||||
|
private Long auditLogId;
|
||||||
|
|
||||||
|
@Column(name = "AUDITACTION_ID")
|
||||||
|
private Integer action;
|
||||||
|
|
||||||
|
@Column(name = "ENTITY_DETAIL")
|
||||||
|
private String entityDetail;
|
||||||
|
|
||||||
|
@Column(name = "ENTITY_NAME")
|
||||||
|
private String entityName;
|
||||||
|
|
||||||
|
@Column(name = "CREATED_DATE")
|
||||||
|
private Date createdDate;
|
||||||
|
|
||||||
|
@JoinColumn(name = "SISTEMA_ID", referencedColumnName = "SISTEMA_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private Sistema sistema;
|
||||||
|
|
||||||
|
@JoinColumn(name = "USUARIO_ID", referencedColumnName = "USUARIO_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private Usuario usuario;
|
||||||
|
|
||||||
|
@JoinColumn(name = "AUDITSERVICE_ID", referencedColumnName = "AUDITSERVICE_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private AuditService service;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private Date dataInicio;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private Date dataFim;
|
||||||
|
|
||||||
|
public Long getAuditLogId() {
|
||||||
|
return auditLogId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditLogId(Long auditLogId) {
|
||||||
|
this.auditLogId = auditLogId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAction(Integer action) {
|
||||||
|
this.action = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sistema getSistema() {
|
||||||
|
return sistema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSistema(Sistema sistema) {
|
||||||
|
this.sistema = sistema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityDetail() {
|
||||||
|
return entityDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityDetail(String entityDetail) {
|
||||||
|
this.entityDetail = entityDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEntityName() {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityName(String entityName) {
|
||||||
|
this.entityName = entityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedDate() {
|
||||||
|
return createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedDate(Date createdDate) {
|
||||||
|
this.createdDate = createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Usuario getUsuario() {
|
||||||
|
return usuario;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsuario(Usuario usuario) {
|
||||||
|
this.usuario = usuario;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditService getService() {
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(AuditService service) {
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return createdDate.toString() + sistema.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDataFim() {
|
||||||
|
return dataFim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataFim(Date dataFim) {
|
||||||
|
this.dataFim = dataFim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDataInicio() {
|
||||||
|
return dataInicio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataInicio(Date dataInicio) {
|
||||||
|
this.dataInicio = dataInicio;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "AUDIT_MODULE")
|
||||||
|
public class AuditModule implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "AUDITMODULE_ID")
|
||||||
|
private Long auditModuleId;
|
||||||
|
|
||||||
|
@Column(name = "NAMEMODULE")
|
||||||
|
private String nameModule;
|
||||||
|
|
||||||
|
@Column(name = "INDAUDITABLE")
|
||||||
|
private Boolean indAuditable;
|
||||||
|
|
||||||
|
public Long getAuditModuleId() {
|
||||||
|
return auditModuleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditModuleId(Long auditModuleId) {
|
||||||
|
this.auditModuleId = auditModuleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIndAuditable() {
|
||||||
|
return indAuditable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNameModule() {
|
||||||
|
return nameModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameModule(String nameModule) {
|
||||||
|
this.nameModule = nameModule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndAuditable(Boolean indAuditable) {
|
||||||
|
this.indAuditable = indAuditable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nameModule;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.rjconsultores.ventaboletos.entidad;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "AUDIT_SERVICE")
|
||||||
|
public class AuditService implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "AUDITSERVICE_ID")
|
||||||
|
private Long auditServiceId;
|
||||||
|
|
||||||
|
@Column(name = "NAMESERVICE")
|
||||||
|
private String nameService;
|
||||||
|
|
||||||
|
@JoinColumn(name = "FUNCIONSISTEMA_ID", referencedColumnName = "FUNCIONSISTEMA_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private FuncionSistema funcionSistema;
|
||||||
|
|
||||||
|
@JoinColumn(name = "AUDITMODULE_ID", referencedColumnName = "AUDITMODULE_ID")
|
||||||
|
@ManyToOne
|
||||||
|
private AuditModule module;
|
||||||
|
|
||||||
|
public Long getAuditServiceId() {
|
||||||
|
return auditServiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditServiceId(Long auditServiceId) {
|
||||||
|
this.auditServiceId = auditServiceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNameService() {
|
||||||
|
return nameService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNameService(String nameService) {
|
||||||
|
this.nameService = nameService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuditModule getModule() {
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModule(AuditModule module) {
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FuncionSistema getFuncionSistema() {
|
||||||
|
return funcionSistema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFuncionSistema(FuncionSistema funcionSistema) {
|
||||||
|
this.funcionSistema = funcionSistema;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.rjconsultores.ventaboletos.enums.auditoria;
|
||||||
|
|
||||||
|
public enum EnumAuditAction {
|
||||||
|
TODOS(-1, "Todos"), CRIACAO(1,"Criação de Registro"), ALTERACAO(2, "Alteração de registro"), EXCLUSAO(3, "Exclusão de Registro");
|
||||||
|
|
||||||
|
private String descricao;
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private EnumAuditAction(Integer id, String descricao) {
|
||||||
|
this.descricao = descricao;
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescricao() {
|
||||||
|
return descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescricao(String descricao) {
|
||||||
|
this.descricao = descricao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String findAction(Integer id) {
|
||||||
|
for (EnumAuditAction action : EnumAuditAction.values()) {
|
||||||
|
if (action.getId() == id) {
|
||||||
|
return action.getDescricao();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return descricao;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
|
||||||
|
public interface AuditLogService extends GenericService<AuditLog, Long>{
|
||||||
|
public List<AuditLog> carregarLog(AuditModule modulo);
|
||||||
|
|
||||||
|
public List<AuditLog> filtrarLog(AuditLog log);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
|
||||||
|
public interface AuditModuleService extends GenericService<AuditModule, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
|
||||||
|
public interface AuditServiceService extends GenericService<AuditService, Long> {
|
||||||
|
public AuditService carregarService(AuditService auditService);
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditLogDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AuditLogService;
|
||||||
|
|
||||||
|
@Service("auditLogService")
|
||||||
|
public class AuditLogServiceImpl implements AuditLogService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuditLogDAO auditLogDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditLog> obtenerTodos() {
|
||||||
|
return auditLogDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditLog obtenerID(Long id) {
|
||||||
|
return auditLogDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditLog suscribir(AuditLog auditLog) {
|
||||||
|
return auditLogDAO.suscribir(auditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditLog actualizacion(AuditLog auditLog) {
|
||||||
|
return auditLogDAO.actualizacion(auditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void borrar(AuditLog auditLog) {
|
||||||
|
auditLogDAO.borrar(auditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditLog> carregarLog(AuditModule modulo) {
|
||||||
|
return auditLogDAO.carregarLog(modulo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditLog> filtrarLog(AuditLog auditLog) {
|
||||||
|
return auditLogDAO.filtrarLog(auditLog);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditModuleDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AuditModuleService;
|
||||||
|
|
||||||
|
@Service("auditModuleService")
|
||||||
|
public class AuditModuleServiceImpl implements AuditModuleService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuditModuleDAO auditModuleDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditModule> obtenerTodos() {
|
||||||
|
return auditModuleDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditModule obtenerID(Long id) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditModule suscribir(AuditModule entidad) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditModule actualizacion(AuditModule entidad) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void borrar(AuditModule entidad) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.AuditServiceDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AuditServiceService;
|
||||||
|
|
||||||
|
@Service("auditServiceService")
|
||||||
|
public class AuditServiceServiceImpl implements AuditServiceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuditServiceDAO auditServiceDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuditService> obtenerTodos() {
|
||||||
|
return auditServiceDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditService obtenerID(Long id) {
|
||||||
|
return auditServiceDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditService suscribir(AuditService entidad) {
|
||||||
|
return auditServiceDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditService actualizacion(AuditService entidad) {
|
||||||
|
return auditServiceDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void borrar(AuditService entidad) {
|
||||||
|
auditServiceDAO.borrar(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuditService carregarService(AuditService auditService) {
|
||||||
|
return auditServiceDAO.carregarService(auditService);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,19 +4,30 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
|
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.interceptor.AuditInterceptor;
|
||||||
import com.rjconsultores.ventaboletos.dao.hibernate.sqlfunction.FnArredondamentoTarifa;
|
import com.rjconsultores.ventaboletos.dao.hibernate.sqlfunction.FnArredondamentoTarifa;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class MyAnnotationSessionFactoryBean extends AnnotationSessionFactoryBean{
|
public class MyAnnotationSessionFactoryBean extends AnnotationSessionFactoryBean{
|
||||||
|
|
||||||
|
|
||||||
public MyAnnotationSessionFactoryBean() {
|
public MyAnnotationSessionFactoryBean() {
|
||||||
super();
|
super();
|
||||||
|
super.setEntityInterceptor(new AuditInterceptor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postProcessAnnotationConfiguration(AnnotationConfiguration config) throws HibernateException {
|
protected void postProcessAnnotationConfiguration(AnnotationConfiguration config) throws HibernateException {
|
||||||
config.addSqlFunction("FN_ARREDONDAMENTO_TARIFA", new FnArredondamentoTarifa());
|
config.addSqlFunction("FN_ARREDONDAMENTO_TARIFA", new FnArredondamentoTarifa());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterSessionFactoryCreation() throws Exception {
|
||||||
|
DBUtil.getInstance().setSessionFactory(this.getSessionFactory());
|
||||||
|
super.afterSessionFactoryCreation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue