155 lines
5.8 KiB
Plaintext
Executable File
155 lines
5.8 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
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.ManagedProperty;
|
|
import javax.faces.bean.ViewScoped;
|
|
|
|
import org.primefaces.context.RequestContext;
|
|
import org.primefaces.event.SelectEvent;
|
|
|
|
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.alfresco.AlfrescoController;
|
|
import com.fp.frontend.enums.EnumLovOption;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
|
|
/**
|
|
* Controlador para listar los documentos habilitantes del sistema
|
|
*
|
|
*/
|
|
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class PermisosAutorizacionesController extends AbstractController<TarmDocumentoHabilitante> {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@ManagedProperty(value = "#{alfrescoController}")
|
|
private AlfrescoController alfrescoController;
|
|
|
|
private TcustPersonDetail tcustPersonDetail;
|
|
|
|
public PermisosAutorizacionesController() throws Exception{
|
|
super(TarmDocumentoHabilitante.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
public void postConstruct() {
|
|
this.init();
|
|
super.startQuery();
|
|
}
|
|
|
|
private void init(){
|
|
this.beanalias = "PERMISOSAUTORIZACIONES";
|
|
this.recperpage = 15;
|
|
this.lrecord = new ArrayList<>();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
if(!this.getMfilters().containsKey("personcode") || this.getMfilters().get("personcode")==null){
|
|
MessageHelper.setMessageError("SELECCIONE UNA IDENTIFICACI\u00d3N");
|
|
}
|
|
DtoQuery dto = super.getDtoQuery(Boolean.TRUE);
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
SubQuery subqueryCategoriaCodigo= new SubQuery("TgeneCatalogDetail", "description", "description", "i.pk.catalog = (select a.tipotramite from TarmTramite a where a.pk=t.ctramite)"
|
|
+ "and i.pk.catalogcode=(select a.tipotramitecodigo from TarmTramite a where a.pk=t.ctramite)");
|
|
dto.addSubQuery(subqueryCategoriaCodigo);
|
|
|
|
SubQuery subqueryipoAutorizacion= new SubQuery("TgeneCatalogDetail", "description", "descriptionTipoAut", "i.pk.catalog = (select a.tipoautorizacion from TarmTramite a where a.pk=t.ctramite)"
|
|
+ "and i.pk.catalogcode=(select a.tipoautorizacioncodigo from TarmTramite a where a.pk=t.ctramite)");
|
|
dto.addSubQuery(subqueryipoAutorizacion);
|
|
|
|
SubQuery subqueryTipocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptiontram", "i.pk.catalog = (select a.categoria from TarmTramite a where a.pk=t.ctramite)"
|
|
+ "and i.pk.catalogcode=(select a.categoriacodigo from TarmTramite a where a.pk=t.ctramite)");
|
|
dto.addSubQuery(subqueryTipocodigo);
|
|
SubQuery subqueryUsocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptionact", "i.pk.catalog = (select a.usoactividad from TarmTramite a where a.pk=t.ctramite)"
|
|
+ "and i.pk.catalogcode=(select a.usoactividadcodigo from TarmTramite a where a.pk=t.ctramite)");
|
|
dto.addSubQuery(subqueryUsocodigo);
|
|
SubQuery subqueryEstadoDoc=new SubQuery("TgeneCatalogDetail", "description", "estadodocumento", "i.pk.catalog = t.estado"
|
|
+ " and i.pk.catalogcode= t.estadocode");
|
|
dto.addSubQuery(subqueryEstadoDoc);
|
|
|
|
dto.setOrderby("t.fechaemision desc");
|
|
|
|
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<>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmDocumentoHabilitante>) resp.get(beanalias);
|
|
super.postQuery(lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
public void save() {
|
|
}
|
|
|
|
public static void openLov() {
|
|
Map<String, Object> options = new HashMap<String, Object>();
|
|
// hint: ver EnumLovOption para las opciones del modal
|
|
options.put(EnumLovOption.MODAL.getLabel(), true);
|
|
options.put(EnumLovOption.HEIGHT.getLabel(), 450);
|
|
options.put(EnumLovOption.WIDTH.getLabel(), 700);
|
|
options.put(EnumLovOption.RESIZABLE.getLabel(), true);
|
|
// lovpersona es el nombre de la pagina
|
|
RequestContext.getCurrentInstance().openDialog("/pages/customer/lov/personLov.xhtml", options, null);
|
|
}
|
|
|
|
|
|
/**
|
|
* Maneja la respuesta del Lov de Personas
|
|
* @param event
|
|
* @throws Exception
|
|
*/
|
|
public void onReturnPersonLov(SelectEvent event) throws Exception {
|
|
tcustPersonDetail = (TcustPersonDetail) event.getObject();
|
|
this.getMfilters().put("personcode",tcustPersonDetail.getPk().getPersoncode().toString());
|
|
this.query();
|
|
}
|
|
|
|
|
|
|
|
|
|
public TcustPersonDetail getTcustPersonDetail() {
|
|
return tcustPersonDetail;
|
|
}
|
|
|
|
public void setTcustPersonDetail(TcustPersonDetail tcustPersonDetail) {
|
|
this.tcustPersonDetail = tcustPersonDetail;
|
|
}
|
|
|
|
public AlfrescoController getAlfrescoController() {
|
|
return alfrescoController;
|
|
}
|
|
|
|
public void setAlfrescoController(AlfrescoController alfrescoController) {
|
|
this.alfrescoController = alfrescoController;
|
|
}
|
|
|
|
}
|