164 lines
5.6 KiB
Plaintext
Executable File
164 lines
5.6 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.lov;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
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.SubQuery;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.enums.EnumLovOption;
|
|
import com.fp.frontend.helper.CallerHelper;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.param.TarmTipoSancion;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
|
|
|
|
/**
|
|
* Clase controladora del lov asociado al bean TarmTipoSancion.
|
|
*
|
|
* @author Andres Cevallos.
|
|
* @version 2.1
|
|
*/
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class SancionarLovController extends AbstractController<TarmTipoSancion> {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
private String clase;
|
|
//static List<TarmTipoSancion> ltiposancion;
|
|
private String tramite;
|
|
public List<TgeneCatalogDetail> lsancion;
|
|
//private List<TarmTipoSancion> tsancion;
|
|
public SancionarLovController() throws Exception {
|
|
super(TarmTipoSancion.class);
|
|
}
|
|
|
|
// public static List<TarmTipoSancion> getLtiposancion() {
|
|
// return ltiposancion;
|
|
// }
|
|
|
|
public List<TgeneCatalogDetail> getLsancion() {
|
|
return lsancion;
|
|
}
|
|
|
|
public void setLsancion(List<TgeneCatalogDetail> lsancion) {
|
|
this.lsancion = lsancion;
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 15; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "CATALOGLOV";
|
|
String clase = CallerHelper.getLovParameter("clase");
|
|
String tramite = CallerHelper.getLovParameter("tramite");
|
|
if(clase!=null){
|
|
this.getMfilters().put("clase", clase);
|
|
}
|
|
if(tramite!=null){
|
|
this.getMfilters().put("tramite", tramite);
|
|
}
|
|
lsancion = CatalogDetailController.find("TIPODEFALTA");
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public void querydatabase() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.pk");
|
|
|
|
// Subquery
|
|
SubQuery subqueryClase = new SubQuery("TgeneCatalogDetail", "description", "nclase", "i.pk.catalog = t.clase and i.pk.catalogcode = t.clasecodigo");
|
|
dto.addSubQuery(subqueryClase);
|
|
|
|
SubQuery subqueryFalta = new SubQuery("TgeneCatalogDetail", "description", "nfalta", "i.pk.catalog = t.falta and i.pk.catalogcode = t.faltacodigo");
|
|
dto.addSubQuery(subqueryFalta);
|
|
|
|
SubQuery subqueryTipoFalta = new SubQuery("TgeneCatalogDetail", "description", "ntipoFalta", "i.pk.catalog = t.tipofalta and i.pk.catalogcode = t.tipofaltacodigo");
|
|
dto.addSubQuery(subqueryTipoFalta);
|
|
|
|
SubQuery subqueryTramite = new SubQuery("TgeneCatalogDetail", "description", "ntramite", "i.pk.catalog = t.tramite and i.pk.catalogcode = t.tramitecodigo");
|
|
dto.addSubQuery(subqueryTramite);
|
|
|
|
SubQuery subquerySancion = new SubQuery("TgeneCatalogDetail", "description", "nsancion", "i.pk.catalog = t.sancion and i.pk.catalogcode = t.sancioncodigo");
|
|
dto.addSubQuery(subquerySancion);
|
|
|
|
SubQuery subqueryTiempo = new SubQuery("TgeneCatalogDetail", "description", "ntiempo", "i.pk.catalog = t.tiempo and i.pk.catalogcode = t.tiempocodigo");
|
|
dto.addSubQuery(subqueryTiempo);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmTipoSancion>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmTipoSancion>) resp.get(beanalias);
|
|
super.postQuery(lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public void setcatalog() {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(this.record);
|
|
}
|
|
|
|
public void setcatalog(TarmTipoSancion tarmTipoSancion) {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(tarmTipoSancion);
|
|
}
|
|
|
|
public static void openLov(Map<String, List<String>> params) {//, List<TarmTipoSancion> tsancion
|
|
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(), 850);
|
|
options.put(EnumLovOption.RESIZABLE.getLabel(), false);
|
|
|
|
RequestContext.getCurrentInstance().openDialog("/pages/armas/lov/sancionarLov.xhtml", options, params);
|
|
}
|
|
|
|
// public List<TarmTipoSancion> getTsancion() {
|
|
// return tsancion;
|
|
// }
|
|
//
|
|
// public void setTsancion(List<TarmTipoSancion> tsancion) {
|
|
// this.tsancion = tsancion;
|
|
// }
|
|
} |