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;
|
||||
|
||||
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,6 +19,18 @@ 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
|
||||
|
@ -34,81 +39,102 @@ import org.zkoss.zul.Textbox;
|
|||
@Scope("prototype")
|
||||
public class BusquedaPerfilController extends MyGenericForwardComposer {
|
||||
|
||||
@Autowired
|
||||
private transient PagedListWrapper<Perfil> 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<Perfil> plwPerfil;
|
||||
@Autowired
|
||||
private PerfilService perfilService;
|
||||
@Autowired
|
||||
private UsuarioService usuarioService;
|
||||
|
||||
perfilList.setItemRenderer(new RenderPerfil());
|
||||
private MyListbox perfilList;
|
||||
private Paging pagingPerfil;
|
||||
private Textbox txtNome;
|
||||
|
||||
perfilList.addEventListener("onDoubleClick", new EventListener() {
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Perfil s = (Perfil) perfilList.getSelected();
|
||||
verSistema(s);
|
||||
}
|
||||
});
|
||||
perfilList.setItemRenderer(new RenderPerfil());
|
||||
|
||||
refreshLista();
|
||||
perfilList.addEventListener("onDoubleClick", new EventListener() {
|
||||
|
||||
txtNome.focus();
|
||||
}
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Perfil s = (Perfil) perfilList.getSelected();
|
||||
verSistema(s);
|
||||
}
|
||||
});
|
||||
|
||||
private void verSistema(Perfil s) {
|
||||
if (s == null) {
|
||||
return;
|
||||
}
|
||||
refreshLista();
|
||||
|
||||
Map args = new HashMap();
|
||||
args.put("perfil", s);
|
||||
args.put("perfilList", perfilList);
|
||||
txtNome.focus();
|
||||
}
|
||||
|
||||
openWindow("/gui/seguridad/editarPerfil.zul",
|
||||
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
||||
}
|
||||
private void verSistema(Perfil s) throws InterruptedException {
|
||||
if (s == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
private void refreshLista() {
|
||||
HibernateSearchObject<Perfil> sistemaBusqueda =
|
||||
new HibernateSearchObject<Perfil>(Perfil.class,
|
||||
pagingPerfil.getPageSize());
|
||||
Map args = new HashMap();
|
||||
args.put("perfil", s);
|
||||
args.put("perfilList", perfilList);
|
||||
|
||||
String descPerfil = txtNome.getText();
|
||||
if (descPerfil != null) {
|
||||
sistemaBusqueda.addFilterLike("descperfil", "%" + descPerfil.trim().concat("%"));
|
||||
}
|
||||
openWindow("/gui/seguridad/editarPerfil.zul",
|
||||
Labels.getLabel("editarPerfilController.window.title"), args, MODAL);
|
||||
}
|
||||
|
||||
sistemaBusqueda.addSortAsc("descperfil");
|
||||
sistemaBusqueda.addFilterEqual("activo", Boolean.TRUE);
|
||||
private void refreshLista() {
|
||||
HibernateSearchObject<Perfil> sistemaBusqueda =
|
||||
new HibernateSearchObject<Perfil>(Perfil.class,
|
||||
pagingPerfil.getPageSize());
|
||||
|
||||
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) {
|
||||
}
|
||||
}
|
||||
String descPerfil = txtNome.getText();
|
||||
if (descPerfil != null) {
|
||||
sistemaBusqueda.addFilterLike("descperfil", "%" + descPerfil.trim().concat("%"));
|
||||
}
|
||||
|
||||
}
|
||||
sistemaBusqueda.addSortAsc("descperfil");
|
||||
sistemaBusqueda.addFilterEqual("activo", Boolean.TRUE);
|
||||
|
||||
public void onClick$btnPesquisa(Event ev) {
|
||||
refreshLista();
|
||||
}
|
||||
Usuario usuarioLogado = usuarioService.obtenerID(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
Perfil perfilUsuario = usuarioLogado.getUsuarioPerfilList().get(0).getPerfil();
|
||||
PerfilJerarquia usuarioJerarquia = PerfilJerarquia.buscar(perfilUsuario.getIndJerarquia());
|
||||
|
||||
public void onClick$btnRefresh(Event ev) {
|
||||
refreshLista();
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick$btnNovo(Event ev) {
|
||||
verSistema(new Perfil());
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,97 +51,99 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPermiso;
|
|||
@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<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);
|
||||
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<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) {
|
||||
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<FuncionSistema> getLsFuncionSistema() {
|
||||
return lsFuncionSistema;
|
||||
}
|
||||
public void setCmbFuncionSistema(Combobox cmbFuncionSistema) {
|
||||
this.cmbFuncionSistema = cmbFuncionSistema;
|
||||
}
|
||||
|
||||
public void setLsFuncionSistema(List<FuncionSistema> lsFuncionSistema) {
|
||||
this.lsFuncionSistema = lsFuncionSistema;
|
||||
}
|
||||
public List<FuncionSistema> getLsFuncionSistema() {
|
||||
return lsFuncionSistema;
|
||||
}
|
||||
|
||||
public Button getBtnApagar() {
|
||||
return btnApagar;
|
||||
}
|
||||
public void setLsFuncionSistema(List<FuncionSistema> 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<FuncionSistema>();
|
||||
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<FuncionSistema>();
|
||||
|
||||
permisoList.setItemRenderer(new RenderPermiso());
|
||||
super.doAfterCompose(comp);
|
||||
|
||||
permisoList.addEventListener("onDoubleClick", new EventListener() {
|
||||
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<PerfilFuncion>();
|
||||
} else {
|
||||
lsPermiso = perfil.getPerfilFuncionList();
|
||||
Collections.sort(lsPermiso, new Comparator<PerfilFuncion>() {
|
||||
if (perfil.getPerfilFuncionList() == null) {
|
||||
lsPermiso = new ArrayList<PerfilFuncion>();
|
||||
} else {
|
||||
lsPermiso = perfil.getPerfilFuncionList();
|
||||
Collections.sort(lsPermiso, new Comparator<PerfilFuncion>() {
|
||||
|
||||
@Override
|
||||
public int compare(PerfilFuncion o1, PerfilFuncion o2) {
|
||||
|
@ -149,46 +151,45 @@ public class EditarPerfilController extends MyGenericForwardComposer {
|
|||
}
|
||||
|
||||
});
|
||||
}
|
||||
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) {
|
||||
|
@ -196,174 +197,174 @@ public class EditarPerfilController extends MyGenericForwardComposer {
|
|||
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<Perfil> listPerfil = perfilService.buscar(txtDescPerfil.getText());
|
||||
if (listPerfil.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean duplicado = true;
|
||||
private boolean duplicado() {
|
||||
List<Perfil> 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);
|
||||
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);
|
||||
}
|
||||
if (radReadOnly.isChecked()) {
|
||||
pf.setIndLectura(Boolean.TRUE);
|
||||
} else if (radWrite.isChecked()) {
|
||||
pf.setIndLectura(Boolean.FALSE);
|
||||
}
|
||||
|
||||
lsPermiso.add(pf);
|
||||
permisoList.setData(lsPermiso);
|
||||
perfil.setPerfilFuncionList(lsPermiso);
|
||||
lsPermiso.add(pf);
|
||||
permisoList.setData(lsPermiso);
|
||||
perfil.setPerfilFuncionList(lsPermiso);
|
||||
|
||||
cmbFuncionSistema.setSelectedItem(null);
|
||||
cmbFuncionSistema.setValue(null);
|
||||
comboItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
cmbFuncionSistema.setSelectedItem(null);
|
||||
cmbFuncionSistema.setValue(null);
|
||||
comboItem.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
|
||||
if (pf.getPerfilfuncionId() != null) {
|
||||
perfilFuncionService.borrar(pf);
|
||||
}
|
||||
if (pf.getPerfilfuncionId() != null) {
|
||||
perfilFuncionService.borrar(pf);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lsPermiso.remove(indice);
|
||||
permisoList.setData(lsPermiso);
|
||||
perfil.setPerfilFuncionList(lsPermiso);
|
||||
lsPermiso.remove(indice);
|
||||
permisoList.setData(lsPermiso);
|
||||
perfil.setPerfilFuncionList(lsPermiso);
|
||||
|
||||
List<Component> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Component> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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