diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaPerfilController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaPerfilController.java index e71f5fdce..cfba99001 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaPerfilController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/BusquedaPerfilController.java @@ -4,17 +4,10 @@ */ package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad; -import com.rjconsultores.ventaboletos.entidad.Perfil; -import com.rjconsultores.ventaboletos.service.PerfilService; -import com.rjconsultores.ventaboletos.service.RutaService; -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.RenderPerfil; import java.util.HashMap; -import java.util.List; import java.util.Map; + +import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; @@ -26,89 +19,122 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zul.Paging; import org.zkoss.zul.Textbox; +import com.rjconsultores.ventaboletos.entidad.Perfil; +import com.rjconsultores.ventaboletos.entidad.Usuario; +import com.rjconsultores.ventaboletos.service.PerfilService; +import com.rjconsultores.ventaboletos.service.UsuarioService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +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.RenderPerfil; +import com.trg.search.Filter; + /** - * + * * @author rodrigo */ @Controller("busquedaPerfilController") @Scope("prototype") public class BusquedaPerfilController extends MyGenericForwardComposer { - @Autowired - private transient PagedListWrapper plwPerfil; - private MyListbox perfilList; - private Paging pagingPerfil; - private Textbox txtNome; - private PerfilService perfilService; + private static final long serialVersionUID = 1L; + private static Logger log = Logger.getLogger(BusquedaPerfilController.class); - @Override - public void doAfterCompose(Component comp) throws Exception { - super.doAfterCompose(comp); + @Autowired + private transient PagedListWrapper plwPerfil; + @Autowired + private PerfilService perfilService; + @Autowired + private UsuarioService usuarioService; - perfilList.setItemRenderer(new RenderPerfil()); - - perfilList.addEventListener("onDoubleClick", new EventListener() { + private MyListbox perfilList; + private Paging pagingPerfil; + private Textbox txtNome; - @Override - public void onEvent(Event event) throws Exception { - Perfil s = (Perfil) perfilList.getSelected(); - verSistema(s); - } - }); + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); - refreshLista(); + perfilList.setItemRenderer(new RenderPerfil()); - txtNome.focus(); - } + perfilList.addEventListener("onDoubleClick", new EventListener() { - private void verSistema(Perfil s) { - if (s == null) { - return; - } + @Override + public void onEvent(Event event) throws Exception { + Perfil s = (Perfil) perfilList.getSelected(); + verSistema(s); + } + }); - Map args = new HashMap(); - args.put("perfil", s); - args.put("perfilList", perfilList); + refreshLista(); - openWindow("/gui/seguridad/editarPerfil.zul", - Labels.getLabel("editarPerfilController.window.title"), args, MODAL); - } + txtNome.focus(); + } - private void refreshLista() { - HibernateSearchObject sistemaBusqueda = - new HibernateSearchObject(Perfil.class, - pagingPerfil.getPageSize()); - - String descPerfil = txtNome.getText(); - if (descPerfil != null) { - sistemaBusqueda.addFilterLike("descperfil", "%" + descPerfil.trim().concat("%")); - } - - sistemaBusqueda.addSortAsc("descperfil"); - sistemaBusqueda.addFilterEqual("activo", Boolean.TRUE); - - plwPerfil.init(sistemaBusqueda, perfilList, pagingPerfil); - perfilList.removeItem(perfilService.buscar("RJ").get(0)); - if (perfilList.getData().length == 0) { - try { - Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), - Labels.getLabel("busquedaPerfilController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); - } catch (InterruptedException ex) { - } - } - - } + private void verSistema(Perfil s) throws InterruptedException { + if (s == null) { + return; + } - public void onClick$btnPesquisa(Event ev) { - refreshLista(); - } + Map args = new HashMap(); + args.put("perfil", s); + args.put("perfilList", perfilList); - public void onClick$btnRefresh(Event ev) { - refreshLista(); - } + openWindow("/gui/seguridad/editarPerfil.zul", + Labels.getLabel("editarPerfilController.window.title"), args, MODAL); + } - public void onClick$btnNovo(Event ev) { - verSistema(new Perfil()); - } + private void refreshLista() { + HibernateSearchObject sistemaBusqueda = + new HibernateSearchObject(Perfil.class, + pagingPerfil.getPageSize()); + + String descPerfil = txtNome.getText(); + if (descPerfil != null) { + sistemaBusqueda.addFilterLike("descperfil", "%" + descPerfil.trim().concat("%")); + } + + sistemaBusqueda.addSortAsc("descperfil"); + sistemaBusqueda.addFilterEqual("activo", Boolean.TRUE); + + Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + Perfil perfilUsuario = usuarioLogado.getUsuarioPerfilList().get(0).getPerfil(); + PerfilJerarquia usuarioJerarquia = PerfilJerarquia.buscar(perfilUsuario.getIndJerarquia()); + + if (!usuarioJerarquia.equals(PerfilJerarquia.ADMIN)) { + if (!usuarioJerarquia.equals(PerfilJerarquia.NORMAL)) { + sistemaBusqueda.addFilterOr(new Filter("indJerarquia", perfilUsuario.getIndJerarquia(), Filter.OP_GREATER_OR_EQUAL), + new Filter("indJerarquia", PerfilJerarquia.NORMAL.getValor(), Filter.OP_LESS_OR_EQUAL)); + } else { + sistemaBusqueda.addFilterEqual("indJerarquia", PerfilJerarquia.NORMAL.getValor()); + } + } + + plwPerfil.init(sistemaBusqueda, perfilList, pagingPerfil); + perfilList.removeItem(perfilService.buscar("RJ").get(0)); + if (perfilList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("busquedaPerfilController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + log.error("", ex); + } + } + + } + + public void onClick$btnPesquisa(Event ev) { + refreshLista(); + } + + public void onClick$btnRefresh(Event ev) { + refreshLista(); + } + + public void onClick$btnNovo(Event ev) throws InterruptedException { + verSistema(new Perfil()); + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarPerfilController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarPerfilController.java index 2675cbb20..bc03016fb 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarPerfilController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarPerfilController.java @@ -44,326 +44,327 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPermiso; /** - * + * * @author rodrigo */ @Controller("editarPerfilController") @Scope("prototype") public class EditarPerfilController extends MyGenericForwardComposer { - @Autowired - private PerfilService perfilService; - @Autowired - private FuncionSistemaService funcionSistemaService; - @Autowired - private PerfilFuncionService perfilFuncionService; - private Perfil perfil; - private MyListbox perfilList; - private MyListbox permisoList; - private Textbox txtDescPerfil; - private List lsFuncionSistema; - private List lsAllFuncionPerfil; - private List lsPermiso; - private Combobox cmbFuncionSistema; - private Button btnApagar; - private Window winEditarPerfil; - private Radiogroup indPermiso; - private Radio radReadOnly; - private Radio radWrite; - private static Logger log = Logger.getLogger(EditarPerfilController.class); + private static final long serialVersionUID = 1L; + private static Logger log = Logger.getLogger(EditarPerfilController.class); - public Perfil getPerfil() { - return perfil; - } + @Autowired + private PerfilService perfilService; + @Autowired + private FuncionSistemaService funcionSistemaService; + @Autowired + private PerfilFuncionService perfilFuncionService; + private Perfil perfil; + private MyListbox perfilList; + private MyListbox permisoList; + private Textbox txtDescPerfil; + private List lsFuncionSistema; + private List lsAllFuncionPerfil; + private List lsPermiso; + private Combobox cmbFuncionSistema; + private Button btnApagar; + private Window winEditarPerfil; + private Radiogroup indPermiso; + private Radio radReadOnly; + private Radio radWrite; - public void setPerfil(Perfil perfil) { - this.perfil = perfil; - } + public Perfil getPerfil() { + return perfil; + } - public Combobox getCmbFuncionSistema() { - return cmbFuncionSistema; - } + public void setPerfil(Perfil perfil) { + this.perfil = perfil; + } - public void setCmbFuncionSistema(Combobox cmbFuncionSistema) { - this.cmbFuncionSistema = cmbFuncionSistema; - } + public Combobox getCmbFuncionSistema() { + return cmbFuncionSistema; + } - public List getLsFuncionSistema() { - return lsFuncionSistema; - } + public void setCmbFuncionSistema(Combobox cmbFuncionSistema) { + this.cmbFuncionSistema = cmbFuncionSistema; + } - public void setLsFuncionSistema(List lsFuncionSistema) { - this.lsFuncionSistema = lsFuncionSistema; - } + public List getLsFuncionSistema() { + return lsFuncionSistema; + } - public Button getBtnApagar() { - return btnApagar; - } + public void setLsFuncionSistema(List lsFuncionSistema) { + this.lsFuncionSistema = lsFuncionSistema; + } - public void setBtnApagar(Button btnApagar) { - this.btnApagar = btnApagar; - } + public Button getBtnApagar() { + return btnApagar; + } - @Override - public void doAfterCompose(Component comp) throws Exception { - lsFuncionSistema = funcionSistemaService.obtenerTodos(); - lsAllFuncionPerfil = new ArrayList(); + public void setBtnApagar(Button btnApagar) { + this.btnApagar = btnApagar; + } - super.doAfterCompose(comp); + @Override + public void doAfterCompose(Component comp) throws Exception { + lsFuncionSistema = funcionSistemaService.obtenerTodos(); + lsAllFuncionPerfil = new ArrayList(); - permisoList.setItemRenderer(new RenderPermiso()); - - permisoList.addEventListener("onDoubleClick", new EventListener() { + super.doAfterCompose(comp); + + permisoList.setItemRenderer(new RenderPermiso()); + + permisoList.addEventListener("onDoubleClick", new EventListener() { @Override public void onEvent(Event event) throws Exception { - PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected(); - abrirPefilFuncion(pf); + PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected(); + abrirPefilFuncion(pf); } }); - perfil = (Perfil) Executions.getCurrent().getArg().get("perfil"); - if (perfil.getPerfilId() != null) { - perfil = perfilService.obtenerID(perfil.getPerfilId()); + perfil = (Perfil) Executions.getCurrent().getArg().get("perfil"); + if (perfil.getPerfilId() != null) { + perfil = perfilService.obtenerID(perfil.getPerfilId()); - for (FuncionSistema fas : lsFuncionSistema) { - for (PerfilFuncion pf : perfil.getPerfilFuncionList()) { - FuncionSistema fs = pf.getFuncionSistema(); - if (fas.equals(fs)) { - lsAllFuncionPerfil.add(fas); - } - } - } - } + for (FuncionSistema fas : lsFuncionSistema) { + for (PerfilFuncion pf : perfil.getPerfilFuncionList()) { + FuncionSistema fs = pf.getFuncionSistema(); + if (fas.equals(fs)) { + lsAllFuncionPerfil.add(fas); + } + } + } + } - perfilList = (MyListbox) Executions.getCurrent().getArg().get("perfilList"); + perfilList = (MyListbox) Executions.getCurrent().getArg().get("perfilList"); - if (perfil.getPerfilFuncionList() == null) { - lsPermiso = new ArrayList(); - } else { - lsPermiso = perfil.getPerfilFuncionList(); - Collections.sort(lsPermiso, new Comparator() { + if (perfil.getPerfilFuncionList() == null) { + lsPermiso = new ArrayList(); + } else { + lsPermiso = perfil.getPerfilFuncionList(); + Collections.sort(lsPermiso, new Comparator() { @Override public int compare(PerfilFuncion o1, PerfilFuncion o2) { return o1.getFuncionSistema().getNombfuncion().compareTo(o2.getFuncionSistema().getNombfuncion()); } - + }); - } - permisoList.setData(lsPermiso); + } + permisoList.setData(lsPermiso); - if (perfil.getPerfilId() == null) { - btnApagar.setVisible(Boolean.FALSE); - } - cmbFuncionSistema.setItemRenderer(new ComboitemRenderer() { + if (perfil.getPerfilId() == null) { + btnApagar.setVisible(Boolean.FALSE); + } + cmbFuncionSistema.setItemRenderer(new ComboitemRenderer() { - @Override - public void render(Comboitem cmbtm, Object o) throws Exception { - FuncionSistema fsItem = (FuncionSistema) o; - for (FuncionSistema fs : lsAllFuncionPerfil) { - if (fsItem.getFuncionsistemaId().equals(fs.getFuncionsistemaId())) { - cmbtm.setVisible(false); - } - } - cmbtm.setLabel(fsItem.getNombfuncion()); - cmbtm.setValue(fsItem); - } - }); + @Override + public void render(Comboitem cmbtm, Object o) throws Exception { + FuncionSistema fsItem = (FuncionSistema) o; + for (FuncionSistema fs : lsAllFuncionPerfil) { + if (fsItem.getFuncionsistemaId().equals(fs.getFuncionsistemaId())) { + cmbtm.setVisible(false); + } + } + cmbtm.setLabel(fsItem.getNombfuncion()); + cmbtm.setValue(fsItem); + } + }); - winEditarPerfil.addEventListener("onClose", new EventListener() { + winEditarPerfil.addEventListener("onClose", new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - txtDescPerfil.getText(); - if (lsPermiso.isEmpty()) { - Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.INFORMATION); + @Override + public void onEvent(Event event) throws Exception { + txtDescPerfil.getText(); + if (lsPermiso.isEmpty()) { + Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.INFORMATION); + } + event.stopPropagation(); - } - event.stopPropagation(); + } + }); - } - }); + txtDescPerfil.focus(); + } - txtDescPerfil.focus(); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) public void abrirPefilFuncion(PerfilFuncion perfilFuncion) { Map args = new HashMap(); args.put("perfilFuncion", perfilFuncion); args.put("permisoList", permisoList); - openWindow("/gui/seguridad/editarPerfilFuncion.zul", - Labels.getLabel("editarPerfilController.window.title"), args, MODAL); + openWindow("/gui/seguridad/editarPerfilFuncion.zul", + Labels.getLabel("editarPerfilController.window.title"), args, MODAL); } - private boolean duplicado() { - List listPerfil = perfilService.buscar(txtDescPerfil.getText()); - if (listPerfil.isEmpty()) { - return false; - } - boolean duplicado = true; + private boolean duplicado() { + List listPerfil = perfilService.buscar(txtDescPerfil.getText()); + if (listPerfil.isEmpty()) { + return false; + } + boolean duplicado = true; - if (perfil.getPerfilId() == null) { - return true; - } + if (perfil.getPerfilId() == null) { + return true; + } - for (Perfil p : listPerfil) { - if (p.getPerfilId().equals(perfil.getPerfilId())) { - duplicado = false; - } - } + for (Perfil p : listPerfil) { + if (p.getPerfilId().equals(perfil.getPerfilId())) { + duplicado = false; + } + } - return duplicado; - } + return duplicado; + } - public void onClick$btnSalvar(Event ev) { - txtDescPerfil.getText(); + public void onClick$btnSalvar(Event ev) { + txtDescPerfil.getText(); - try { - if (lsPermiso.isEmpty()) { - Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.INFORMATION); + try { + if (lsPermiso.isEmpty()) { + Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.INFORMATION); - return; - } + return; + } - if (duplicado()) { - Clients.alert(Labels.getLabel("MSG.Registro.Existe"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.INFORMATION); + if (duplicado()) { + Clients.alert(Labels.getLabel("MSG.Registro.Existe"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.INFORMATION); - return; - } + return; + } - perfil.setActivo(Boolean.TRUE); - perfil.setFecmodif(Calendar.getInstance().getTime()); - perfil.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - perfil.setPerfilFuncionList(lsPermiso); + perfil.setActivo(Boolean.TRUE); + perfil.setFecmodif(Calendar.getInstance().getTime()); + perfil.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + perfil.setPerfilFuncionList(lsPermiso); - if (perfil.getPerfilId() == null) { - perfilService.suscribir(perfil); - perfilList.addItem(perfil); - } else { - perfilService.actualizacion(perfil); - perfilList.updateItem(perfil); - } + if (perfil.getPerfilId() == null) { + perfilService.suscribir(perfil); + perfilList.addItem(perfil); + } else { + perfilService.actualizacion(perfil); + perfilList.updateItem(perfil); + } - Messagebox.show( - Labels.getLabel("editarPerfilController.MSG.suscribirOK"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); + Messagebox.show( + Labels.getLabel("editarPerfilController.MSG.suscribirOK"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); - closeWindow(); - } catch (Exception ex) { - log.error(ex); - Clients.alert( - Labels.getLabel("MSG.Error"), - Labels.getLabel("editarEstacionController.window.title"), - Messagebox.INFORMATION); - } - } + closeWindow(); + } catch (Exception ex) { + log.error(ex); + Clients.alert( + Labels.getLabel("MSG.Error"), + Labels.getLabel("editarEstacionController.window.title"), + Messagebox.INFORMATION); + } + } - public void onClick$btnApagar(Event ev) { - try { - int resp = Messagebox.show( - Labels.getLabel("editarPerfilController.MSG.borrarPergunta"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + public void onClick$btnApagar(Event ev) { + try { + int resp = Messagebox.show( + Labels.getLabel("editarPerfilController.MSG.borrarPergunta"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); - if (resp == Messagebox.YES) { - for (PerfilFuncion pf : perfil.getPerfilFuncionList()) { - pf.setActivo(Boolean.FALSE); - pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - pf.setFecmodif(Calendar.getInstance().getTime()); - } + if (resp == Messagebox.YES) { + for (PerfilFuncion pf : perfil.getPerfilFuncionList()) { + pf.setActivo(Boolean.FALSE); + pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + pf.setFecmodif(Calendar.getInstance().getTime()); + } - perfilService.borrar(perfil); + perfilService.borrar(perfil); - Messagebox.show( - Labels.getLabel("editarPerfilController.MSG.borrarOK"), - Labels.getLabel("editarPerfilController.window.title"), - Messagebox.OK, Messagebox.INFORMATION); + Messagebox.show( + Labels.getLabel("editarPerfilController.MSG.borrarOK"), + Labels.getLabel("editarPerfilController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); - perfilList.removeItem(perfil); + perfilList.removeItem(perfil); - closeWindow(); - } - } catch (Exception ex) { - log.error(ex); - Clients.alert( - Labels.getLabel("MSG.Error"), - Labels.getLabel("editarEstacionController.window.title"), - Messagebox.INFORMATION); - } - } + closeWindow(); + } + } catch (Exception ex) { + log.error(ex); + Clients.alert( + Labels.getLabel("MSG.Error"), + Labels.getLabel("editarEstacionController.window.title"), + Messagebox.INFORMATION); + } + } - public void onClick$btnAdicionarPermiso(Event ev) { - Comboitem comboItem = cmbFuncionSistema.getSelectedItem(); - if (comboItem != null && indPermiso.getSelectedItem() != null) { - FuncionSistema fs = (FuncionSistema) comboItem.getValue(); - PerfilFuncion pf = new PerfilFuncion(); - pf.setActivo(Boolean.TRUE); - pf.setFuncionSistema(fs); - pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - pf.setFecmodif(Calendar.getInstance().getTime()); - pf.setPerfil(perfil); - - if(radReadOnly.isChecked()){ - pf.setIndLectura(Boolean.TRUE); - }else if(radWrite.isChecked()){ - pf.setIndLectura(Boolean.FALSE); - } + public void onClick$btnAdicionarPermiso(Event ev) { + Comboitem comboItem = cmbFuncionSistema.getSelectedItem(); + if (comboItem != null && indPermiso.getSelectedItem() != null) { + FuncionSistema fs = (FuncionSistema) comboItem.getValue(); + PerfilFuncion pf = new PerfilFuncion(); + pf.setActivo(Boolean.TRUE); + pf.setFuncionSistema(fs); + pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + pf.setFecmodif(Calendar.getInstance().getTime()); + pf.setPerfil(perfil); - lsPermiso.add(pf); - permisoList.setData(lsPermiso); - perfil.setPerfilFuncionList(lsPermiso); + if (radReadOnly.isChecked()) { + pf.setIndLectura(Boolean.TRUE); + } else if (radWrite.isChecked()) { + pf.setIndLectura(Boolean.FALSE); + } - cmbFuncionSistema.setSelectedItem(null); - cmbFuncionSistema.setValue(null); - comboItem.setVisible(false); - } - } + lsPermiso.add(pf); + permisoList.setData(lsPermiso); + perfil.setPerfilFuncionList(lsPermiso); - public void onClick$btnRemoverPermiso(Event ev) { - PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected(); - if (pf != null) { - pf.setActivo(Boolean.FALSE); - pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); - pf.setFecmodif(Calendar.getInstance().getTime()); + cmbFuncionSistema.setSelectedItem(null); + cmbFuncionSistema.setValue(null); + comboItem.setVisible(false); + } + } - if (pf.getPerfilfuncionId() != null) { - perfilFuncionService.borrar(pf); - } + public void onClick$btnRemoverPermiso(Event ev) { + PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected(); + if (pf != null) { + pf.setActivo(Boolean.FALSE); + pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + pf.setFecmodif(Calendar.getInstance().getTime()); - int indice = 0; - for (int i = 0; i < lsPermiso.size(); i++) { - PerfilFuncion pfL = lsPermiso.get(i); - if (pfL.getFuncionSistema() != null) { - if (pfL.getFuncionSistema().equals(pf.getFuncionSistema())) { - indice = i; - } - } - } + if (pf.getPerfilfuncionId() != null) { + perfilFuncionService.borrar(pf); + } - lsPermiso.remove(indice); - permisoList.setData(lsPermiso); - perfil.setPerfilFuncionList(lsPermiso); + int indice = 0; + for (int i = 0; i < lsPermiso.size(); i++) { + PerfilFuncion pfL = lsPermiso.get(i); + if (pfL.getFuncionSistema() != null) { + if (pfL.getFuncionSistema().equals(pf.getFuncionSistema())) { + indice = i; + } + } + } - List children = cmbFuncionSistema.getChildren(); - for (Component c : children) { - if (c instanceof Comboitem) { - Comboitem ci = (Comboitem) c; - if ((!ci.isVisible()) && ((FuncionSistema) ci.getValue()).getFuncionsistemaId().equals(pf.getFuncionSistema().getFuncionsistemaId())) { - ci.setVisible(true); - } - } - } - } - } + lsPermiso.remove(indice); + permisoList.setData(lsPermiso); + perfil.setPerfilFuncionList(lsPermiso); + + List children = cmbFuncionSistema.getChildren(); + for (Component c : children) { + if (c instanceof Comboitem) { + Comboitem ci = (Comboitem) c; + if ((!ci.isVisible()) && ((FuncionSistema) ci.getValue()).getFuncionsistemaId().equals(pf.getFuncionSistema().getFuncionsistemaId())) { + ci.setVisible(true); + } + } + } + } + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PerfilJerarquia.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PerfilJerarquia.java new file mode 100644 index 000000000..ed3129564 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/PerfilJerarquia.java @@ -0,0 +1,25 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad; + +public enum PerfilJerarquia { + + NORMAL(0), ADMIN(1), JERARQUIA_2(2), JERARQUIA_3(3), JERARQUIA_4(4); + + private Integer valor; + + private PerfilJerarquia(Integer valor) { + this.valor = valor; + } + + public Integer getValor() { + return valor; + } + + public static PerfilJerarquia buscar(Integer name) { + for (PerfilJerarquia jerarquia : PerfilJerarquia.values()) { + if (jerarquia.getValor().equals(name)) { + return jerarquia; + } + } + return null; + } +}