148 lines
4.6 KiB
Plaintext
Executable File
148 lines
4.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.Filter;
|
|
import com.fp.dto.query.SubQuery;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.enums.EnumLovOption;
|
|
import com.fp.frontend.helper.CallerHelper;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.fun.TarmCarga;
|
|
import com.fp.persistence.parmas.param.TarmTipoArmaExplosivo;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
|
|
/**
|
|
* Clase controladora del lov asociado al bean TarmCarga.
|
|
*
|
|
* @author Christian Pazmino
|
|
* @version 2.1
|
|
*/
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class CargasLovController extends AbstractController<TarmCarga> {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private String tituloLOV;
|
|
private String personcode;
|
|
|
|
|
|
public CargasLovController() throws Exception {
|
|
super(TarmCarga.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() throws Exception {
|
|
this.init();
|
|
personcode = CallerHelper.getLovParameter("personcode");
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
}
|
|
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 500; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "CARGASLOV";
|
|
this.querydatabase();
|
|
} 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.fecha desc");
|
|
String sql="";
|
|
if(personcode!= null){
|
|
sql="t.esdesaduanizado = 'N' and t.tipocarga='IMP' and t.personcode ="+ personcode;
|
|
// Filtro para la TX 30-20
|
|
if(!this.getLoginController().getRequest().getTransactionCode().equals(37)){
|
|
sql=sql+" and t.csolicitud is null";
|
|
}
|
|
}else{
|
|
MessageHelper.setMessageError("EL CODIGO DE PERSONA ES REQUERIDO");
|
|
return;
|
|
}
|
|
Filter filtro= new Filter();
|
|
filtro.setSql(sql); //TarmTipoArmaExplosivo//catalogcode
|
|
dto.addFiltro(filtro);
|
|
|
|
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<TarmCarga>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TarmCarga>) resp.get(this.beanalias);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public void setCarga() {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(this.record);
|
|
}
|
|
|
|
public void setCarga(TarmCarga carga) {
|
|
// se utiliza en la pagina del lov.
|
|
RequestContext.getCurrentInstance().closeDialog(carga);
|
|
}
|
|
|
|
public String getTituloLOV() {
|
|
return tituloLOV;
|
|
}
|
|
|
|
public void setTituloLOV(String tituloLOV) {
|
|
this.tituloLOV = tituloLOV;
|
|
}
|
|
|
|
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(), 700);
|
|
options.put(EnumLovOption.RESIZABLE.getLabel(), false);
|
|
RequestContext.getCurrentInstance().openDialog("/pages/armas/lov/cargasLov.xhtml", options, params);
|
|
}
|
|
|
|
public String getPersoncode() {
|
|
return personcode;
|
|
}
|
|
|
|
public void setPersoncode(String personcode) {
|
|
this.personcode = personcode;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|