diff --git a/src/com/rjconsultores/ventaboletos/entidad/EsquemaCorrida.java b/src/com/rjconsultores/ventaboletos/entidad/EsquemaCorrida.java index bfda8473e..a3cdb9709 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/EsquemaCorrida.java +++ b/src/com/rjconsultores/ventaboletos/entidad/EsquemaCorrida.java @@ -40,7 +40,7 @@ import br.com.rjconsultores.auditador.interfaces.Auditavel; @Entity @SequenceGenerator(name = "ESQUEMA_CORRIDA_SEQ", sequenceName = "ESQUEMA_CORRIDA_SEQ", allocationSize = 1) @Table(name = "ESQUEMA_CORRIDA") -@AuditarClasse(nome = "ESQUEMA_CORRIDA", campoEmpresa = "empresa", tela = "Configuração de Serviços") +@AuditarClasse(nome = "ESQUEMA_CORRIDA", tela = "Configuração de Serviços") public class EsquemaCorrida implements Serializable, Auditavel { private static final long serialVersionUID = 1L; diff --git a/src/com/rjconsultores/ventaboletos/entidad/Tarifa.java b/src/com/rjconsultores/ventaboletos/entidad/Tarifa.java index 3d7b0fec0..16be316b4 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/Tarifa.java +++ b/src/com/rjconsultores/ventaboletos/entidad/Tarifa.java @@ -40,7 +40,7 @@ import br.com.rjconsultores.auditador.interfaces.AuditavelTelaAlternativa; @Entity @SequenceGenerator(name = "TARIFA_SEQ", sequenceName = "TARIFA_SEQ", allocationSize = 1) @Table(name = "TARIFA") -@AuditarClasse(nome = "TARIFA", tela = "Alteração de Preço", campoEmpresa = "empresaId") +@AuditarClasse(nome = "TARIFA", tela = "Alteração de Preço") public class Tarifa implements Serializable, Auditavel, AuditavelTelaAlternativa { private static final long serialVersionUID = 1L; @@ -162,9 +162,6 @@ public class Tarifa implements Serializable, Auditavel, AuditavelTelaAlt @Transient private String telaAlternativa; - @Transient - private Integer empresaId; - public Tarifa() { } @@ -415,7 +412,6 @@ public class Tarifa implements Serializable, Auditavel, AuditavelTelaAlt public void clonar() throws CloneNotSupportedException { tarifaClone = new Tarifa(); tarifaClone = (Tarifa) this.clone(); - tarifaClone.setEmpresaId(this.getMarca() != null && this.getMarca().getEmpresa() != null ? this.getMarca().getEmpresa().getEmpresaId() : null); } @Override @@ -428,14 +424,6 @@ public class Tarifa implements Serializable, Auditavel, AuditavelTelaAlt return String.format("ID [%s]", getTarifaId()); } - public Integer getEmpresaId() { - return empresaId; - } - - public void setEmpresaId(Integer empresaId) { - this.empresaId = empresaId; - } - public void setTelaAlternativa(String telaAlternativa) { this.telaAlternativa = telaAlternativa; } diff --git a/src/com/rjconsultores/ventaboletos/entidad/TarifaOficial.java b/src/com/rjconsultores/ventaboletos/entidad/TarifaOficial.java index 8906065a0..5e60613f4 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/TarifaOficial.java +++ b/src/com/rjconsultores/ventaboletos/entidad/TarifaOficial.java @@ -27,7 +27,7 @@ import br.com.rjconsultores.auditador.interfaces.Auditavel; @Entity @SequenceGenerator(name = "TARIFA_OFICIAL_SEQ", sequenceName = "TARIFA_OFICIAL_SEQ", allocationSize = 1) @Table(name = "TARIFA_OFICIAL") -@AuditarClasse(nome = "TARIFA", tela = "Alteração de Preço / Tarifa Oficial", campoEmpresa = "empresaId") +@AuditarClasse(nome = "TARIFA", tela = "Alteração de Preço / Tarifa Oficial") public class TarifaOficial implements Serializable, Auditavel { private static final long serialVersionUID = 1L; diff --git a/src/com/rjconsultores/ventaboletos/service/LogAuditoriaService.java b/src/com/rjconsultores/ventaboletos/service/LogAuditoriaService.java index a5a3ffb74..82fec3cb5 100644 --- a/src/com/rjconsultores/ventaboletos/service/LogAuditoriaService.java +++ b/src/com/rjconsultores/ventaboletos/service/LogAuditoriaService.java @@ -8,12 +8,12 @@ import br.com.rjconsultores.auditador.model.AuditadorObjects; public interface LogAuditoriaService extends GenericService { - public void auditar(Object objetoOriginal, Object objetoNovo); + public void auditar(Object objetoOriginal, Object objetoNovo, Integer empresaId); - public void auditarExclusao(Object objeto); + public void auditarExclusao(Object objeto, Integer empresaId); public List listarTodasAsTelas(); - public void suscribir(List lsObjects); + public void suscribir(List lsObjects, Integer empresaId); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EsquemaCorridaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EsquemaCorridaServiceImpl.java index d65523f07..39af4b8b3 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EsquemaCorridaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EsquemaCorridaServiceImpl.java @@ -104,7 +104,7 @@ public class EsquemaCorridaServiceImpl implements EsquemaCorridaService { entidad = esquemaCorridaDAO.actualizacion(entidad); - logAuditoriaService.auditar(null, entidad); + logAuditoriaService.auditar(null, entidad, entidad.getEmpresa() != null ? entidad.getEmpresa().getEmpresaId() : null); return entidad; } @@ -133,7 +133,7 @@ public class EsquemaCorridaServiceImpl implements EsquemaCorridaService { novoClone.setEsquemaAsientoList(lsNovoAsientos); } - logAuditoriaService.auditar(clone, entidad.getCloneObject()); + logAuditoriaService.auditar(clone, entidad.getCloneObject(), entidad.getEmpresa() != null ? entidad.getEmpresa().getEmpresaId() : null); return entidad; } catch (Exception e) { @@ -162,7 +162,7 @@ public class EsquemaCorridaServiceImpl implements EsquemaCorridaService { entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.FALSE); - logAuditoriaService.auditarExclusao(entidad); + logAuditoriaService.auditarExclusao(entidad, entidad.getEmpresa() != null ? entidad.getEmpresa().getEmpresaId() : null); esquemaCorridaDAO.actualizacion(entidad); } @@ -247,7 +247,7 @@ public class EsquemaCorridaServiceImpl implements EsquemaCorridaService { } novoClone.setEsquemaTramoList(lsTramosNovo); - logAuditoriaService.auditar(originalClone, novoClone); + logAuditoriaService.auditar(originalClone, novoClone, ec.getEmpresa() != null ? ec.getEmpresa().getEmpresaId() : null); } catch (Exception e) { log.error(e.getMessage(), e); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/LogAuditoriaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/LogAuditoriaServiceImpl.java index ef64bed49..70b13f6c4 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/LogAuditoriaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/LogAuditoriaServiceImpl.java @@ -65,22 +65,22 @@ public class LogAuditoriaServiceImpl implements LogAuditoriaService { @Override @Transactional - public void auditar(Object original, Object novo) { + public void auditar(Object original, Object novo, Integer empresaId) { try { - log.info(String.format(":: Iniciando gravação registros de auditoria classe: %s", novo.getClass().toString())); + log.info(String.format(":: Iniciando gravação registros de auditoria classe: %s", novo.getClass().getSimpleName())); Integer totalRegistrosAuditados = 0; List lista = Auditador.getInstance().auditar(original, novo); if(lista != null && !lista.isEmpty()) { - suscribir(lista); + suscribir(lista, empresaId); totalRegistrosAuditados = lista.size(); } - log.info(String.format(":: Iniciando gravação registros de auditoria classe: %s - Total Registros auditados: %d", novo.getClass().toString(), totalRegistrosAuditados)); + log.info(String.format(":: Fim gravação registros de auditoria classe: %s - Total Registros auditados: %d", novo.getClass().getSimpleName(), totalRegistrosAuditados)); } catch (Exception e) { log.error(e.getMessage(), e); } } - private LogAuditoria convertToLogAuditoria(AuditadorObjects log) { + private LogAuditoria convertToLogAuditoria(AuditadorObjects log, Integer empresaId) { LogAuditoria logAuditoria = new LogAuditoria(); logAuditoria.setUsuario(UsuarioLogado.getUsuarioLogado()); logAuditoria.setFecmodif(Calendar.getInstance().getTime()); @@ -94,24 +94,24 @@ public class LogAuditoriaServiceImpl implements LogAuditoriaService { logAuditoria.setValorNovo(log.getValorNovo() != null ? log.getValorNovo().toUpperCase() : null); logAuditoria.setIdAuditado(log.getIdAuditado()); - if(log.getEmpresaId() != null) { - logAuditoria.setEmpresa(new Empresa(log.getEmpresaId())); + if(empresaId != null) { + logAuditoria.setEmpresa(new Empresa(empresaId)); } return logAuditoria; } @Override @Transactional - public void auditarExclusao(Object objeto) { + public void auditarExclusao(Object objeto, Integer empresaId) { try { log.info(String.format(":: Iniciando gravação registros de auditoria de exclusao classe: %s", objeto.getClass().getSimpleName())); Integer totalRegistrosAuditados = 0; List lista = Auditador.getInstance().auditarExclusao(objeto); if(lista != null && !lista.isEmpty()) { - suscribir(lista); + suscribir(lista, empresaId); totalRegistrosAuditados = lista.size(); } - log.info(String.format(":: Iniciando gravação registros de auditoria de exclusao classe: %s - Total Registros auditados: %d", objeto.getClass().getSimpleName(), totalRegistrosAuditados)); + log.info(String.format(":: Fim gravação registros de auditoria de exclusao classe: %s - Total Registros auditados: %d", objeto.getClass().getSimpleName(), totalRegistrosAuditados)); } catch (Exception e) { log.error(e.getMessage(), e); } @@ -124,9 +124,9 @@ public class LogAuditoriaServiceImpl implements LogAuditoriaService { @Override @Transactional - public void suscribir(List lsObjects) { + public void suscribir(List lsObjects, Integer empresaId) { for (AuditadorObjects auditado : lsObjects) { - LogAuditoria logAuditoria = convertToLogAuditoria(auditado); + LogAuditoria logAuditoria = convertToLogAuditoria(auditado, empresaId); suscribir(logAuditoria); } } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TarifaOficialServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TarifaOficialServiceImpl.java index fdfed24c8..4eb77a37a 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TarifaOficialServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TarifaOficialServiceImpl.java @@ -252,8 +252,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService { try { TarifaOficial originalClone = tarifaOficial.getCloneObject(); tarifaOficialDAO.actualizacion(tarifaOficial); - tarifaOficial.setEmpresaId(tarifaOficial.getMarca() != null && tarifaOficial.getMarca().getEmpresa() != null ? tarifaOficial.getMarca().getEmpresa().getEmpresaId() : null); - logAuditoriaService.auditar(originalClone, tarifaOficial); + logAuditoriaService.auditar(originalClone, tarifaOficial, tarifaOficial.getMarca() != null && tarifaOficial.getMarca().getEmpresa() != null ? tarifaOficial.getMarca().getEmpresa().getEmpresaId() : null); } catch (Exception e) { log.error(e.getMessage(), e); throw new RuntimeException(e.getMessage(), e); @@ -275,8 +274,7 @@ public class TarifaOficialServiceImpl implements TarifaOficialService { @Transactional public void borrar(TarifaOficial tarifaOficial) { tarifaOficialDAO.borrar(tarifaOficial); - tarifaOficial.setEmpresaId(tarifaOficial.getMarca() != null && tarifaOficial.getMarca().getEmpresa() != null ? tarifaOficial.getMarca().getEmpresa().getEmpresaId() : null); - logAuditoriaService.auditarExclusao(tarifaOficial); + logAuditoriaService.auditarExclusao(tarifaOficial, tarifaOficial.getMarca() != null && tarifaOficial.getMarca().getEmpresa() != null ? tarifaOficial.getMarca().getEmpresa().getEmpresaId() : null); } @Override diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TarifaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TarifaServiceImpl.java index e4e14e04b..942463bf5 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TarifaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TarifaServiceImpl.java @@ -115,9 +115,7 @@ public class TarifaServiceImpl implements TarifaService { } cadastrarTarifaHistorico(entidad); - entidad.setEmpresaId(entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); - - logAuditoriaService.auditar(null, entidad); + logAuditoriaService.auditar(null, entidad, entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); return tarifaDAO.suscribir(entidad); @@ -155,9 +153,7 @@ public class TarifaServiceImpl implements TarifaService { tarifaDAO.updateTarifa(entidad); - entidad.setEmpresaId(entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); - - logAuditoriaService.auditar(originalClone, entidad); + logAuditoriaService.auditar(originalClone, entidad, entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); return entidad; @@ -187,9 +183,7 @@ public class TarifaServiceImpl implements TarifaService { cadastrarTarifaHistorico(entidad); - entidad.setEmpresaId(entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); - - logAuditoriaService.auditarExclusao(entidad); + logAuditoriaService.auditarExclusao(entidad, entidad.getMarca() != null && entidad.getMarca().getEmpresa() != null ? entidad.getMarca().getEmpresa().getEmpresaId() : null); tarifaDAO.actualizacion(entidad); } @@ -290,9 +284,7 @@ public class TarifaServiceImpl implements TarifaService { tarifa = tarifaDAO.suscribir(tarifa); - tarifa.setEmpresaId(tarifa.getMarca() != null && tarifa.getMarca().getEmpresa() != null ? tarifa.getMarca().getEmpresa().getEmpresaId() : null); - - logAuditoriaService.auditar(null, tarifa); + logAuditoriaService.auditar(null, tarifa, tarifa.getMarca() != null && tarifa.getMarca().getEmpresa() != null ? tarifa.getMarca().getEmpresa().getEmpresaId() : null); } } }