fixes bug #0008366
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@66693 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
eb4244c74b
commit
09d96d173c
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
O * To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.Executions;
|
||||||
|
import org.zkoss.zul.Textbox;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditControl;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
|
|
||||||
|
@Controller("auditModuleDetailController")
|
||||||
|
@Scope("prototype")
|
||||||
|
public class AuditModuleDetailController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Textbox txtEntityJson;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
|
|
||||||
|
super.doAfterCompose(comp);
|
||||||
|
|
||||||
|
AuditLog auditLog = (AuditLog) Executions.getCurrent().getArg().get("auditLog");
|
||||||
|
|
||||||
|
Class<?> clazz = Class.forName("com.rjconsultores.ventaboletos.entidad.".concat(auditLog.getEntityName()));
|
||||||
|
|
||||||
|
Object clazzJson = AuditControl.getGson().fromJson(auditLog.getEntityDetail(), clazz);
|
||||||
|
|
||||||
|
txtEntityJson.setValue(AuditControl.formatJson(clazzJson, true));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,450 @@
|
||||||
|
/*
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.zkoss.util.resource.Labels;
|
||||||
|
import org.zkoss.zhtml.Messagebox;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zul.Combobox;
|
||||||
|
import org.zkoss.zul.Comboitem;
|
||||||
|
import org.zkoss.zul.Paging;
|
||||||
|
import org.zkoss.zul.Textbox;
|
||||||
|
import org.zkoss.zul.api.Datebox;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditControl;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditModule;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditService;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Sistema;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.auditoria.EnumAuditAction;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AuditLogService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.AuditModuleService;
|
||||||
|
import com.rjconsultores.ventaboletos.service.SistemaService;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderAudit;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEntityDetail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author eduardo
|
||||||
|
*/
|
||||||
|
@Controller("auditoriaController")
|
||||||
|
@Scope("prototype")
|
||||||
|
public class AuditoriaController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuditModuleService auditModuleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SistemaService sistemaService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AuditLogService auditLogService;
|
||||||
|
|
||||||
|
private List<AuditModule> lsModulo;
|
||||||
|
private List<Sistema> lsAmbiente;
|
||||||
|
private List<EnumAuditAction> lsAcao;
|
||||||
|
|
||||||
|
private Combobox cmbModulo;
|
||||||
|
private Combobox cmbAmbiente;
|
||||||
|
private Combobox cmbAcao;
|
||||||
|
|
||||||
|
private Datebox dtDataInicial;
|
||||||
|
private Datebox dtDataFinal;
|
||||||
|
|
||||||
|
private Textbox txtMdUsuario;
|
||||||
|
private Textbox txtMdCustom;
|
||||||
|
|
||||||
|
private MyListbox auditoriaList;
|
||||||
|
private MyListbox auditoriaModelDetailList;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private transient PagedListWrapper<AuditLog> plwAuditoria;
|
||||||
|
|
||||||
|
private Paging pagingAudit;
|
||||||
|
private Paging pagingModuleDetail;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
|
|
||||||
|
lsModulo = new ArrayList<AuditModule>();
|
||||||
|
AuditModule modulo = new AuditModule();
|
||||||
|
modulo.setNameModule("Todos");
|
||||||
|
|
||||||
|
lsModulo.add(modulo);
|
||||||
|
lsModulo.addAll(auditModuleService.obtenerTodos());
|
||||||
|
|
||||||
|
lsAmbiente = new ArrayList<Sistema>();
|
||||||
|
Sistema sistemaTodos = new Sistema();
|
||||||
|
sistemaTodos.setNombsistema("TODOS");
|
||||||
|
|
||||||
|
lsAmbiente.add(sistemaTodos);
|
||||||
|
lsAmbiente.addAll(sistemaService.obtenerTodos());
|
||||||
|
|
||||||
|
lsAcao = obterAcoes();
|
||||||
|
|
||||||
|
super.doAfterCompose(comp);
|
||||||
|
|
||||||
|
auditoriaList.setItemRenderer(new RenderAudit());
|
||||||
|
auditoriaList.addEventListener("onDoubleClick", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
verDetalhesModulo(auditoriaList.getSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
auditoriaModelDetailList.setItemRenderer(new RenderEntityDetail());
|
||||||
|
auditoriaModelDetailList.addEventListener("onDoubleClick", new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
verDetalhesModulo(auditoriaModelDetailList.getSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refreshLista();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick$btnPesquisa(Event ev) {
|
||||||
|
if ((txtMdCustom.getValue() == null || txtMdCustom.getValue().isEmpty()) &&
|
||||||
|
(txtMdUsuario.getValue() == null || txtMdUsuario.getValue().isEmpty())) {
|
||||||
|
refreshLista();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
gerarLogModelDetail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Paging getPagingAudit() {
|
||||||
|
return pagingAudit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPagingAudit(Paging pagingAudit) {
|
||||||
|
this.pagingAudit = pagingAudit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Combobox getCmbModulo() {
|
||||||
|
return cmbModulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmbModulo(Combobox cmbModulo) {
|
||||||
|
this.cmbModulo = cmbModulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AuditModule> getLsModulo() {
|
||||||
|
return lsModulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLsModulo(List<AuditModule> lsModulo) {
|
||||||
|
this.lsModulo = lsModulo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MyListbox getAuditoriaList() {
|
||||||
|
return auditoriaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditoriaList(MyListbox auditoriaList) {
|
||||||
|
this.auditoriaList = auditoriaList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Sistema> getLsAmbiente() {
|
||||||
|
return lsAmbiente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLsAmbiente(List<Sistema> lsAmbiente) {
|
||||||
|
this.lsAmbiente = lsAmbiente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Combobox getCmbAmbiente() {
|
||||||
|
return cmbAmbiente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmbAmbiente(Combobox cmbAmbiente) {
|
||||||
|
this.cmbAmbiente = cmbAmbiente;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Combobox getCmbAcao() {
|
||||||
|
return cmbAcao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmbAcao(Combobox cmbAcao) {
|
||||||
|
this.cmbAcao = cmbAcao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EnumAuditAction> getLsAcao() {
|
||||||
|
return lsAcao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLsAcao(List<EnumAuditAction> lsAcao) {
|
||||||
|
this.lsAcao = lsAcao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Paging getPagingModuleDetail() {
|
||||||
|
return pagingModuleDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPagingModuleDetail(Paging pagingModuleDetail) {
|
||||||
|
this.pagingModuleDetail = pagingModuleDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshLista() {
|
||||||
|
|
||||||
|
auditoriaList.setVisible(true);
|
||||||
|
auditoriaModelDetailList.setVisible(false);
|
||||||
|
|
||||||
|
HibernateSearchObject<AuditLog> auditBusqueda = new HibernateSearchObject<AuditLog>(AuditLog.class,
|
||||||
|
pagingAudit.getPageSize());
|
||||||
|
|
||||||
|
Comboitem cbiModulo = cmbModulo.getSelectedItem();
|
||||||
|
if (cbiModulo != null) {
|
||||||
|
AuditModule module = (AuditModule) cbiModulo.getValue();
|
||||||
|
|
||||||
|
if (module.getAuditModuleId() != null) {
|
||||||
|
auditBusqueda.addFilterEqual("service.module", module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Date dataInicial = dtDataInicial.getValue();
|
||||||
|
if (dataInicial != null) {
|
||||||
|
auditBusqueda.addFilterGreaterOrEqual("createDate", dataInicial);
|
||||||
|
}
|
||||||
|
|
||||||
|
Date dataFinal = dtDataFinal.getValue();
|
||||||
|
if (dataFinal != null) {
|
||||||
|
auditBusqueda.addFilterLessOrEqual("createDate", dataFinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
Comboitem cbiAmbiente = cmbAmbiente.getSelectedItem();
|
||||||
|
|
||||||
|
if (cbiAmbiente != null) {
|
||||||
|
Sistema sistema = (Sistema) cbiAmbiente.getValue();
|
||||||
|
|
||||||
|
if (sistema.getNombsistema().equals("DIGITACAO")) {
|
||||||
|
try {
|
||||||
|
Messagebox.show("A auditoria não está habilitada para o sistema " + sistema.getNombsistema(),
|
||||||
|
Labels.getLabel("auditoriaController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sistema.getSistemaId() != null) {
|
||||||
|
auditBusqueda.addFilterEqual("sistema", sistema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Comboitem cbiAcao = cmbAcao.getSelectedItem();
|
||||||
|
if (cbiAcao != null) {
|
||||||
|
EnumAuditAction action = (EnumAuditAction) cbiAcao.getValue();
|
||||||
|
if (action != EnumAuditAction.TODOS) {
|
||||||
|
auditBusqueda.addFilterEqual("action", action.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plwAuditoria.init(auditBusqueda, auditoriaList, pagingAudit);
|
||||||
|
|
||||||
|
if (auditoriaList.getData().length == 0) {
|
||||||
|
try {
|
||||||
|
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
||||||
|
Labels.getLabel("auditoriaController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void verDetalhesModulo(Object auditLog) {
|
||||||
|
if (auditLog == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
Map args = new HashMap();
|
||||||
|
args.put("auditLog", auditLog);
|
||||||
|
|
||||||
|
openWindow("/gui/seguridad/auditModuleDetail.zul",
|
||||||
|
Labels.getLabel("auditModuleDetailController.window.title"), args, MODAL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gerarLogModelDetail() {
|
||||||
|
|
||||||
|
auditoriaList.setVisible(false);
|
||||||
|
auditoriaModelDetailList.setVisible(true);
|
||||||
|
|
||||||
|
AuditLog auditLog = new AuditLog();
|
||||||
|
AuditModule module = null;
|
||||||
|
|
||||||
|
Comboitem cbiModulo = cmbModulo.getSelectedItem();
|
||||||
|
if (cbiModulo != null) {
|
||||||
|
module = (AuditModule) cbiModulo.getValue();
|
||||||
|
|
||||||
|
if (module.getAuditModuleId() != null) {
|
||||||
|
AuditService service = new AuditService();
|
||||||
|
service.setModule(module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Date dataInicio = dtDataInicial.getValue();
|
||||||
|
Date dataFim = dtDataFinal.getValue();
|
||||||
|
|
||||||
|
if (dataInicio != null && dataFim != null) {
|
||||||
|
auditLog.setDataInicio(dataInicio);
|
||||||
|
auditLog.setDataFim(dataFim);
|
||||||
|
}
|
||||||
|
|
||||||
|
Comboitem cbiAmbiente = cmbAmbiente.getSelectedItem();
|
||||||
|
|
||||||
|
if (cbiAmbiente != null) {
|
||||||
|
Sistema sistema = (Sistema) cbiAmbiente.getValue();
|
||||||
|
|
||||||
|
if (sistema.getNombsistema().equals("DIGITACAO")) {
|
||||||
|
try {
|
||||||
|
Messagebox.show("A auditoria não está habilitada para o sistema " + sistema.getNombsistema(),
|
||||||
|
Labels.getLabel("auditoriaController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sistema.getSistemaId() != null) {
|
||||||
|
auditLog.setSistema(sistema);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Comboitem cbiAcao = cmbAcao.getSelectedItem();
|
||||||
|
if (cbiAcao != null) {
|
||||||
|
EnumAuditAction action = (EnumAuditAction) cbiAcao.getValue();
|
||||||
|
if (action != EnumAuditAction.TODOS) {
|
||||||
|
auditLog.setAction(action.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AuditLog> logs = auditLogService.filtrarLog(auditLog);
|
||||||
|
|
||||||
|
if (logs == null || logs.size() == 0) {
|
||||||
|
try {
|
||||||
|
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
||||||
|
Labels.getLabel("auditoriaController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!txtMdUsuario.getValue().isEmpty()) {
|
||||||
|
Integer userId = Integer.parseInt(txtMdUsuario.getValue());
|
||||||
|
|
||||||
|
logs = recuperarUserLogs(logs, userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!txtMdCustom.getValue().isEmpty()) {
|
||||||
|
logs = recuperarCustomLogs(logs, txtMdCustom.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logs.size() == 0) {
|
||||||
|
try {
|
||||||
|
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
||||||
|
Labels.getLabel("auditoriaController.window.title"),
|
||||||
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
log.info(ex.getStackTrace());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pagingModuleDetail.setTotalSize(logs.size());
|
||||||
|
auditoriaModelDetailList.setData(logs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick$btnRefresh(Event ev) {
|
||||||
|
refreshLista();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EnumAuditAction> obterAcoes() {
|
||||||
|
List<EnumAuditAction> lsAcao = new ArrayList<EnumAuditAction>();
|
||||||
|
lsAcao.add(EnumAuditAction.TODOS);
|
||||||
|
lsAcao.add(EnumAuditAction.CRIACAO);
|
||||||
|
lsAcao.add(EnumAuditAction.ALTERACAO);
|
||||||
|
lsAcao.add(EnumAuditAction.EXCLUSAO);
|
||||||
|
|
||||||
|
return lsAcao;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AuditLog> recuperarUserLogs(List<AuditLog> logs, Integer userId) {
|
||||||
|
Gson gson = AuditControl.getGson();
|
||||||
|
List<AuditLog> logsUser = new ArrayList<AuditLog>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (AuditLog auditLog : logs) {
|
||||||
|
Class<?> clazz = Class.forName("com.rjconsultores.ventaboletos.entidad.".concat(auditLog.getEntityName()));
|
||||||
|
Object entity = gson.fromJson(auditLog.getEntityDetail(), clazz);
|
||||||
|
|
||||||
|
for (Field field : entity.getClass().getDeclaredFields()) {
|
||||||
|
if (field.getName().equalsIgnoreCase("usuarioid")) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
if (field.get(entity).equals(userId)) {
|
||||||
|
logsUser.add(auditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException classNotFoundException) {
|
||||||
|
log.error(classNotFoundException.getStackTrace());
|
||||||
|
} catch (SecurityException securityException) {
|
||||||
|
log.error(securityException.getStackTrace());
|
||||||
|
} catch (IllegalArgumentException illegalArgumentException) {
|
||||||
|
log.error(illegalArgumentException.getStackTrace());
|
||||||
|
} catch (IllegalAccessException illegalAccessException) {
|
||||||
|
log.error(illegalAccessException.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
|
return logsUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<AuditLog> recuperarCustomLogs(List<AuditLog> logs, String param) {
|
||||||
|
|
||||||
|
List<AuditLog> logsCustom = new ArrayList<AuditLog>();
|
||||||
|
|
||||||
|
for (AuditLog auditLog : logs) {
|
||||||
|
if (auditLog.getEntityDetail().contains(param)) {
|
||||||
|
logsCustom.add(auditLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return logsCustom;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,12 @@ package com.rjconsultores.ventaboletos.web.utilerias.menu;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.jfree.util.Log;
|
||||||
import org.zkoss.zk.ui.Desktop;
|
import org.zkoss.zk.ui.Desktop;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditManager;
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.interceptor.AuditInterceptor;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.labellocator.MenuLabelLocator;
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.labellocator.MenuLabelLocator;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.labellocator.ZKMenuLabelLocator;
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.labellocator.ZKMenuLabelLocator;
|
||||||
|
|
||||||
|
@ -13,6 +17,7 @@ public class DefaultItemMenuSistema implements ItemMenuSistema {
|
||||||
protected MenuLabelLocator menuLabelLocator;
|
protected MenuLabelLocator menuLabelLocator;
|
||||||
protected Desktop desktop;
|
protected Desktop desktop;
|
||||||
protected Boolean isReadOnly;
|
protected Boolean isReadOnly;
|
||||||
|
private static Logger log = Logger.getLogger(DefaultItemMenuSistema.class);
|
||||||
|
|
||||||
public DefaultItemMenuSistema(String claveTraduccionMenu) {
|
public DefaultItemMenuSistema(String claveTraduccionMenu) {
|
||||||
this.menuLabelLocator = ZKMenuLabelLocator.getInstance();
|
this.menuLabelLocator = ZKMenuLabelLocator.getInstance();
|
||||||
|
@ -54,8 +59,15 @@ public class DefaultItemMenuSistema implements ItemMenuSistema {
|
||||||
public Desktop getDesktop() {
|
public Desktop getDesktop() {
|
||||||
return desktop;
|
return desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getIsReadOnly() {
|
public Boolean getIsReadOnly() {
|
||||||
|
try {
|
||||||
|
AuditManager.getINSTANCE(getClaveMenu()).setCheckModuleAudit(Boolean.TRUE);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getStackTrace());
|
||||||
|
}
|
||||||
|
|
||||||
return isReadOnly;
|
return isReadOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad;
|
||||||
|
|
||||||
|
import org.zkoss.util.resource.Labels;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
|
||||||
|
|
||||||
|
|
||||||
|
public class ItemMenuAuditoria extends DefaultItemMenuSistema {
|
||||||
|
public ItemMenuAuditoria() {
|
||||||
|
super("indexController.mniAuditoria.label");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getClaveMenu() {
|
||||||
|
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.SEGURIDAD.MENU.AUDITORIA";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ejecutar() {
|
||||||
|
PantallaUtileria.openWindow("/gui/seguridad/auditoria.zul",
|
||||||
|
Labels.getLabel("auditoriaController.window.title"), getArgs(), desktop);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -190,6 +190,7 @@ seguridad.perfil=com.rjconsultores.ventaboletos.web.utilerias.menu.item.segurida
|
||||||
seguridad.autorizacionPerfil=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuAutorizacionPerfil
|
seguridad.autorizacionPerfil=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuAutorizacionPerfil
|
||||||
seguridad.usuario=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuUsuario
|
seguridad.usuario=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuUsuario
|
||||||
seguridad.fiscalImpressora=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuFiscalImpressora
|
seguridad.fiscalImpressora=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuFiscalImpressora
|
||||||
|
seguridad.auditoria=com.rjconsultores.ventaboletos.web.utilerias.menu.item.seguridad.ItemMenuAuditoria
|
||||||
pasajerofrecuente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.MenuPasajeroFrecuente
|
pasajerofrecuente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.MenuPasajeroFrecuente
|
||||||
pasajerofrecuente.cliente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuCliente
|
pasajerofrecuente.cliente=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuCliente
|
||||||
pasajerofrecuente.importarClientes=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuImportarClientes
|
pasajerofrecuente.importarClientes=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pasajerofrecuente.ItemMenuImportarClientes
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.render;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import org.zkoss.zul.Listcell;
|
||||||
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.ListitemRenderer;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.auditoria.EnumAuditAction;
|
||||||
|
|
||||||
|
public class RenderAudit implements ListitemRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Listitem item, Object o) throws Exception {
|
||||||
|
|
||||||
|
AuditLog auditLog = (AuditLog) o;
|
||||||
|
|
||||||
|
Listcell lc = new Listcell();
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||||
|
sdf.applyPattern("dd/MM/yyyy");
|
||||||
|
|
||||||
|
lc = new Listcell(sdf.format(auditLog.getCreatedDate()));
|
||||||
|
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getSistema().getNombsistema());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getService().getModule().getNameModule());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(EnumAuditAction.findAction(auditLog.getAction()));
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getEntityName());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getUsuario().getNombusuario());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
item.setAttribute("data", auditLog);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.render;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import org.zkoss.zul.Listcell;
|
||||||
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.ListitemRenderer;
|
||||||
|
|
||||||
|
public class RenderAuditModuleDetail implements ListitemRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Listitem item, Object object) throws Exception {
|
||||||
|
|
||||||
|
Listcell lc = null;
|
||||||
|
|
||||||
|
for (Field field : object.getClass().getDeclaredFields()) {
|
||||||
|
|
||||||
|
if (!field.isAnnotationPresent(Column.class) && !field.isAnnotationPresent(Id.class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
String fieldValue = (field.get(object) == null ? "" : field.get(object)).toString();
|
||||||
|
|
||||||
|
lc = new Listcell(fieldValue);
|
||||||
|
lc.setParent(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.render;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import org.zkoss.zul.Listcell;
|
||||||
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.ListitemRenderer;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.rjconsultores.ventaboletos.auditoria.AuditControl;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.AuditLog;
|
||||||
|
import com.rjconsultores.ventaboletos.enums.auditoria.EnumAuditAction;
|
||||||
|
|
||||||
|
public class RenderEntityDetail implements ListitemRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Listitem item, Object object) throws Exception {
|
||||||
|
|
||||||
|
AuditLog auditLog = (AuditLog) object;
|
||||||
|
Listcell lc = new Listcell();
|
||||||
|
|
||||||
|
Gson gson = AuditControl.getGson();
|
||||||
|
Class<?> clazz = Class.forName("com.rjconsultores.ventaboletos.entidad.".concat(auditLog.getEntityName()));
|
||||||
|
|
||||||
|
Object clazzJson = gson.fromJson(auditLog.getEntityDetail(), clazz);
|
||||||
|
|
||||||
|
for (Field field: clazzJson.getClass().getDeclaredFields()) {
|
||||||
|
|
||||||
|
if (!field.isAnnotationPresent(Id.class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
lc = new Listcell((field.get(clazzJson) == null ? "null" : field.get(clazzJson)).toString());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getUsuario().getNombusuario());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(auditLog.getSistema().getNombsistema());
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||||
|
sdf.applyPattern("dd/MM/yyyy");
|
||||||
|
|
||||||
|
lc = new Listcell(sdf.format(auditLog.getCreatedDate()));
|
||||||
|
lc.setParent(item);
|
||||||
|
|
||||||
|
lc = new Listcell(EnumAuditAction.findAction(auditLog.getAction()));
|
||||||
|
lc.setParent(item);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?page contentType="text/html;charset=UTF-8"?>
|
||||||
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winAuditModelDetail"?>
|
||||||
|
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||||
|
|
||||||
|
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||||
|
<window id="winAuditModelDetail" border="normal"
|
||||||
|
apply="${auditModuleDetailController}"
|
||||||
|
width="700px" height="600px" contentStyle="overflow:auto"
|
||||||
|
title="${c:l('auditModuleDetailController.window.title')}">
|
||||||
|
<toolbar>
|
||||||
|
<hbox spacing="5px" style="padding:1px" align="right">
|
||||||
|
<button id="btnFechar" height="20"
|
||||||
|
image="/gui/img/exit.png" width="35px"
|
||||||
|
onClick="winAuditModelDetail.detach()"
|
||||||
|
tooltiptext="${c:l('tooltiptext.btnFechar')}"/>
|
||||||
|
<separator orient="vertical" />
|
||||||
|
</hbox>
|
||||||
|
</toolbar>
|
||||||
|
|
||||||
|
<textbox id="txtEntityJson" rows="50" cols="140" />
|
||||||
|
</window>
|
||||||
|
</zk>
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?page contentType="text/html;charset=UTF-8"?>
|
||||||
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winAuditoria"?>
|
||||||
|
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||||
|
|
||||||
|
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||||
|
<window id="winAuditoria" title="${c:l('auditoriaController.window.title')}"
|
||||||
|
apply="${auditoriaController}" contentStyle="overflow:auto"
|
||||||
|
height="500px" width="1200px" border="normal" >
|
||||||
|
|
||||||
|
<toolbar>
|
||||||
|
<button id="btnRefresh" image="/gui/img/refresh.png" width="35px"
|
||||||
|
tooltiptext="${c:l('auditoriaController.btnRefresh.tooltiptext')}" />
|
||||||
|
<separator orient="vertical" />
|
||||||
|
<button id="btnCerrar" onClick="winAuditoria.detach()" image="/gui/img/exit.png" width="35px"
|
||||||
|
tooltiptext="${c:l('auditoriaController.btnCerrar.tooltiptext')}"/>
|
||||||
|
</toolbar>
|
||||||
|
|
||||||
|
<grid fixedLayout="true">
|
||||||
|
<columns>
|
||||||
|
<column width="15%"/>
|
||||||
|
<column width="75%"/>
|
||||||
|
<column width="15%"/>
|
||||||
|
<column width="75%"/>
|
||||||
|
</columns>
|
||||||
|
<rows>
|
||||||
|
<row>
|
||||||
|
<label value="${c:l('auditoriaController.modulo.label')}"/>
|
||||||
|
<combobox id="cmbModulo"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
|
||||||
|
mold="rounded" buttonVisible="true" width="70%"
|
||||||
|
model="@{winAuditoria$composer.lsModulo}"/>
|
||||||
|
|
||||||
|
<label value="Ambiente:"/>
|
||||||
|
<combobox id="cmbAmbiente"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
|
||||||
|
mold="rounded" buttonVisible="true" width="70%"
|
||||||
|
model="@{winAuditoria$composer.lsAmbiente}"/>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<label value="${c:l('auditoriaController.dataInicial.label')}"/>
|
||||||
|
<datebox id="dtDataInicial" width="220px" mold="rounded" format="dd/MM/yyyy" />
|
||||||
|
|
||||||
|
<label value="Acao"/>
|
||||||
|
<combobox id="cmbAcao"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
|
||||||
|
mold="rounded" buttonVisible="true" width="70%"
|
||||||
|
model="@{winAuditoria$composer.lsAcao}"/>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<label value="${c:l('auditoriaController.dataFinal.label')}"/>
|
||||||
|
<datebox id="dtDataFinal" width="220px" mold="rounded" format="dd/MM/yyyy" />
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row id="rwMdUsuario">
|
||||||
|
<label value="Usuario ID" />
|
||||||
|
<textbox id="txtMdUsuario" width="50%" maxlength="5" />
|
||||||
|
|
||||||
|
<label value="Custom" />
|
||||||
|
<textbox id="txtMdCustom" width="50%" maxlength="400" />
|
||||||
|
</row>
|
||||||
|
</rows>
|
||||||
|
</grid>
|
||||||
|
|
||||||
|
<toolbar>
|
||||||
|
<button id="btnPesquisa" image="/gui/img/find.png"
|
||||||
|
label="${c:l('busquedaEstacionController.btnPesquisa.label')}" />
|
||||||
|
</toolbar>
|
||||||
|
|
||||||
|
<paging id="pagingAudit" pageSize="10"/>
|
||||||
|
<listbox id="auditoriaList" use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
|
||||||
|
multiple="false" height="170px" width="1175px" >
|
||||||
|
<listhead sizable="true">
|
||||||
|
<listheader id="lhData" image="/gui/img/create_doc.gif"
|
||||||
|
label="${c:l('auditoriaController.lhData.label')}"
|
||||||
|
sort="auto(createDate)" width="90px"/>
|
||||||
|
<listheader id="lhAmbiente" image="/gui/img/create_doc.gif"
|
||||||
|
label="${c:l('auditoriaController.lhAmbiente.label')}"
|
||||||
|
sort="auto(sistema)" width="200px"/>
|
||||||
|
<listheader id="lhModulo" image="/gui/img/create_doc.gif"
|
||||||
|
label="${c:l('auditoriaController.lhModulo.label')}"
|
||||||
|
sort="auto(auditServiceId)" width="280px" />
|
||||||
|
<listheader id="lhAcao" image="/gui/img/create_doc.gif"
|
||||||
|
label="${c:l('auditoriaController.lhAcao.label')}"
|
||||||
|
sort="auto(action)" width="50%" />
|
||||||
|
<listheader id="lhEntidade" image="/gui/img/create_doc.gif"
|
||||||
|
label="Entidade" sort="auto(entityName)" width="50%" />
|
||||||
|
<listheader id="lhUsuario" image="/gui/img/create_doc.gif"
|
||||||
|
label="Usuario" sort="auto(usuario)" width="100%" />
|
||||||
|
</listhead>
|
||||||
|
</listbox>
|
||||||
|
|
||||||
|
<paging id="pagingModuleDetail" pageSize="10" visible="false" />
|
||||||
|
<listbox id="auditoriaModelDetailList" use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
|
||||||
|
multiple="false" height="170px" width="1200px" visible="false" >
|
||||||
|
<listhead sizable="true">
|
||||||
|
<listheader id="lhMDId" image="/gui/img/create_doc.gif"
|
||||||
|
label="ID" />
|
||||||
|
<listheader id="lhMDUsuario" image="/gui/img/create_doc.gif"
|
||||||
|
label="Usuario" />
|
||||||
|
<listheader id="lhMDSistema" image="/gui/img/create_doc.gif"
|
||||||
|
label="Ambiente" />
|
||||||
|
<listheader id="lhMDData" image="/gui/img/create_doc.gif"
|
||||||
|
label="Data Alteracao" />
|
||||||
|
<listheader id="lhMDAcao" image="/gui/img/create_doc.gif"
|
||||||
|
label="Acao" />
|
||||||
|
</listhead>
|
||||||
|
</listbox>
|
||||||
|
</window>
|
||||||
|
</zk>
|
Loading…
Reference in New Issue