274 lines
9.3 KiB
Plaintext
Executable File
274 lines
9.3 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.parametros;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ViewScoped;
|
|
|
|
import org.primefaces.context.RequestContext;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.dto.query.Filter;
|
|
import com.fp.dto.query.SubQuery;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.armas.solicitud.TarmTramiteController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
|
|
import com.fp.frontend.enums.EnumLovOption;
|
|
import com.fp.frontend.helper.CallerHelper;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.param.TarmTramite;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
|
|
|
|
/**
|
|
* Clase controladora del lov asociado al bean TarmTramite.
|
|
*
|
|
* @author Christian Pazmino.
|
|
* @version 2.1
|
|
*/
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class BuscarTramiteLovController extends AbstractController<TarmTramite> {
|
|
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
private List<TgeneCatalogDetail> ltipoTramite;
|
|
private List<TgeneCatalogDetail> ltipoAutorizacion;
|
|
private List<TgeneCatalogDetail> lcategoria;
|
|
private List<TgeneCatalogDetail> lusoActividad;
|
|
private String ctramite;
|
|
private String tipoPersonaAmbos;
|
|
private List<TarmTramite> tarmTramite;
|
|
private String tipoautorizacion;
|
|
private String tipotramite;
|
|
private String categoria;
|
|
|
|
public BuscarTramiteLovController() throws Exception {
|
|
super(TarmTramite.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
try {
|
|
ctramite = CallerHelper.getLovParameter("ctramite");
|
|
String tipopersonasol=CallerHelper.getLovParameter("tipopersonasol");
|
|
if(tipopersonasol!=null && tipopersonasol.trim().length()>0){
|
|
tipoPersonaAmbos=ParametersController.find("CODIGO.PERSONTYPE.AMBOS", "1").getTextvalue();
|
|
this.getMfilelds().put("tipopersonasol", "(tipopersona='"+tipoPersonaAmbos+"' or tipopersona='"+tipopersonasol+"') ");
|
|
}
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 10; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "TRAMITE";
|
|
ltipoAutorizacion=CatalogDetailController.find("TIPOAUTORIZACION");
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.tipotramite, t.tipoautorizacion, t.categoria, t.usoactividad");
|
|
SubQuery stipoAutorizacion= new SubQuery
|
|
("TgeneCatalogDetail", "description", "destipoAutorizacion", "i.pk.catalog = t.tipoautorizacion and i.pk.catalogcode=t.tipoautorizacioncodigo");
|
|
SubQuery stipoTramite= new SubQuery
|
|
("TgeneCatalogDetail", "description", "destipoTramite", "i.pk.catalog = t.tipotramite and i.pk.catalogcode=t.tipotramitecodigo");
|
|
SubQuery scategoria= new SubQuery
|
|
("TgeneCatalogDetail", "description", "descategoria", "i.pk.catalog = t.categoria and i.pk.catalogcode=t.categoriacodigo");
|
|
SubQuery susoactividad= new SubQuery
|
|
("TgeneCatalogDetail", "description", "desusoactividad", "i.pk.catalog = t.usoactividad and i.pk.catalogcode=t.usoactividadcodigo");
|
|
|
|
dto.addSubQuery(stipoAutorizacion);
|
|
dto.addSubQuery(stipoTramite);
|
|
dto.addSubQuery(scategoria);
|
|
dto.addSubQuery(susoactividad);
|
|
//valida si tiene el codigo del tramite padre
|
|
if (ctramite != null) {
|
|
Filter filtro= new Filter();
|
|
filtro.setSql("pk !="+ctramite);
|
|
dto.addFiltro(filtro);
|
|
}
|
|
|
|
if(this.getMfilelds().get("tipopersonasol")!=null){
|
|
Filter filtro= new Filter();
|
|
filtro.setSql(this.getMfilelds().get("tipopersonasol").toString());
|
|
dto.addFiltro(filtro);
|
|
}
|
|
|
|
// dto.setOrderby("t.tipotramite"); // En en string van todos los campos de orden ("t.pk, t.nombre, t.cpais").
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
request.setQueryTables(mtables);
|
|
Response resp = this.callerhelper.executeQuery(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
this.lrecord = new ArrayList<TarmTramite>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TarmTramite>) resp.get(this.beanalias);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public static void openLov(Map<String, List<String>> params) {
|
|
Map<String, Object> options = new HashMap<String, Object>();
|
|
options.put(EnumLovOption.MODAL.getLabel(), true);
|
|
options.put(EnumLovOption.HEIGHT.getLabel(), 450);
|
|
options.put(EnumLovOption.WIDTH.getLabel(), 980);
|
|
options.put(EnumLovOption.RESIZABLE.getLabel(), false);
|
|
|
|
RequestContext.getCurrentInstance().openDialog("/pages/armas/lov/buscartramiteLov.xhtml", options, params);
|
|
}
|
|
|
|
public void catalogos(List<TgeneCatalogDetail>list, String codigo,String pk){
|
|
for(TgeneCatalogDetail item:list){
|
|
if(codigo==item.getPk().getCatalog()){
|
|
record.modifiedData.put(pk, item.getDescription());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Método para el evento change del combo tramite
|
|
*/
|
|
public void executeTramite() {
|
|
tarmTramite = new ArrayList<>();
|
|
ltipoTramite = new ArrayList<>();
|
|
lcategoria = new ArrayList<>();
|
|
lusoActividad = new ArrayList<>();
|
|
|
|
tipoautorizacion = (String) this.getMfilters().get("pk.tipoautorizacion");
|
|
|
|
tarmTramite = TarmTramiteController.findPorCriteriosTramite(tipoautorizacion);
|
|
|
|
for (int i = 0; i < tarmTramite.size(); i++) {
|
|
TarmTramite tramite = tarmTramite.get(i);
|
|
|
|
TgeneCatalogDetail catalogDetail = CatalogDetailController.findCatalogo(tramite.getTipotramitecodigo(),tramite.getTipotramite());
|
|
if(!ltipoTramite.contains(catalogDetail)){
|
|
ltipoTramite.add(catalogDetail);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Método para el evento change del combo autorizacion
|
|
*/
|
|
public void executeTipoTramite() {
|
|
lusoActividad = new ArrayList<>();
|
|
tipotramite = (String) this.getMfilters().get("pk.tipotramite");
|
|
|
|
for (int i = 0; i < tarmTramite.size(); i++) {
|
|
TarmTramite tramite = tarmTramite.get(i);
|
|
if(tramite.getTipotramite().equals(tipotramite) && tramite.getCategoriacodigo().equals("CATEGORIA")){
|
|
TgeneCatalogDetail catalogDetail = CatalogDetailController.findCatalogo(tramite.getCategoriacodigo(),tramite.getCategoria());
|
|
|
|
if(!lcategoria.contains(catalogDetail)){
|
|
lcategoria.add(catalogDetail);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Método para el evento change del combo categoria
|
|
*/
|
|
public void executeCategoria() {
|
|
|
|
categoria = (String) this.getMfilters().get("pk.categoria");
|
|
lusoActividad = new ArrayList<>();
|
|
for (int i = 0; i < tarmTramite.size(); i++) {
|
|
TarmTramite tramite = tarmTramite.get(i);
|
|
if(tramite.getTipotramite().equals(tipotramite) && tramite.getCategoria().equals(categoria) &&
|
|
tramite.getCategoriacodigo().equals("CATEGORIA") && tramite.getUsoactividadcodigo().equals("USOACTIVIDAD")){
|
|
TgeneCatalogDetail catalogDetail = CatalogDetailController.findCatalogo(tramite.getUsoactividadcodigo(),tramite.getUsoactividad());
|
|
|
|
if(!lusoActividad.contains(catalogDetail)){
|
|
lusoActividad.add(catalogDetail);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtipoTramite() {
|
|
return ltipoTramite;
|
|
}
|
|
|
|
public void setLtipoTramite(List<TgeneCatalogDetail> ltipoTramite) {
|
|
this.ltipoTramite = ltipoTramite;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLcategoria() {
|
|
return lcategoria;
|
|
}
|
|
|
|
public void setLcategoria(List<TgeneCatalogDetail> lcategoria) {
|
|
this.lcategoria = lcategoria;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLusoActividad() {
|
|
return lusoActividad;
|
|
}
|
|
|
|
public void setLusoActividad(List<TgeneCatalogDetail> lusoActividad) {
|
|
this.lusoActividad = lusoActividad;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtipoAutorizacion() {
|
|
return ltipoAutorizacion;
|
|
}
|
|
|
|
public void setLtipoAutorizacion(List<TgeneCatalogDetail> ltipoAutorizacion) {
|
|
this.ltipoAutorizacion = ltipoAutorizacion;
|
|
}
|
|
|
|
public void setTramite() {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(this.record);
|
|
}
|
|
|
|
public void setTramite(TarmTramite tarmTramite) {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(tarmTramite);
|
|
}
|
|
|
|
|
|
|
|
}
|