Alterar Perfil (fixes bug #6329)
Tempo: 04 horas git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@44290 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
124c13fbd1
commit
d92e77a6e1
|
@ -4,17 +4,10 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.web.gui.controladores.seguridad;
|
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.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
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.Paging;
|
||||||
import org.zkoss.zul.Textbox;
|
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
|
* @author rodrigo
|
||||||
*/
|
*/
|
||||||
@Controller("busquedaPerfilController")
|
@Controller("busquedaPerfilController")
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class BusquedaPerfilController extends MyGenericForwardComposer {
|
public class BusquedaPerfilController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
@Autowired
|
private static final long serialVersionUID = 1L;
|
||||||
private transient PagedListWrapper<Perfil> plwPerfil;
|
private static Logger log = Logger.getLogger(BusquedaPerfilController.class);
|
||||||
private MyListbox perfilList;
|
|
||||||
private Paging pagingPerfil;
|
|
||||||
private Textbox txtNome;
|
|
||||||
private PerfilService perfilService;
|
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
public void doAfterCompose(Component comp) throws Exception {
|
private transient PagedListWrapper<Perfil> plwPerfil;
|
||||||
super.doAfterCompose(comp);
|
@Autowired
|
||||||
|
private PerfilService perfilService;
|
||||||
|
@Autowired
|
||||||
|
private UsuarioService usuarioService;
|
||||||
|
|
||||||
perfilList.setItemRenderer(new RenderPerfil());
|
private MyListbox perfilList;
|
||||||
|
private Paging pagingPerfil;
|
||||||
perfilList.addEventListener("onDoubleClick", new EventListener() {
|
private Textbox txtNome;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
Perfil s = (Perfil) perfilList.getSelected();
|
super.doAfterCompose(comp);
|
||||||
verSistema(s);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
refreshLista();
|
perfilList.setItemRenderer(new RenderPerfil());
|
||||||
|
|
||||||
txtNome.focus();
|
perfilList.addEventListener("onDoubleClick", new EventListener() {
|
||||||
}
|
|
||||||
|
|
||||||
private void verSistema(Perfil s) {
|
@Override
|
||||||
if (s == null) {
|
public void onEvent(Event event) throws Exception {
|
||||||
return;
|
Perfil s = (Perfil) perfilList.getSelected();
|
||||||
}
|
verSistema(s);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Map args = new HashMap();
|
refreshLista();
|
||||||
args.put("perfil", s);
|
|
||||||
args.put("perfilList", perfilList);
|
|
||||||
|
|
||||||
openWindow("/gui/seguridad/editarPerfil.zul",
|
txtNome.focus();
|
||||||
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshLista() {
|
private void verSistema(Perfil s) throws InterruptedException {
|
||||||
HibernateSearchObject<Perfil> sistemaBusqueda =
|
if (s == null) {
|
||||||
new HibernateSearchObject<Perfil>(Perfil.class,
|
return;
|
||||||
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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick$btnPesquisa(Event ev) {
|
Map args = new HashMap();
|
||||||
refreshLista();
|
args.put("perfil", s);
|
||||||
}
|
args.put("perfilList", perfilList);
|
||||||
|
|
||||||
public void onClick$btnRefresh(Event ev) {
|
openWindow("/gui/seguridad/editarPerfil.zul",
|
||||||
refreshLista();
|
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick$btnNovo(Event ev) {
|
private void refreshLista() {
|
||||||
verSistema(new Perfil());
|
HibernateSearchObject<Perfil> sistemaBusqueda =
|
||||||
}
|
new HibernateSearchObject<Perfil>(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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,326 +44,327 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPermiso;
|
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPermiso;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author rodrigo
|
* @author rodrigo
|
||||||
*/
|
*/
|
||||||
@Controller("editarPerfilController")
|
@Controller("editarPerfilController")
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class EditarPerfilController extends MyGenericForwardComposer {
|
public class EditarPerfilController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
@Autowired
|
private static final long serialVersionUID = 1L;
|
||||||
private PerfilService perfilService;
|
private static Logger log = Logger.getLogger(EditarPerfilController.class);
|
||||||
@Autowired
|
|
||||||
private FuncionSistemaService funcionSistemaService;
|
|
||||||
@Autowired
|
|
||||||
private PerfilFuncionService perfilFuncionService;
|
|
||||||
private Perfil perfil;
|
|
||||||
private MyListbox perfilList;
|
|
||||||
private MyListbox permisoList;
|
|
||||||
private Textbox txtDescPerfil;
|
|
||||||
private List<FuncionSistema> lsFuncionSistema;
|
|
||||||
private List<FuncionSistema> lsAllFuncionPerfil;
|
|
||||||
private List<PerfilFuncion> 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);
|
|
||||||
|
|
||||||
public Perfil getPerfil() {
|
@Autowired
|
||||||
return perfil;
|
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<FuncionSistema> lsFuncionSistema;
|
||||||
|
private List<FuncionSistema> lsAllFuncionPerfil;
|
||||||
|
private List<PerfilFuncion> lsPermiso;
|
||||||
|
private Combobox cmbFuncionSistema;
|
||||||
|
private Button btnApagar;
|
||||||
|
private Window winEditarPerfil;
|
||||||
|
private Radiogroup indPermiso;
|
||||||
|
private Radio radReadOnly;
|
||||||
|
private Radio radWrite;
|
||||||
|
|
||||||
public void setPerfil(Perfil perfil) {
|
public Perfil getPerfil() {
|
||||||
this.perfil = perfil;
|
return perfil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Combobox getCmbFuncionSistema() {
|
public void setPerfil(Perfil perfil) {
|
||||||
return cmbFuncionSistema;
|
this.perfil = perfil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCmbFuncionSistema(Combobox cmbFuncionSistema) {
|
public Combobox getCmbFuncionSistema() {
|
||||||
this.cmbFuncionSistema = cmbFuncionSistema;
|
return cmbFuncionSistema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncionSistema> getLsFuncionSistema() {
|
public void setCmbFuncionSistema(Combobox cmbFuncionSistema) {
|
||||||
return lsFuncionSistema;
|
this.cmbFuncionSistema = cmbFuncionSistema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLsFuncionSistema(List<FuncionSistema> lsFuncionSistema) {
|
public List<FuncionSistema> getLsFuncionSistema() {
|
||||||
this.lsFuncionSistema = lsFuncionSistema;
|
return lsFuncionSistema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Button getBtnApagar() {
|
public void setLsFuncionSistema(List<FuncionSistema> lsFuncionSistema) {
|
||||||
return btnApagar;
|
this.lsFuncionSistema = lsFuncionSistema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBtnApagar(Button btnApagar) {
|
public Button getBtnApagar() {
|
||||||
this.btnApagar = btnApagar;
|
return btnApagar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setBtnApagar(Button btnApagar) {
|
||||||
public void doAfterCompose(Component comp) throws Exception {
|
this.btnApagar = btnApagar;
|
||||||
lsFuncionSistema = funcionSistemaService.obtenerTodos();
|
}
|
||||||
lsAllFuncionPerfil = new ArrayList<FuncionSistema>();
|
|
||||||
|
|
||||||
super.doAfterCompose(comp);
|
@Override
|
||||||
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
|
lsFuncionSistema = funcionSistemaService.obtenerTodos();
|
||||||
|
lsAllFuncionPerfil = new ArrayList<FuncionSistema>();
|
||||||
|
|
||||||
permisoList.setItemRenderer(new RenderPermiso());
|
super.doAfterCompose(comp);
|
||||||
|
|
||||||
permisoList.addEventListener("onDoubleClick", new EventListener() {
|
permisoList.setItemRenderer(new RenderPermiso());
|
||||||
|
|
||||||
|
permisoList.addEventListener("onDoubleClick", new EventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected();
|
PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected();
|
||||||
abrirPefilFuncion(pf);
|
abrirPefilFuncion(pf);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
perfil = (Perfil) Executions.getCurrent().getArg().get("perfil");
|
perfil = (Perfil) Executions.getCurrent().getArg().get("perfil");
|
||||||
if (perfil.getPerfilId() != null) {
|
if (perfil.getPerfilId() != null) {
|
||||||
perfil = perfilService.obtenerID(perfil.getPerfilId());
|
perfil = perfilService.obtenerID(perfil.getPerfilId());
|
||||||
|
|
||||||
for (FuncionSistema fas : lsFuncionSistema) {
|
for (FuncionSistema fas : lsFuncionSistema) {
|
||||||
for (PerfilFuncion pf : perfil.getPerfilFuncionList()) {
|
for (PerfilFuncion pf : perfil.getPerfilFuncionList()) {
|
||||||
FuncionSistema fs = pf.getFuncionSistema();
|
FuncionSistema fs = pf.getFuncionSistema();
|
||||||
if (fas.equals(fs)) {
|
if (fas.equals(fs)) {
|
||||||
lsAllFuncionPerfil.add(fas);
|
lsAllFuncionPerfil.add(fas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
perfilList = (MyListbox) Executions.getCurrent().getArg().get("perfilList");
|
perfilList = (MyListbox) Executions.getCurrent().getArg().get("perfilList");
|
||||||
|
|
||||||
if (perfil.getPerfilFuncionList() == null) {
|
if (perfil.getPerfilFuncionList() == null) {
|
||||||
lsPermiso = new ArrayList<PerfilFuncion>();
|
lsPermiso = new ArrayList<PerfilFuncion>();
|
||||||
} else {
|
} else {
|
||||||
lsPermiso = perfil.getPerfilFuncionList();
|
lsPermiso = perfil.getPerfilFuncionList();
|
||||||
Collections.sort(lsPermiso, new Comparator<PerfilFuncion>() {
|
Collections.sort(lsPermiso, new Comparator<PerfilFuncion>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(PerfilFuncion o1, PerfilFuncion o2) {
|
public int compare(PerfilFuncion o1, PerfilFuncion o2) {
|
||||||
return o1.getFuncionSistema().getNombfuncion().compareTo(o2.getFuncionSistema().getNombfuncion());
|
return o1.getFuncionSistema().getNombfuncion().compareTo(o2.getFuncionSistema().getNombfuncion());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
permisoList.setData(lsPermiso);
|
permisoList.setData(lsPermiso);
|
||||||
|
|
||||||
if (perfil.getPerfilId() == null) {
|
if (perfil.getPerfilId() == null) {
|
||||||
btnApagar.setVisible(Boolean.FALSE);
|
btnApagar.setVisible(Boolean.FALSE);
|
||||||
}
|
}
|
||||||
cmbFuncionSistema.setItemRenderer(new ComboitemRenderer() {
|
cmbFuncionSistema.setItemRenderer(new ComboitemRenderer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Comboitem cmbtm, Object o) throws Exception {
|
public void render(Comboitem cmbtm, Object o) throws Exception {
|
||||||
FuncionSistema fsItem = (FuncionSistema) o;
|
FuncionSistema fsItem = (FuncionSistema) o;
|
||||||
for (FuncionSistema fs : lsAllFuncionPerfil) {
|
for (FuncionSistema fs : lsAllFuncionPerfil) {
|
||||||
if (fsItem.getFuncionsistemaId().equals(fs.getFuncionsistemaId())) {
|
if (fsItem.getFuncionsistemaId().equals(fs.getFuncionsistemaId())) {
|
||||||
cmbtm.setVisible(false);
|
cmbtm.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmbtm.setLabel(fsItem.getNombfuncion());
|
cmbtm.setLabel(fsItem.getNombfuncion());
|
||||||
cmbtm.setValue(fsItem);
|
cmbtm.setValue(fsItem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
winEditarPerfil.addEventListener("onClose", new EventListener() {
|
winEditarPerfil.addEventListener("onClose", new EventListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
txtDescPerfil.getText();
|
txtDescPerfil.getText();
|
||||||
if (lsPermiso.isEmpty()) {
|
if (lsPermiso.isEmpty()) {
|
||||||
Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"),
|
Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.INFORMATION);
|
Messagebox.INFORMATION);
|
||||||
|
|
||||||
|
}
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
}
|
}
|
||||||
event.stopPropagation();
|
});
|
||||||
|
|
||||||
}
|
txtDescPerfil.focus();
|
||||||
});
|
}
|
||||||
|
|
||||||
txtDescPerfil.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
public void abrirPefilFuncion(PerfilFuncion perfilFuncion) {
|
public void abrirPefilFuncion(PerfilFuncion perfilFuncion) {
|
||||||
Map args = new HashMap();
|
Map args = new HashMap();
|
||||||
args.put("perfilFuncion", perfilFuncion);
|
args.put("perfilFuncion", perfilFuncion);
|
||||||
args.put("permisoList", permisoList);
|
args.put("permisoList", permisoList);
|
||||||
|
|
||||||
openWindow("/gui/seguridad/editarPerfilFuncion.zul",
|
openWindow("/gui/seguridad/editarPerfilFuncion.zul",
|
||||||
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean duplicado() {
|
private boolean duplicado() {
|
||||||
List<Perfil> listPerfil = perfilService.buscar(txtDescPerfil.getText());
|
List<Perfil> listPerfil = perfilService.buscar(txtDescPerfil.getText());
|
||||||
if (listPerfil.isEmpty()) {
|
if (listPerfil.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean duplicado = true;
|
boolean duplicado = true;
|
||||||
|
|
||||||
if (perfil.getPerfilId() == null) {
|
if (perfil.getPerfilId() == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Perfil p : listPerfil) {
|
for (Perfil p : listPerfil) {
|
||||||
if (p.getPerfilId().equals(perfil.getPerfilId())) {
|
if (p.getPerfilId().equals(perfil.getPerfilId())) {
|
||||||
duplicado = false;
|
duplicado = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return duplicado;
|
return duplicado;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick$btnSalvar(Event ev) {
|
public void onClick$btnSalvar(Event ev) {
|
||||||
txtDescPerfil.getText();
|
txtDescPerfil.getText();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (lsPermiso.isEmpty()) {
|
if (lsPermiso.isEmpty()) {
|
||||||
Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"),
|
Clients.alert(Labels.getLabel("editarPerfilController.MSG.funcionObligatorio"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.INFORMATION);
|
Messagebox.INFORMATION);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplicado()) {
|
if (duplicado()) {
|
||||||
Clients.alert(Labels.getLabel("MSG.Registro.Existe"),
|
Clients.alert(Labels.getLabel("MSG.Registro.Existe"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.INFORMATION);
|
Messagebox.INFORMATION);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
perfil.setActivo(Boolean.TRUE);
|
perfil.setActivo(Boolean.TRUE);
|
||||||
perfil.setFecmodif(Calendar.getInstance().getTime());
|
perfil.setFecmodif(Calendar.getInstance().getTime());
|
||||||
perfil.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
perfil.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
perfil.setPerfilFuncionList(lsPermiso);
|
perfil.setPerfilFuncionList(lsPermiso);
|
||||||
|
|
||||||
if (perfil.getPerfilId() == null) {
|
if (perfil.getPerfilId() == null) {
|
||||||
perfilService.suscribir(perfil);
|
perfilService.suscribir(perfil);
|
||||||
perfilList.addItem(perfil);
|
perfilList.addItem(perfil);
|
||||||
} else {
|
} else {
|
||||||
perfilService.actualizacion(perfil);
|
perfilService.actualizacion(perfil);
|
||||||
perfilList.updateItem(perfil);
|
perfilList.updateItem(perfil);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messagebox.show(
|
Messagebox.show(
|
||||||
Labels.getLabel("editarPerfilController.MSG.suscribirOK"),
|
Labels.getLabel("editarPerfilController.MSG.suscribirOK"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.OK, Messagebox.INFORMATION);
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
closeWindow();
|
closeWindow();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex);
|
log.error(ex);
|
||||||
Clients.alert(
|
Clients.alert(
|
||||||
Labels.getLabel("MSG.Error"),
|
Labels.getLabel("MSG.Error"),
|
||||||
Labels.getLabel("editarEstacionController.window.title"),
|
Labels.getLabel("editarEstacionController.window.title"),
|
||||||
Messagebox.INFORMATION);
|
Messagebox.INFORMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick$btnApagar(Event ev) {
|
public void onClick$btnApagar(Event ev) {
|
||||||
try {
|
try {
|
||||||
int resp = Messagebox.show(
|
int resp = Messagebox.show(
|
||||||
Labels.getLabel("editarPerfilController.MSG.borrarPergunta"),
|
Labels.getLabel("editarPerfilController.MSG.borrarPergunta"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
||||||
|
|
||||||
if (resp == Messagebox.YES) {
|
if (resp == Messagebox.YES) {
|
||||||
for (PerfilFuncion pf : perfil.getPerfilFuncionList()) {
|
for (PerfilFuncion pf : perfil.getPerfilFuncionList()) {
|
||||||
pf.setActivo(Boolean.FALSE);
|
pf.setActivo(Boolean.FALSE);
|
||||||
pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
pf.setFecmodif(Calendar.getInstance().getTime());
|
pf.setFecmodif(Calendar.getInstance().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
perfilService.borrar(perfil);
|
perfilService.borrar(perfil);
|
||||||
|
|
||||||
Messagebox.show(
|
Messagebox.show(
|
||||||
Labels.getLabel("editarPerfilController.MSG.borrarOK"),
|
Labels.getLabel("editarPerfilController.MSG.borrarOK"),
|
||||||
Labels.getLabel("editarPerfilController.window.title"),
|
Labels.getLabel("editarPerfilController.window.title"),
|
||||||
Messagebox.OK, Messagebox.INFORMATION);
|
Messagebox.OK, Messagebox.INFORMATION);
|
||||||
|
|
||||||
perfilList.removeItem(perfil);
|
perfilList.removeItem(perfil);
|
||||||
|
|
||||||
closeWindow();
|
closeWindow();
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex);
|
log.error(ex);
|
||||||
Clients.alert(
|
Clients.alert(
|
||||||
Labels.getLabel("MSG.Error"),
|
Labels.getLabel("MSG.Error"),
|
||||||
Labels.getLabel("editarEstacionController.window.title"),
|
Labels.getLabel("editarEstacionController.window.title"),
|
||||||
Messagebox.INFORMATION);
|
Messagebox.INFORMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick$btnAdicionarPermiso(Event ev) {
|
public void onClick$btnAdicionarPermiso(Event ev) {
|
||||||
Comboitem comboItem = cmbFuncionSistema.getSelectedItem();
|
Comboitem comboItem = cmbFuncionSistema.getSelectedItem();
|
||||||
if (comboItem != null && indPermiso.getSelectedItem() != null) {
|
if (comboItem != null && indPermiso.getSelectedItem() != null) {
|
||||||
FuncionSistema fs = (FuncionSistema) comboItem.getValue();
|
FuncionSistema fs = (FuncionSistema) comboItem.getValue();
|
||||||
PerfilFuncion pf = new PerfilFuncion();
|
PerfilFuncion pf = new PerfilFuncion();
|
||||||
pf.setActivo(Boolean.TRUE);
|
pf.setActivo(Boolean.TRUE);
|
||||||
pf.setFuncionSistema(fs);
|
pf.setFuncionSistema(fs);
|
||||||
pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
pf.setFecmodif(Calendar.getInstance().getTime());
|
pf.setFecmodif(Calendar.getInstance().getTime());
|
||||||
pf.setPerfil(perfil);
|
pf.setPerfil(perfil);
|
||||||
|
|
||||||
if(radReadOnly.isChecked()){
|
|
||||||
pf.setIndLectura(Boolean.TRUE);
|
|
||||||
}else if(radWrite.isChecked()){
|
|
||||||
pf.setIndLectura(Boolean.FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
lsPermiso.add(pf);
|
if (radReadOnly.isChecked()) {
|
||||||
permisoList.setData(lsPermiso);
|
pf.setIndLectura(Boolean.TRUE);
|
||||||
perfil.setPerfilFuncionList(lsPermiso);
|
} else if (radWrite.isChecked()) {
|
||||||
|
pf.setIndLectura(Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
cmbFuncionSistema.setSelectedItem(null);
|
lsPermiso.add(pf);
|
||||||
cmbFuncionSistema.setValue(null);
|
permisoList.setData(lsPermiso);
|
||||||
comboItem.setVisible(false);
|
perfil.setPerfilFuncionList(lsPermiso);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick$btnRemoverPermiso(Event ev) {
|
cmbFuncionSistema.setSelectedItem(null);
|
||||||
PerfilFuncion pf = (PerfilFuncion) permisoList.getSelected();
|
cmbFuncionSistema.setValue(null);
|
||||||
if (pf != null) {
|
comboItem.setVisible(false);
|
||||||
pf.setActivo(Boolean.FALSE);
|
}
|
||||||
pf.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
}
|
||||||
pf.setFecmodif(Calendar.getInstance().getTime());
|
|
||||||
|
|
||||||
if (pf.getPerfilfuncionId() != null) {
|
public void onClick$btnRemoverPermiso(Event ev) {
|
||||||
perfilFuncionService.borrar(pf);
|
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;
|
if (pf.getPerfilfuncionId() != null) {
|
||||||
for (int i = 0; i < lsPermiso.size(); i++) {
|
perfilFuncionService.borrar(pf);
|
||||||
PerfilFuncion pfL = lsPermiso.get(i);
|
}
|
||||||
if (pfL.getFuncionSistema() != null) {
|
|
||||||
if (pfL.getFuncionSistema().equals(pf.getFuncionSistema())) {
|
|
||||||
indice = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lsPermiso.remove(indice);
|
int indice = 0;
|
||||||
permisoList.setData(lsPermiso);
|
for (int i = 0; i < lsPermiso.size(); i++) {
|
||||||
perfil.setPerfilFuncionList(lsPermiso);
|
PerfilFuncion pfL = lsPermiso.get(i);
|
||||||
|
if (pfL.getFuncionSistema() != null) {
|
||||||
|
if (pfL.getFuncionSistema().equals(pf.getFuncionSistema())) {
|
||||||
|
indice = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Component> children = cmbFuncionSistema.getChildren();
|
lsPermiso.remove(indice);
|
||||||
for (Component c : children) {
|
permisoList.setData(lsPermiso);
|
||||||
if (c instanceof Comboitem) {
|
perfil.setPerfilFuncionList(lsPermiso);
|
||||||
Comboitem ci = (Comboitem) c;
|
|
||||||
if ((!ci.isVisible()) && ((FuncionSistema) ci.getValue()).getFuncionsistemaId().equals(pf.getFuncionSistema().getFuncionsistemaId())) {
|
List<Component> children = cmbFuncionSistema.getChildren();
|
||||||
ci.setVisible(true);
|
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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue