maia/.svn/pristine/e9/e9d59e8c2cfec6a2de5a5bedc9c...

837 lines
32 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.frontend.controller.armas.solicitud;
import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
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.ReportController;
import com.fp.frontend.controller.alfresco.AlfrescoController;
import com.fp.frontend.controller.armas.funcionalidad.RegistroArmController;
import com.fp.frontend.controller.armas.parametros.CentroControlArmasController;
import com.fp.frontend.controller.pcustomer.PersonDetailController;
import com.fp.frontend.controller.pcustomer.lov.PersonLovController;
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
import com.fp.frontend.controller.pgeneral.menu.MenuController;
import com.fp.frontend.helper.MessageHelper;
import com.fp.frontend.utility.MsgControlArmas;
import com.fp.frontend.utility.MsgGeneral;
import com.fp.frontend.utility.Utilidades;
import com.fp.persistence.parmas.fun.TarmRegistroArmas;
import com.fp.persistence.parmas.param.TarmCentroControl;
import com.fp.persistence.parmas.param.TarmTramite;
import com.fp.persistence.parmas.soli.TarmArmas;
import com.fp.persistence.parmas.soli.TarmCertificadoArmas;
import com.fp.persistence.parmas.soli.TarmCertificadoArmasKey;
import com.fp.persistence.parmas.soli.TarmCertificadoFiscalia;
import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
/**
* Controlador que permite genereal los certificados de Fiscalia
* @author Manuel Cepeda
*
*/
@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class CertificadoFiscaliaController extends AbstractController<TarmArmas> {
private String razonSocial;
private String numeroDocumento;
private String lote;
private boolean panelPerson;
private boolean panelSinDatosPerson;
private boolean panelSinDatosArma;
private String filtroPersona;
private List<TarmArmas> listaArmas;
private List<TarmArmas> listaArmasBySerie;
@ManagedProperty(value = "#{personLovController}")
private PersonLovController personLovController;
@ManagedProperty(value = "#{certificadoArmasController}")
private CertificadoArmasController certificadoArmasController;
@ManagedProperty(value = "#{reportController}")
private ReportController reportController;
private String sessionID;
private TcustPersonDetail tcustPersonDetail;
private String nroSolicitud;
private TarmCentroControl centroControl;
private TarmCertificadoFiscalia certificadoFiscalia;
@ManagedProperty(value = "#{solicitudCertificadoController}")
private SolicitudCertificadoController solicitudCertificadoController;
/**
* Bandera de tipo booleano para indicar si se habilita el boton de completar tarea
*/
private Boolean esTareaCompleta = Boolean.FALSE;
/**
* Clase controladora de funcionalidad del Alfresco
*/
@ManagedProperty(value="#{alfrescoController}")
private AlfrescoController alfrescoController;
/**
* Deshabilita la pantalla despu&eacute;s de grabar la solicitud
*/
private boolean deshabilitarPantalla;
public CertificadoFiscaliaController() throws Exception {
super(TarmArmas.class);
}
/**
* M&eacute;todo que se ejecuta despu&eacute;s del constructor
*/
@PostConstruct
private void postconstruct() {
try {
super.startQuery();
nroSolicitud = this.getMfilters().get("csolicitud");
this.getMfilters().clear();
this.getPersonLovController().getMfilters().clear();
this.getCertificadoArmasController().getMfilters().clear();
this.getSolicitudCertificadoController().getMfilters().clear();
this.init();
panelPerson = true;
panelSinDatosPerson = false;
panelSinDatosArma = false;
} catch (Exception e) {
MessageHelper.setMessageError(e);
}
panelSinDatosPerson = false;
panelSinDatosArma = false;
}
/**
* Inicializa valores del controlador
*/
private void init() {
try {
filtroPersona = "";
certificadoFiscalia = SolicitudCertificadoController.findPorSolicitud(nroSolicitud.trim());
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
sessionID = session.getId();
// recperpage = 15; // Cambiar al # reg a mirar.
lrecord = new ArrayList<>();
centroControl=Utilidades.obtenerCentroControl();
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
if(tsafeUserDetail!=null && tsafeUserDetail.getPk().getPersoncode()!=null){
tcustPersonDetail=PersonDetailController.find(tsafeUserDetail.getPk().getPersoncode().toString());
}
} catch (Exception e) {
MessageHelper.setMessageError(e);
}
}
@Override
public void next() throws Exception {
super.next();
}
/**
* Retorna un {@link DtoQuery} con los atributos a presentarse
* @return
* @throws Exception
*/
private DtoQuery getDtoQuery() throws Exception{
DtoQuery dto = super.getDtoQuery(true);
SubQuery subqueryMarca= new SubQuery("TgeneCatalogDetail","description","marca","i.pk.catalog=t.marca and i.pk.catalogcode=t.marcacodigo");
dto.addSubQuery(subqueryMarca);
SubQuery subqueryColor= new SubQuery("TgeneCatalogDetail","description","color","i.pk.catalog=t.color and i.pk.catalogcode=t.colorcodigo");
dto.addSubQuery(subqueryColor);
SubQuery subqueryEstado= new SubQuery("TgeneCatalogDetail","description","estado","i.pk.catalog=t.estado and i.pk.catalogcode=t.estadocodigo");
dto.addSubQuery(subqueryEstado);
SubQuery subqueryClase= new SubQuery("TarmTipoArmaExplosivo","clase","cclase","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryClase);
SubQuery subqueryClaseCodigo= new SubQuery("TarmTipoArmaExplosivo","clasecodigo","cclasecodigo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryClaseCodigo);
SubQuery subqueryLongitud= new SubQuery("TarmTipoArmaExplosivo","longitud","clongitud","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryLongitud);
SubQuery subqueryLongitudCodigo= new SubQuery("TarmTipoArmaExplosivo","longitudcodigo","clongitudcodigo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryLongitudCodigo);
SubQuery subqueryCalibre= new SubQuery("TarmTipoArmaExplosivo","calibre","ccalibre","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryCalibre);
SubQuery subqueryCalibreCodigo= new SubQuery("TarmTipoArmaExplosivo","calibrecodigo","ccalibrecodigo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryCalibreCodigo);
SubQuery subqueryTipoArma= new SubQuery("TarmTipoArmaExplosivo","tipoarmaexplosivo","ctipoarmaexplosivo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryTipoArma);
SubQuery subqueryTipoArmaCodigo= new SubQuery("TarmTipoArmaExplosivo","tipoarmaexplosivocodigo","ctipoarmaexplosivocodigo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryTipoArmaCodigo);
SubQuery subqueryUnidad= new SubQuery("TarmTipoArmaExplosivo","unidadmedidapeso","cunidadmedidapeso","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryUnidad);
SubQuery subqueryUnidadCodigo= new SubQuery("TarmTipoArmaExplosivo","unidadmedidapesocodigo","cunidadmedidapesocodigo","i.pk=t.ctipoarmaexplosivo");
dto.addSubQuery(subqueryUnidadCodigo);
SubQuery subqueryUnidadMedida= new SubQuery("TgeneCatalogDetail","description","unidadmedida","i.pk.catalog=t.unidadmedidacantidad and i.pk.catalogcode=t.unidadmedidacantidadcodigo");
dto.addSubQuery(subqueryUnidadMedida);
SubQuery subquerycpersoncode= new SubQuery("TarmRegistroArmas","personcode","personcode","i.pk=t.cregistro");
dto.addSubQuery(subquerycpersoncode);
return dto;
}
@Override
public void save() {
}
/**
* Metodo para finalizar la tarea del flujo
*/
public void completarTarea() {
try {
if(esTareaCompleta){
return;
}
Request request = callerhelper.getRequest();
// limpiar request para finalizar la tarea.
super.cleanRequest(request);
request.modifiedData().put("csolicitud", nroSolicitud);
request.modifiedData().put("TID", tid);
request.modifiedData().put("BPMStatus", bpmDataStatus == null ? "A" : bpmDataStatus); // A,D,R
request.modifiedData().put("BPMObs", bpmDataComment == null ? "OK" : bpmDataComment);
Response resp = callerhelper.executeSave(request);
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
MessageHelper.setMessageInfo(resp);
esTareaCompleta=Boolean.TRUE;
RequestContext.getCurrentInstance().execute("Maia.refreshusertasks()");
} else {
MessageHelper.setMessageError(resp);
}
} catch (Throwable e) {
MessageHelper.setMessageError(e);
}
}
/**
* Genera el certificado de armas para la Fiscalia y sube al Alfresco el pdf
*/
public void generarReporte() {
if(deshabilitarPantalla){
return;
}
String path = "armas/reports/certificadosArmas";
Boolean aux=Boolean.FALSE;
java.util.Date today = new java.util.Date();
java.sql.Timestamp fechaReporte = new java.sql.Timestamp(today.getTime());
Random aleatorio = new Random();
int ticketGenerado = aleatorio.nextInt();
int i=0;
for(TarmArmas armasel:lrecord){
i++;
if(armasel.getModifiedData().get("seleccionado")!=null && armasel.getModifiedData().get("seleccionado").equals(Boolean.TRUE)){
aux=Boolean.TRUE;
guardarCertificadoReporte(armasel, i, ticketGenerado, fechaReporte);
}
}
if(!aux){
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_nohaseleccionadoarmas"));
return;
}
certificadoArmasController.save();
try {
//Fija parametros del report.
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
parameters.put("codResponsable", centroControl.getPersoncode());
parameters.put("gradoresponsable","" ); //centroControl.getModifiedData().get("desgrado")
parameters.put("nombreresponsable",centroControl.getModifiedData().get("desgrado")+" "+ centroControl.getModifiedData().get("nombre"));
parameters.put("centrocontrol", String.valueOf(centroControl.getModifiedData().get("desnombreinstitucion")));
parameters.put("sessionID",sessionID);
parameters.put("nroSolicitud",certificadoFiscalia.getNroficiofiscalia());
// parameters.put("fechaReporte",fechaReporte);
parameters.put("ticket",ticketGenerado);
parameters.put("personCodeLogin",(tcustPersonDetail!=null && tcustPersonDetail.getPk()!=null)?tcustPersonDetail.getPk().getPersoncode():null);
if(tcustPersonDetail!=null){
parameters.put("usuario", tcustPersonDetail.getName());
}
parameters.put("unidadmilitar", MsgControlArmas.getProperty("msg_inf_digitadordel")+" "+String.valueOf(centroControl.getModifiedData().get("desnombreinstitucion")));
String format="pdf";
String filename="Certificado";
InputStream file =this.reportController.jaspertoInputstream(path, parameters, format, filename, this.getLoginController());
String xPathLocation= getRutaDocumentoCertificadoBase() + "/cm:" + this.nroSolicitud;
String nombreArchivo = "CERT" + nroSolicitud + ".pdf";
alfrescoController.uploadFile(file, nombreArchivo, xPathLocation);
//actualizar solicitudCertificadoController
solicitudCertificadoController.getMfilters().put("nrsolicitud", nroSolicitud);
solicitudCertificadoController.querydatabase();
TarmCertificadoFiscalia tarmCertificadoFiscalia = solicitudCertificadoController.getRecord();
tarmCertificadoFiscalia.setIsnew(false);
tarmCertificadoFiscalia.setXpathSolicitudArma(xPathLocation+"/cm:"+nombreArchivo);
solicitudCertificadoController.getLrecord().add(tarmCertificadoFiscalia);
solicitudCertificadoController.update();
solicitudCertificadoController.save();
deshabilitarPantalla = Boolean.TRUE;
MessageHelper.setMessageInfo("Se genero el certificado exitosamente.");
} catch (Exception ex) {
MessageHelper.setMessageError(ex);
}
}
/**
* Retorna la ruta base donde se almacenara dicho archivo
*
* @return
*/
public String getRutaDocumentoCertificadoBase() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new java.util.Date());
StringBuilder ruta = new StringBuilder("cm:Certificados");
ruta = ruta.append("/cm:A-").append(calendar.get(Calendar.YEAR));
ruta = ruta.append("/cm:M-").append((calendar.get(Calendar.MONTH)+1) <= 9 ? "0" + (calendar.get(Calendar.MONTH) + 1) : (calendar.get(Calendar.MONTH)+1));
return ruta.toString();
}
/**
* Guarda los datos de las Armas solicitadas por el Fiscal a la bdd
* @param armaObj
* @param orden
* @param ticket
* @param fechaReporte
*/
private void guardarCertificadoReporte(TarmArmas armaObj,int orden,int ticket, java.sql.Timestamp fechaReporte){
TarmCertificadoArmas certificadoArmasObj = new TarmCertificadoArmas();
TarmCertificadoArmasKey pk = new TarmCertificadoArmasKey();
certificadoArmasObj.setPk(pk);
try {
certificadoArmasObj.getPk().setFechareporte(fechaReporte);
certificadoArmasObj.getPk().setSessionid(sessionID);
certificadoArmasObj.getPk().setOrden(orden);
certificadoArmasObj.setIdentification(armaObj.getModifiedData().get("noDocumento")!=null?armaObj.getModifiedData().get("noDocumento").toString():null);
certificadoArmasObj.setName(armaObj.getModifiedData().get("propietario")!=null?armaObj.getModifiedData().get("propietario").toString():null);
certificadoArmasObj.setRegisterdate(armaObj.getFecharegistro());
certificadoArmasObj.setClase(armaObj.getModifiedData().get("clase")!=null?armaObj.getModifiedData().get("clase").toString():null);
certificadoArmasObj.setTipoarmaexplosivo(armaObj.getModifiedData().get("tipoarmaexplosivo")!=null?armaObj.getModifiedData().get("tipoarmaexplosivo").toString():null);
certificadoArmasObj.setMarca(armaObj.getModifiedData().get("marca")!=null?armaObj.getModifiedData().get("marca").toString():null);
certificadoArmasObj.setCalibre(armaObj.getModifiedData().get("calibre")!=null?armaObj.getModifiedData().get("calibre").toString():null);
certificadoArmasObj.setLote(armaObj.getLote());
certificadoArmasObj.setPaisfabricacion(armaObj.getModifiedData().get("paisorigen")!=null?armaObj.getModifiedData().get("paisorigen").toString():null);
certificadoArmasObj.setEstado(armaObj.getModifiedData().get("estado")!=null?armaObj.getModifiedData().get("estado").toString():null);
certificadoArmasObj.setUsercode((tcustPersonDetail!=null && tcustPersonDetail.getPk()!=null)?tcustPersonDetail.getPk().getPersoncode().toString():null);
certificadoArmasObj.setTicket(ticket);
certificadoArmasObj.setPermiso((armaObj.getModifiedData().get("permiso") != null) ? armaObj.getModifiedData().get("permiso").toString() : "");//armaObj.getModifiedData().get("permiso").toString());
certificadoArmasObj.setFechaemison((Date) armaObj.getModifiedData().get("fechaemision"));
certificadoArmasObj.setFechaexpiracion((Date)armaObj.getModifiedData().get("fechaexpiracion"));
certificadoArmasObj.setIsnew(true);
certificadoArmasController.update(certificadoArmasObj);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Selecciona el objeto TcustPersonDetail de la tabla actual de la pagina
* @param person
*/
public void setPerson(TcustPersonDetail person) {
if(person != null){
panelPerson = false;
filtroPersona = " and t.cregistro in (select i.pk from TarmRegistroArmas i where i.personcode ="+person.getPk().getPersoncode()+")";
querydatabaseArma();
setRazonSocial(person.getName());
setNumeroDocumento(person.getIdentification());
}
}
/**
* Permite consultar en la tabla armas mediante el codigo de la persona
*/
protected void querydatabaseArma() {
try {
DtoQuery dto = this.getDtoQuery();
dto.setOrderby("pk");
Filter filtro = new Filter();
String sql="t.fecharegistro=(select max(ta.fecharegistro) from TarmArmas ta where t.codigoarma=ta.codigoarma) and t.estado !='DEST' and t.estado!='VEND' and t.estado!='MING' and t.estado!='DUPL' and t.estado!='CUSTEM'"
+ " and (t.peso>0 or t.cantidad>0) " + filtroPersona;//
filtro.setSql(sql);
dto.addFiltro(filtro);
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
Request request = this.callerhelper.getRequest();
request.setQueryTables(mtables);
Response resp = this.callerhelper.executeQuery(request);
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
listaArmas = new ArrayList<TarmArmas>();
MessageHelper.setMessageError(resp);
} else {
listaArmas= (List<TarmArmas>) resp.get(this.beanalias);
actualizarDatos(listaArmas);
}
} catch (Throwable e) {
MessageHelper.setMessageError(e);
}
}
/**
* Permite actualizar los datos de la Entidad TarmAmas
* @param listaArmas
*/
private void actualizarDatos(List<TarmArmas> listaArmas){
for(TarmArmas armasObj:listaArmas){
TarmRegistroArmas registroArmasObj = RegistroArmController.findByCodigo(armasObj.getCregistro().toString());
if(registroArmasObj!=null && registroArmasObj.getPersoncode()!=null){
TcustPersonDetail propietarioObj = PersonDetailController.find(registroArmasObj.getPersoncode().toString());
if(propietarioObj.getIdentificationcatalog()!=null && propietarioObj.getIdentificationcatalogcode()!=null){
armasObj.getModifiedData().put("tipoDocumento", CatalogDetailController.findxCodigoCodcatalogo(propietarioObj.getIdentificationcatalog(), propietarioObj.getIdentificationcatalogcode()).getDescription());
}
armasObj.getModifiedData().put("noDocumento", propietarioObj.getIdentification());
armasObj.getModifiedData().put("nombrerazonsocial", propietarioObj.getName());
armasObj.getModifiedData().put("paisorigencode", registroArmasObj.getPaisorigen());
if(armasObj.getModifiedData().get("cclase")!=null){
armasObj.getModifiedData().put("clase", CatalogDetailController.findxCodigoCodcatalogo(armasObj.getModifiedData().get("cclase").toString(), armasObj.getModifiedData().get("cclasecodigo").toString()).getDescription());
}
if(armasObj.getModifiedData().get("ctipoarmaexplosivo")!=null){
armasObj.getModifiedData().put("tipoarmaexplosivo", CatalogDetailController.findxCodigoCodcatalogo(armasObj.getModifiedData().get("ctipoarmaexplosivo").toString(), armasObj.getModifiedData().get("ctipoarmaexplosivocodigo").toString()).getDescription());
}
if(armasObj.getModifiedData().get("ccalibre")!=null){
armasObj.getModifiedData().put("calibre", CatalogDetailController.findxCodigoCodcatalogo(armasObj.getModifiedData().get("ccalibre").toString(), armasObj.getModifiedData().get("ccalibrecodigo").toString()).getDescription());
}
TarmDocumentoHabilitante documentoHabilitante = DocumentoHabilitanteController.findxarma(armasObj.getPk());
if(documentoHabilitante != null ){
armasObj.getModifiedData().put("fechaemision", documentoHabilitante.getFechaemision());
armasObj.getModifiedData().put("fechaexpiracion", documentoHabilitante.getFechaexpiracion());
TarmTramite tarmTramite = TarmTramiteController.find(documentoHabilitante.getCtramite().toString());
if(tarmTramite != null){
armasObj.getModifiedData().put("permiso", tarmTramite.getModifiedData().get("usoactividad"));
}
}
//cargarPropietario
armasObj.getModifiedData().put("ordenarma",armasObj.getPk());
if(armasObj.getModifiedData().get("personcode")!=null){
TcustPersonDetail personaDetalle=PersonDetailController.find(armasObj.getModifiedData().get("personcode").toString());
armasObj.getModifiedData().put("propietario", personaDetalle.getName());
armasObj.getModifiedData().put("noDocumento", personaDetalle.getIdentification());
armasObj.getModifiedData().put("nombrerazonsocial", personaDetalle.getName());
}
}
}
}
/**
* Permite consultar en la tabla armas mediante el lote/serie de armas
*/
public void querydatabaseSerie() {
try {
DtoQuery dto = this.getDtoQuery();
String sqlFiltroEstados = "";
String sqlFiltroCodigosArmas = "";//1
dto.setOrderby("pk");
String sqlActual = " t.fecharegistro=(select max(ta.fecharegistro) from TarmArmas ta where t.codigoarma=ta.codigoarma) "
+ " and (t.peso>0 or t.cantidad>0)";// and (t.cregistro=ta.cregistro) para el manejo de los explosivos
String sqlFinal = obtenerFiltroBusquedaGeneral(sqlFiltroEstados, sqlFiltroCodigosArmas, sqlActual);
Filter filtroFinal = new Filter();
filtroFinal.setSql(sqlFinal);
dto.addFiltro(filtroFinal);
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
Request request = this.callerhelper.getRequest();
request.setQueryTables(mtables);
Response resp = this.callerhelper.executeQuery(request);
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
listaArmasBySerie = new ArrayList<TarmArmas>();
MessageHelper.setMessageError(resp);
} else {
listaArmasBySerie = (List<TarmArmas>) resp.get(this.beanalias);
actualizarDatos(listaArmasBySerie);
}
} catch (Throwable e) {
MessageHelper.setMessageError(e);
}
}
/**
* Metodo que agrega dinamicamente los filtros a una consulta SQL
* @param sqlFiltros
* @return String
*/
private String obtenerFiltroBusquedaGeneral(String... sqlFiltros ){
StringBuffer sqlFinal = new StringBuffer();
for (int i = 0; i < sqlFiltros.length ; i++) {
if(sqlFinal.length() > 0 && !StringUtils.endsWith(StringUtils.trim(sqlFinal.toString()), "AND")){
sqlFinal.append( " AND ");
}
sqlFinal.append(sqlFiltros[i]);
}
return sqlFinal.toString();
}
/**
* Seleccionado todos los registros de la tabla
*/
public void seleccionarTodos(AjaxBehaviorEvent event) {
try {
Boolean valorColocar = Boolean.FALSE;
if(Boolean.valueOf(event.getComponent().getAttributes().get("value") != null ? event.getComponent().getAttributes().get("value").toString() : "false")){
valorColocar = Boolean.TRUE;
}
for (TarmArmas tarmArmas : listaArmas) {
tarmArmas.getModifiedData().put("seleccionado", valorColocar);
}
} catch (Throwable e) {
MessageHelper.setMessageError(e);
}
}
/**
* Permite actualizar el campo seleccionado en la entidad tarmArmas
*/
public void actualizarDatosArma(){
for(TarmArmas tarmArmas : listaArmas){
if(tarmArmas.getModifiedData().get("seleccionado").equals(Boolean.TRUE)){
this.getLrecord().add(tarmArmas);
}
}
panelPerson = true;
personLovController.init();
personLovController.getMfilters().clear();
getMfilters().clear();
}
/**
* Permite actualizar el campo seleccionado en la entidad tarmArmas
*/
public void actualizarDatosArmaSerie(){
for(TarmArmas tarmArmas : listaArmasBySerie){
if(tarmArmas.getModifiedData().get("seleccionado").equals(Boolean.TRUE)){
this.getLrecord().add(tarmArmas);
}
}
panelPerson = true;
setPanelSinDatosPerson(false);
listaArmasBySerie = new ArrayList<>();
this.getMfilters().clear();
}
/**
* Metodo para extrer solo elnoimbre del archivo
* @param xpath xpath del archivo en alfresco
* @return solo la parte correspondiente al nombre del archivo
*/
public String soloNombreArchivo(String xpath){
return xpath.substring(xpath.lastIndexOf(":") + 1,xpath.length());
}
public void onReturnPersonLov(){
numeroDocumento = "";
razonSocial = "";
setPanelPerson(true);
setPanelSinDatosPerson(false);
setPanelSinDatosArma(false);
getMfilters().clear();
}
public void emptyPerson(){
if((lote == null || "".equals(lote)) && (numeroDocumento == null || "".equals(numeroDocumento)) && (razonSocial == null || "".equals(razonSocial))){
MessageHelper.setMessageError("Ingrese el campo Identificaci<63>n o el campo Nombre");
return;
}
TarmArmas obj = new TarmArmas();
if(razonSocial == null || "".equals(razonSocial)){
razonSocial = "N/A";
}
if(lote != null && !"".equals(lote)){
obj.setLote(lote);
}
if(numeroDocumento != null || !"".equals(numeroDocumento)){
obj.getModifiedData().put("noDocumento", numeroDocumento);
}
obj.getModifiedData().put("nombrerazonsocial", razonSocial);
obj.getModifiedData().put("propietario", razonSocial);
obj.getModifiedData().put("permiso", "No se registra permisos en el sistema");
lrecord.add(obj);
personLovController.init();
personLovController.getMfilters().clear();
setLote("");
numeroDocumento = "";
razonSocial = "";
}
public boolean isPanelPerson() {
return panelPerson;
}
public void setPanelPerson(boolean panelPerson) {
this.panelPerson = panelPerson;
}
public List<TarmArmas> getListaArmas() {
return listaArmas;
}
public void setListaArmas(List<TarmArmas> listaArmas) {
this.listaArmas = listaArmas;
}
/**
* @return the razonSocial
*/
public String getRazonSocial() {
return razonSocial;
}
/**
* @param razonSocial the razonSocial to set
*/
public void setRazonSocial(String razonSocial) {
this.razonSocial = razonSocial;
}
/**
* @return the numeroDocumento
*/
public String getNumeroDocumento() {
return numeroDocumento;
}
/**
* @param numeroDocumento the numeroDocumento to set
*/
public void setNumeroDocumento(String numeroDocumento) {
this.numeroDocumento = numeroDocumento;
}
/**
* @return the personLovController
*/
public PersonLovController getPersonLovController() {
return personLovController;
}
/**
* @param personLovController the personLovController to set
*/
public void setPersonLovController(PersonLovController personLovController) {
this.personLovController = personLovController;
}
/**
* @return the listaArmasBySerie
*/
public List<TarmArmas> getListaArmasBySerie() {
return listaArmasBySerie;
}
/**
* @param listaArmasBySerie the listaArmasBySerie to set
*/
public void setListaArmasBySerie(List<TarmArmas> listaArmasBySerie) {
this.listaArmasBySerie = listaArmasBySerie;
}
/**
* @return the certificadoArmasController
*/
public CertificadoArmasController getCertificadoArmasController() {
return certificadoArmasController;
}
/**
* @param certificadoArmasController the certificadoArmasController to set
*/
public void setCertificadoArmasController(
CertificadoArmasController certificadoArmasController) {
this.certificadoArmasController = certificadoArmasController;
}
/**
* @return the reportController
*/
public ReportController getReportController() {
return reportController;
}
/**
* @param reportController the reportController to set
*/
public void setReportController(ReportController reportController) {
this.reportController = reportController;
}
@Override
protected void querydatabase() {
// TODO Auto-generated method stub
}
/**
* @return the alfrescoController
*/
public AlfrescoController getAlfrescoController() {
return alfrescoController;
}
/**
* @param alfrescoController the alfrescoController to set
*/
public void setAlfrescoController(AlfrescoController alfrescoController) {
this.alfrescoController = alfrescoController;
}
/**
* @return the solicitudCertificadoController
*/
public SolicitudCertificadoController getSolicitudCertificadoController() {
return solicitudCertificadoController;
}
/**
* @param solicitudCertificadoController the solicitudCertificadoController to set
*/
public void setSolicitudCertificadoController(
SolicitudCertificadoController solicitudCertificadoController) {
this.solicitudCertificadoController = solicitudCertificadoController;
}
/**
* @return the certificadoFiscalia
*/
public TarmCertificadoFiscalia getCertificadoFiscalia() {
return certificadoFiscalia;
}
/**
* @param certificadoFiscalia the certificadoFiscalia to set
*/
public void setCertificadoFiscalia(TarmCertificadoFiscalia certificadoFiscalia) {
this.certificadoFiscalia = certificadoFiscalia;
}
/**
* @return the nroSolicitud
*/
public String getNroSolicitud() {
return nroSolicitud;
}
/**
* @param nroSolicitud the nroSolicitud to set
*/
public void setNroSolicitud(String nroSolicitud) {
this.nroSolicitud = nroSolicitud;
}
/**
* @return the esTareaCompleta
*/
public boolean isEsTareaCompleta() {
return esTareaCompleta;
}
/**
* @param esTareaCompleta the esTareaCompleta to set
*/
public void setEsTareaCompleta(boolean esTareaCompleta) {
this.esTareaCompleta = esTareaCompleta;
}
/**
* @return the panelSinDatosPerson
*/
public boolean isPanelSinDatosPerson() {
return panelSinDatosPerson;
}
/**
* @param panelSinDatosPerson the panelSinDatosPerson to set
*/
public void setPanelSinDatosPerson(boolean panelSinDatosPerson) {
this.panelSinDatosPerson = panelSinDatosPerson;
}
/**
* @return the panelSinDatosArma
*/
public boolean isPanelSinDatosArma() {
return panelSinDatosArma;
}
/**
* @param panelSinDatosArma the panelSinDatosArma to set
*/
public void setPanelSinDatosArma(boolean panelSinDatosArma) {
this.panelSinDatosArma = panelSinDatosArma;
}
/**
* @return the lote
*/
public String getLote() {
return lote;
}
/**
* @param lote the lote to set
*/
public void setLote(String lote) {
this.lote = lote;
}
/**
* @return the deshabilitarPantalla
*/
public boolean isDeshabilitarPantalla() {
return deshabilitarPantalla;
}
/**
* @param deshabilitarPantalla the deshabilitarPantalla to set
*/
public void setDeshabilitarPantalla(boolean deshabilitarPantalla) {
this.deshabilitarPantalla = deshabilitarPantalla;
}
}