Java tutorial
/* Forseti, El ERP Gratuito para PyMEs Copyright (C) 2015 Gabriel Gutirrez Fuentes. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package forseti.reportes; import java.io.*; //import java.util.Calendar; //import java.util.Date; import java.util.Enumeration; import javax.imageio.ImageIO; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.CellRangeAddress; import org.apache.poi.hssf.util.HSSFColor; //import org.apache.poi.hssf.util.CellRangeAddress; //import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; //import org.apache.poi.ss.usermodel.IndexedColors; //import org.apache.poi.ss.usermodel.Color; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import org.jdom.output.Format.TextMode; import org.xhtmlrenderer.pdf.ITextRenderer; import com.lowagie.text.DocumentException; //import Acme.JPM.Encoders.GifEncoder; import forseti.JBajarArchivo; import forseti.JForsetiApl; import forseti.JFsiGrafAreas; import forseti.JFsiGrafCirc; import forseti.JFsiGrafLineas; import forseti.JFsiGraficas; import forseti.JRepCellStyles; import forseti.sets.JProcessSet; import forseti.sets.JReportesBind2Set; import forseti.sets.JReportesBind3Set; import forseti.sets.JReportesBindFSet; import forseti.sets.JReportesCompL1Set; import forseti.sets.JReportesFiltroSet; import forseti.sets.JReportesLevel1; import forseti.sets.JReportesSentenciasColumnasSet; import forseti.sets.JReportesSentenciasSet; import forseti.sets.JReportesSet; import forseti.sets.JUsuariosSubmoduloNominaPerm; import forseti.sets.REP_LEVEL1; import forseti.sets.REP_LEVEL2; import forseti.sets.JListasCatalogosSet; import forseti.sets.JUsuariosSubmoduloVentasPerm; import forseti.sets.JUsuariosSubmoduloComprasPerm; import forseti.sets.JUsuariosSubmoduloProduccionPerm; import forseti.sets.JUsuariosSubmoduloBancosPerm; import forseti.sets.JUsuariosSubmoduloBodegasPerm; import forseti.JFsiGrafBarras; import forseti.JUtil; @SuppressWarnings({ "serial", "deprecation" }) public class JReportesDlg extends JForsetiApl { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doPost(request, response); String rep_reportes_dlg = ""; request.setAttribute("rep_reportes_dlg", rep_reportes_dlg); String mensaje = ""; short idmensaje = -1; if (request.getParameter("proceso") != null && !request.getParameter("proceso").equals("")) { if (request.getParameter("proceso").equals("CARGAR_REPORTE")) { if (request.getParameter("REPID") != null) { String[] valoresParam = request.getParameterValues("REPID"); if (valoresParam.length == 1) { // Verifica que este usuario tenga permiso del reporte if (!getSesion(request) .getPermisoReporte(Integer.parseInt(request.getParameter("REPID")))) { idmensaje = 3; mensaje += MsjPermisoDenegado(request, "CEF", "REP_REPORTES"); getSesion(request).setID_Mensaje(idmensaje, mensaje); RDP("CEF", getSesion(request).getConBD(), "ER", getSesion(request).getID_Usuario(), "REP_REPORTES", "RREP|" + request.getParameter("REPID") + "|||", mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } if (request.getParameter("subproceso") != null && request.getParameter("subproceso").equals("GENERAR")) { // Solicitud de envio a procesar if (VerificarFiltro(request, response)) { try { CargarReporte(request, response); } catch (DocumentException e) { idmensaje = 3; mensaje += e.getMessage(); getSesion(request).setID_Mensaje(idmensaje, mensaje); RDP("CEF", getSesion(request).getConBD(), "ER", getSesion(request).getID_Usuario(), "REP_REPORTES", "RREP|" + request.getParameter("REPID") + "|||", mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } return; } } else { // Como el subproceso no es GENERAR, abre la ventana del proceso de FILTRADO para cargar `por primera vez JReportesSet m_RepSet = new JReportesSet(request); m_RepSet.m_Where = "ID_Report = '" + p(request.getParameter("REPID")) + "'"; m_RepSet.Open(); JReportesBindFSet set = new JReportesBindFSet(request); set.m_Where = "ID_Report = '" + p(request.getParameter("REPID")) + "'"; set.m_OrderBy = "ID_Column ASC"; set.Open(); String fechasql1, fechasql2; fechasql1 = "dd/MMM/yyyy"; fechasql2 = "ddmmmyyyy"; request.setAttribute("BindFSet", set); request.setAttribute("fechasql1", fechasql1); request.setAttribute("fechasql2", fechasql2); getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/reportes/rep_reportes_dlg.jsp", request, response); return; } } else { idmensaje = 1; mensaje += JUtil.Msj("GLB", "VISTA", "GLB", "SELEC-PROC", 2); getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } } else { idmensaje = 3; mensaje += JUtil.Msj("GLB", "VISTA", "GLB", "SELEC-PROC", 1); getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } } else { idmensaje = 3; mensaje += JUtil.Msj("GLB", "VISTA", "GLB", "SELEC-PROC", 3); getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } } else { idmensaje = 3; mensaje += JUtil.Msj("GLB", "VISTA", "GLB", "SELEC-PROC", 3); getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return; } } public String generarReporteHtml(HttpServletRequest request, HttpServletResponse response, boolean lineas) throws ServletException, IOException { String html = ""; float anchuraL1 = 0.00F, anchuraL2 = 0.00F, anchuraL3 = 0.00F; JReportesSet m_RepSet = (JReportesSet) request.getAttribute("m_RepSet"); JReportesLevel1 m_setL1 = (JReportesLevel1) request.getAttribute("m_setL1"); JReportesCompL1Set m_setCL1 = (JReportesCompL1Set) request.getAttribute("m_setCL1"); Boolean m_bSelectL1 = (Boolean) request.getAttribute("m_bSelectL1"); Boolean m_bSelectL2 = (Boolean) request.getAttribute("m_bSelectL2"); Boolean m_bSelectL3 = (Boolean) request.getAttribute("m_bSelectL3"); Boolean m_bComputeL1 = (Boolean) request.getAttribute("m_bComputeL1"); Boolean m_bComputeL2 = (Boolean) request.getAttribute("m_bComputeL2"); Boolean m_bComputeL3 = (Boolean) request.getAttribute("m_bComputeL3"); JReportesBind2Set m_selectL1 = (JReportesBind2Set) request.getAttribute("m_selectL1"); JReportesBind2Set m_selectL2 = (JReportesBind2Set) request.getAttribute("m_selectL2"); JReportesBind2Set m_selectL3 = (JReportesBind2Set) request.getAttribute("m_selectL3"); JReportesBind2Set m_computeL1 = (JReportesBind2Set) request.getAttribute("m_computeL1"); JReportesBind2Set m_computeL2 = (JReportesBind2Set) request.getAttribute("m_computeL2"); JReportesBind2Set m_computeL3 = (JReportesBind2Set) request.getAttribute("m_computeL3"); JReportesBind3Set m_colL1 = (JReportesBind3Set) request.getAttribute("m_colL1"); JReportesBind3Set m_colL2 = (JReportesBind3Set) request.getAttribute("m_colL2"); JReportesBind3Set m_colL3 = (JReportesBind3Set) request.getAttribute("m_colL3"); JReportesBind3Set m_colCL1 = (JReportesBind3Set) request.getAttribute("m_colCL1"); JReportesBind3Set m_colCL2 = (JReportesBind3Set) request.getAttribute("m_colCL2"); JReportesBind3Set m_colCL3 = (JReportesBind3Set) request.getAttribute("m_colCL3"); String fsi_filtro = (String) request.getAttribute("fsi_filtro"); String fsiTitulo = "font-family: Arial, Helvetica, sans-serif; font-size: 14pt; font-style: italic; font-weight: bold;"; String fsiEncL1 = "font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-style: normal; font-weight: bold;"; String fsiEncL2 = "font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; font-weight: bold;"; String fsiEncL3 = "font-family: Arial, Helvetica, sans-serif; font-size: 6pt; font-style: normal; font-weight: bold;"; String fsiL1 = "font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; font-weight: bold;"; String fsiL2 = "font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; font-weight: normal;"; String fsiL3 = "font-family: Arial, Helvetica, sans-serif; font-size: 6pt; font-style: normal; font-weight: normal;"; String fsiCL1 = "font-family: Arial, Helvetica, sans-serif; font-size: 9pt; font-style: normal; font-weight: bold;"; String fsiCL2 = "font-family: Arial, Helvetica, sans-serif; font-size: 8pt; font-style: normal; font-weight: bold;"; String fsiCL3 = "font-family: Arial, Helvetica, sans-serif; font-size: 6pt; font-style: normal; font-weight: bold;"; //html += "\r\n"; //html += "<!--DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"-->\r\n"; //html += "<html>\r\n"; html += "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n"; html += "<html xmlns='http://www.w3.org/1999/xhtml'>\n"; html += "<head>\r\n"; //html += "<script language=\"JavaScript\">\r\n"; //html += "\twindow.resizeTo(" + m_RepSet.getAbsRow(0).getHW() + "," + m_RepSet.getAbsRow(0).getVW() + ");\r\n"; //html += "</script>\r\n"; html += "<title>"; html += m_RepSet.getAbsRow(0).getDescription(); html += "</title>\r\n"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>\r\n"; html += "<style type=\"text/css\">\r\n"; html += "<!--\r\n"; html += ".fsiTitulo {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getTitulo() == null || m_RepSet.getAbsRow(0).getTitulo().equals("")) ? fsiTitulo : m_RepSet.getAbsRow(0).getTitulo()); html += "\r\n"; html += "}\r\n"; html += ".fsiEncL1 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getEncL1() == null || m_RepSet.getAbsRow(0).getEncL1().equals("")) ? fsiEncL1 : m_RepSet.getAbsRow(0).getEncL1()); html += "\r\n"; html += "}\r\n"; html += ".fsiEncL2 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getEncL2() == null || m_RepSet.getAbsRow(0).getEncL2().equals("")) ? fsiEncL2 : m_RepSet.getAbsRow(0).getEncL2()); html += "\r\n"; html += "}\r\n"; html += ".fsiEncL3 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getEncL3() == null || m_RepSet.getAbsRow(0).getEncL3().equals("")) ? fsiEncL3 : m_RepSet.getAbsRow(0).getEncL3()); html += "\r\n"; html += "}\r\n"; html += ".fsiL1 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getL1() == null || m_RepSet.getAbsRow(0).getL1().equals("")) ? fsiL1 : m_RepSet.getAbsRow(0).getL1()); html += "\r\n"; html += "}\r\n"; html += ".fsiL2 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getL2() == null || m_RepSet.getAbsRow(0).getL2().equals("")) ? fsiL2 : m_RepSet.getAbsRow(0).getL2()); html += "\r\n"; html += "}\r\n"; html += ".fsiL3 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getL3() == null || m_RepSet.getAbsRow(0).getL3().equals("")) ? fsiL3 : m_RepSet.getAbsRow(0).getL3()); html += "\r\n"; html += "}\r\n"; html += ".fsiCL1 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getCL1() == null || m_RepSet.getAbsRow(0).getCL1().equals("")) ? fsiCL1 : m_RepSet.getAbsRow(0).getCL1()); html += "\r\n"; html += "}\r\n"; html += ".fsiCL2 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getCL2() == null || m_RepSet.getAbsRow(0).getCL2().equals("")) ? fsiCL2 : m_RepSet.getAbsRow(0).getCL2()); html += "\r\n"; html += "}\r\n"; html += ".fsiCL3 {\r\n"; html += "\t"; html += ((m_RepSet.getAbsRow(0).getCL3() == null || m_RepSet.getAbsRow(0).getCL3().equals("")) ? fsiCL3 : m_RepSet.getAbsRow(0).getCL3()); html += "\r\n"; html += "}\r\n"; html += "-->\r\n"; html += "</style>\r\n"; html += "</head>\r\n"; html += "<body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\r\n"; html += "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n"; html += " <tr>\r\n"; html += " <td class=\"fsiTitulo\" align=\"center\">"; html += m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro; html += "</td>\r\n"; html += " </tr>\r\n"; html += " <tr>\r\n"; html += " <td class=\"fsiL1\" align=\"center\"> </td>\r\n"; html += " </tr>\r\n"; if (lineas) { html += " <tr>\r\n"; html += "\t<td bgcolor=\"#000000\" style=\"height:0.5mm;\"></td>\r\n"; html += " </tr> \r\n"; } html += " <tr>\r\n"; html += " <td>\r\n"; html += "\t\t<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n"; html += "\t\t <tr>\r\n"; html += "\t\t\t<td>\r\n"; if (m_bSelectL1.booleanValue()) { html += "\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; anchuraL1 = m_selectL1.getAbsRow(0).getTabPrintPnt(); if (m_selectL1.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiEncL1\" width=\""; html += m_selectL1.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t"; } for (int i = 0; i < m_colL1.getNumRows(); i++) { if (m_colL1.getAbsRow(i).getWillShow()) { anchuraL1 += m_colL1.getAbsRow(i).getAncho(); if (anchuraL1 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL1 = m_selectL1.getAbsRow(0).getTabPrintPnt() + m_colL1.getAbsRow(i).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t\t\t <td class=\"fsiEncL1\" width=\""; html += m_colL1.getAbsRow(i).getAncho(); html += "%\" align=\""; html += m_colL1.getAbsRow(i).getAlinHor(); html += '"'; html += ((m_colL1.getAbsRow(i).getFGColor() != null) ? " style=\"color:#" + m_colL1.getAbsRow(i).getFGColor() + ";\"" : ""); html += '>'; html += m_colL1.getAbsRow(i).getColName().toUpperCase(); html += "</td>\r\n"; html += "\t"; } } html += "\r\n"; html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += " "; } html += "\t\t\t</td>\r\n"; html += "\t\t </tr>\r\n"; html += "\t\t <tr>\r\n"; html += "\t\t\t<td>\r\n"; if (m_bSelectL2.booleanValue()) { html += "\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; anchuraL2 = m_selectL2.getAbsRow(0).getTabPrintPnt(); if (m_selectL2.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiEncL2\" width=\""; html += m_selectL2.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t"; } for (int i = 0; i < m_colL2.getNumRows(); i++) { if (m_colL2.getAbsRow(i).getWillShow()) { anchuraL2 += m_colL2.getAbsRow(i).getAncho(); if (anchuraL2 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL2 = m_selectL2.getAbsRow(0).getTabPrintPnt() + m_colL2.getAbsRow(i).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t\t\t <td class=\"fsiEncL2\" width=\""; html += m_colL2.getAbsRow(i).getAncho(); html += "%\" align=\""; html += m_colL2.getAbsRow(i).getAlinHor(); html += '"'; html += ((m_colL2.getAbsRow(i).getFGColor() != null) ? " style=\"color:#" + m_colL2.getAbsRow(i).getFGColor() + ";\"" : ""); html += '>'; html += m_colL2.getAbsRow(i).getColName().toUpperCase(); html += "</td>\r\n"; html += "\t"; } } html += "\r\n"; html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += " "; } html += "\t\t\t</td>\r\n"; html += "\t\t </tr>\r\n"; html += "\t\t <tr>\r\n"; html += "\t\t\t<td>\r\n"; if (m_bSelectL3.booleanValue()) { html += "\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; anchuraL3 = m_selectL3.getAbsRow(0).getTabPrintPnt(); if (m_selectL3.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiEncL3\" width=\""; html += m_selectL3.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t"; } for (int i = 0; i < m_colL3.getNumRows(); i++) { if (m_colL3.getAbsRow(i).getWillShow()) { anchuraL3 += m_colL3.getAbsRow(i).getAncho(); if (anchuraL3 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL3 = m_selectL3.getAbsRow(0).getTabPrintPnt() + m_colL3.getAbsRow(i).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t\t\t <td class=\"fsiEncL3\" width=\""; html += m_colL3.getAbsRow(i).getAncho(); html += "%\" align=\""; html += m_colL3.getAbsRow(i).getAlinHor(); html += '"'; html += ((m_colL3.getAbsRow(i).getFGColor() != null) ? " style=\"color:#" + m_colL3.getAbsRow(i).getFGColor() + ";\"" : ""); html += '>'; html += m_colL3.getAbsRow(i).getColName().toUpperCase(); html += "</td>\r\n"; html += "\t"; } } html += "\r\n"; html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += " "; } html += "\t\t\t</td>\r\n"; html += "\t\t </tr>\r\n"; html += "\t\t</table>\r\n"; html += "\t</td>\r\n"; html += " </tr>\r\n"; if (lineas) { html += " <tr>\r\n"; html += "\t<td bgcolor=\"#000000\" style=\"height:0.5mm;\"></td>\r\n"; html += " </tr> \r\n"; } html += " <tr>\r\n"; html += " <td class=\"fsiL1\" align=\"center\"> </td>\r\n"; html += " </tr>\r\n"; html += " <tr>\r\n"; html += " <td>\r\n"; if (m_bSelectL1.booleanValue()) { for (int RL1 = 0; RL1 < m_setL1.getNumRows(); RL1++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t"; anchuraL1 = m_selectL1.getAbsRow(0).getTabPrintPnt(); if (m_selectL1.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiL1\" width=\""; html += m_selectL1.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t"; } for (int CL1 = 0; CL1 < m_colL1.getNumRows(); CL1++) { if (m_colL1.getAbsRow(CL1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSTS(m_colL1.getAbsRow(CL1).getColName()), m_colL1.getAbsRow(CL1).getFormat(), m_colL1.getAbsRow(CL1).getBindDataType(), request); anchuraL1 += m_colL1.getAbsRow(CL1).getAncho(); if (anchuraL1 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL1 = m_selectL1.getAbsRow(0).getTabPrintPnt() + m_colL1.getAbsRow(CL1).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t <td class=\"fsiL1\" width=\""; html += m_colL1.getAbsRow(CL1).getAncho(); html += "%\" align=\""; html += m_colL1.getAbsRow(CL1).getAlinHor(); html += '"'; html += ((m_colL1.getAbsRow(CL1).getFGColor() != null) ? " style=\"color:#" + m_colL1.getAbsRow(CL1).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += "\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table> "; // Nivel 2 if (m_bSelectL2.booleanValue()) { for (int RL2 = 0; RL2 < m_setL1.getAbsRow(RL1).getSetL2().getNumRows(); RL2++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t\t\t"; anchuraL2 = m_selectL2.getAbsRow(0).getTabPrintPnt(); if (m_selectL2.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiL2\" width=\""; html += m_selectL2.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t\t\t"; } for (int CL2 = 0; CL2 < m_colL2.getNumRows(); CL2++) { if (m_colL2.getAbsRow(CL2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2) .getSTS(m_colL2.getAbsRow(CL2).getColName()), m_colL2.getAbsRow(CL2).getFormat(), m_colL2.getAbsRow(CL2).getBindDataType(), request); anchuraL2 += m_colL2.getAbsRow(CL2).getAncho(); if (anchuraL2 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL2 = m_selectL2.getAbsRow(0).getTabPrintPnt() + m_colL2.getAbsRow(CL2).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t <td class=\"fsiL2\" width=\""; html += m_colL2.getAbsRow(CL2).getAncho(); html += "%\" align=\""; html += m_colL2.getAbsRow(CL2).getAlinHor(); html += '"'; html += ((m_colL2.getAbsRow(CL2).getFGColor() != null) ? " style=\"color:#" + m_colL2.getAbsRow(CL2).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += "\t\t\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table> "; // Nivel 3 if (m_bSelectL3.booleanValue()) { for (int RL3 = 0; RL3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getNumRows(); RL3++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t\t\t\t\t"; anchuraL3 = m_selectL3.getAbsRow(0).getTabPrintPnt(); if (m_selectL3.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiL3\" width=\""; html += m_selectL3.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t\t\t\t\t"; } for (int CL3 = 0; CL3 < m_colL3.getNumRows(); CL3++) { if (m_colL3.getAbsRow(CL3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getAbsRow(RL3).getSTS(m_colL3.getAbsRow(CL3).getColName()), m_colL3.getAbsRow(CL3).getFormat(), m_colL3.getAbsRow(CL3).getBindDataType(), request); anchuraL3 += m_colL3.getAbsRow(CL3).getAncho(); if (anchuraL3 > 100) //Si el ancho de este elemento sobrepasa el 100%, brinca a la siguiente linea { anchuraL3 = m_selectL3.getAbsRow(0).getTabPrintPnt() + m_colL3.getAbsRow(CL3).getAncho(); html += "\t\t\t\t</tr>\r\n"; html += "\t\t\t </table>\r\n"; html += "\t\t\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t\t\t \t<tr>\r\n"; } html += "\r\n"; html += "\t\t <td class=\"fsiL3\" width=\""; html += m_colL3.getAbsRow(CL3).getAncho(); html += "%\" align=\""; html += m_colL3.getAbsRow(CL3).getAlinHor(); html += '"'; html += ((m_colL3.getAbsRow(CL3).getFGColor() != null) ? " style=\"color:#" + m_colL3.getAbsRow(CL3).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += "\t\t\t\t\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table> "; } if (m_bComputeL3.booleanValue()) { for (int RC3 = 0; RC3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getNumRows(); RC3++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t\t\t\t\t\t"; if (m_computeL3.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiCL3\" width=\""; html += m_computeL3.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t\t\t\t\t\t"; } for (int CC3 = 0; CC3 < m_colCL3.getNumRows(); CC3++) { if (m_colCL3.getAbsRow(CC3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getAbsRow(RC3) .getSTS(m_colCL3.getAbsRow(CC3).getColName()), m_colCL3.getAbsRow(CC3).getFormat(), m_colCL3.getAbsRow(CC3).getBindDataType(), request); html += "\r\n"; html += "\t\t <td class=\"fsiCL3\" width=\""; html += m_colCL3.getAbsRow(CC3).getAncho(); html += "%\" align=\""; html += m_colCL3.getAbsRow(CC3).getAlinHor(); html += '"'; html += ((m_colCL3.getAbsRow(CC3).getFGColor() != null) ? " style=\"color:#" + m_colCL3.getAbsRow(CC3).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += " \t\t\t\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table>\t\r\n"; html += " \t\t"; } } // Fin SI CL3 } // Fin SI L3 } if (m_bComputeL2.booleanValue()) { for (int RC2 = 0; RC2 < m_setL1.getAbsRow(RL1).getSetCL2().getNumRows(); RC2++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t\t\t\t"; if (m_computeL2.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiCL2\" width=\""; html += m_computeL2.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t\t\t\t"; } for (int CC2 = 0; CC2 < m_colCL2.getNumRows(); CC2++) { if (m_colCL2.getAbsRow(CC2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetCL2().getAbsRow(RC2) .getSTS(m_colCL2.getAbsRow(CC2).getColName()), m_colCL2.getAbsRow(CC2).getFormat(), m_colCL2.getAbsRow(CC2).getBindDataType(), request); html += "\r\n"; html += "\t\t <td class=\"fsiCL2\" width=\""; html += m_colCL2.getAbsRow(CC2).getAncho(); html += "%\" align=\""; html += m_colCL2.getAbsRow(CC2).getAlinHor(); html += '"'; html += ((m_colCL2.getAbsRow(CC2).getFGColor() != null) ? " style=\"color:#" + m_colCL2.getAbsRow(CC2).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += " \t\t\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table>\t\r\n"; html += " \t\t"; } } // Fin SI CL2 } // Fin SI L2 } if (m_bComputeL1.booleanValue()) { for (int RC1 = 0; RC1 < m_setCL1.getNumRows(); RC1++) { html += "\r\n"; html += "\t <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\r\n"; html += "\t \t<tr> \r\n"; html += "\t\t"; if (m_computeL1.getAbsRow(0).getTabPrintPnt() > 0) { html += " \r\n"; html += "\t\t <td class=\"fsiCL1\" width=\""; html += m_computeL1.getAbsRow(0).getTabPrintPnt(); html += "%\"> </td> \r\n"; html += "\t\t"; } for (int CC1 = 0; CC1 < m_colCL1.getNumRows(); CC1++) { if (m_colCL1.getAbsRow(CC1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setCL1.getAbsRow(RC1).getSTS(m_colCL1.getAbsRow(CC1).getColName()), m_colCL1.getAbsRow(CC1).getFormat(), m_colCL1.getAbsRow(CC1).getBindDataType(), request); html += "\r\n"; html += "\t\t <td class=\"fsiCL1\" width=\""; html += m_colCL1.getAbsRow(CC1).getAncho(); html += "%\" align=\""; html += m_colCL1.getAbsRow(CC1).getAlinHor(); html += '"'; html += ((m_colCL1.getAbsRow(CC1).getFGColor() != null) ? " style=\"color:#" + m_colCL1.getAbsRow(CC1).getFGColor() + ";\"" : ""); html += '>'; html += cabval; html += "</td>\r\n"; html += " \t\t"; } } html += "\r\n"; html += "\t\t</tr>\r\n"; html += "\t </table>\t\r\n"; html += " "; } } // Fin SI CL1 } // Fin SI L1 html += "\r\n"; html += "\t</td>\r\n"; html += " </tr>\r\n"; html += "</table>\r\n"; html += "</body>\r\n"; html += "</html>\r\n"; return html; } public String generarArchivoSQL(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String html = ""; JReportesSet RepSet = (JReportesSet) request.getAttribute("m_RepSet"); JReportesSentenciasSet RepSentSet = new JReportesSentenciasSet(request); RepSentSet.m_Where = "ID_Report = '" + RepSet.getAbsRow(0).getID_Report() + "'"; RepSentSet.Open(); JReportesSentenciasColumnasSet RepSentColSet = new JReportesSentenciasColumnasSet(request); RepSentColSet.m_Where = "ID_Report = '" + RepSet.getAbsRow(0).getID_Report() + "'"; RepSentColSet.Open(); JReportesFiltroSet RepFilSet = new JReportesFiltroSet(request); RepFilSet.m_Where = "ID_Report = '" + RepSet.getAbsRow(0).getID_Report() + "'"; RepFilSet.Open(); html += "INSERT INTO TBL_REPORTS\n"; html += "VALUES('" + RepSet.getAbsRow(0).getID_Report() + "','" + p(RepSet.getAbsRow(0).getDescription()) + "','" + p(RepSet.getAbsRow(0).getTipo()) + "','" + p(RepSet.getAbsRow(0).getTitulo()) + "','" + p(RepSet.getAbsRow(0).getEncL1()) + "','" + p(RepSet.getAbsRow(0).getEncL2()) + "','" + p(RepSet.getAbsRow(0).getEncL3()) + "','" + p(RepSet.getAbsRow(0).getL1()) + "','" + p(RepSet.getAbsRow(0).getL2()) + "','" + p(RepSet.getAbsRow(0).getL3()) + "','" + p(RepSet.getAbsRow(0).getCL1()) + "','" + p(RepSet.getAbsRow(0).getCL2()) + "','" + p(RepSet.getAbsRow(0).getCL3()) + "'," + RepSet.getAbsRow(0).getHW() + "," + RepSet.getAbsRow(0).getVW() + ",'" + p(RepSet.getAbsRow(0).getSubTipo()) + "','" + p(RepSet.getAbsRow(0).getClave()) + "','" + (RepSet.getAbsRow(0).getGraficar() ? "1" : "0") + "');\n\n"; for (int i = 0; i < RepSentSet.getNumRows(); i++) { html += "INSERT INTO TBL_REPORTS_SENTENCES\n"; html += "VALUES(" + RepSentSet.getAbsRow(i).getID_Report() + "," + RepSentSet.getAbsRow(i).getID_Sentence() + "," + RepSentSet.getAbsRow(i).getID_IsCompute() + ",'" + q(RepSentSet.getAbsRow(i).getSelect_Clause()) + "'," + RepSentSet.getAbsRow(i).getTabPrintPnt() + ",null );\n"; } html += "\n"; for (int i = 0; i < RepSentColSet.getNumRows(); i++) { html += "INSERT INTO TBL_REPORTS_SENTENCES_COLUMNS\n"; html += "VALUES(" + RepSentColSet.getAbsRow(i).getID_Report() + "," + RepSentColSet.getAbsRow(i).getID_Sentence() + "," + RepSentColSet.getAbsRow(i).getID_IsCompute() + "," + RepSentColSet.getAbsRow(i).getID_Column() + ",'" + q(RepSentColSet.getAbsRow(i).getColName()) + "','" + q(RepSentColSet.getAbsRow(i).getBindDataType()) + "','" + (RepSentColSet.getAbsRow(i).getWillShow() ? 1 : 0) + "','" + q(RepSentColSet.getAbsRow(i).getFormat()) + "'," + RepSentColSet.getAbsRow(i).getAncho() + ",'" + q(RepSentColSet.getAbsRow(i).getAlinHor()) + "','000000' );\n"; } html += "\n"; for (int i = 0; i < RepFilSet.getNumRows(); i++) { html += "INSERT INTO TBL_REPORTS_FILTER\n"; html += "VALUES(" + RepFilSet.getAbsRow(i).getID_Report() + "," + RepFilSet.getAbsRow(i).getID_Column() + ",'" + p(RepFilSet.getAbsRow(i).getInstructions()) + "','" + (RepFilSet.getAbsRow(i).getIsRange() ? 1 : 0) + "','" + q(RepFilSet.getAbsRow(i).getPriDataName()) + "','" + q(RepFilSet.getAbsRow(i).getPriDefault()) + "','" + q(RepFilSet.getAbsRow(i).getSecDataName()) + "','" + q(RepFilSet.getAbsRow(i).getSecDefault()) + "','" + q(RepFilSet.getAbsRow(i).getBindDataType()) + "','" + (RepFilSet.getAbsRow(i).getFromCatalog() ? 1 : 0) + "','" + q(RepFilSet.getAbsRow(i).getSelect_Clause()) + "' );\n"; } return html; } public String generarArchivoCSV(HttpServletRequest request, HttpServletResponse response, String sep) throws ServletException, IOException { String html = ""; JReportesSet m_RepSet = (JReportesSet) request.getAttribute("m_RepSet"); JReportesLevel1 m_setL1 = (JReportesLevel1) request.getAttribute("m_setL1"); JReportesCompL1Set m_setCL1 = (JReportesCompL1Set) request.getAttribute("m_setCL1"); Boolean m_bSelectL1 = (Boolean) request.getAttribute("m_bSelectL1"); Boolean m_bSelectL2 = (Boolean) request.getAttribute("m_bSelectL2"); Boolean m_bSelectL3 = (Boolean) request.getAttribute("m_bSelectL3"); Boolean m_bComputeL1 = (Boolean) request.getAttribute("m_bComputeL1"); Boolean m_bComputeL2 = (Boolean) request.getAttribute("m_bComputeL2"); Boolean m_bComputeL3 = (Boolean) request.getAttribute("m_bComputeL3"); JReportesBind3Set m_colL1 = (JReportesBind3Set) request.getAttribute("m_colL1"); JReportesBind3Set m_colL2 = (JReportesBind3Set) request.getAttribute("m_colL2"); JReportesBind3Set m_colL3 = (JReportesBind3Set) request.getAttribute("m_colL3"); JReportesBind3Set m_colCL1 = (JReportesBind3Set) request.getAttribute("m_colCL1"); JReportesBind3Set m_colCL2 = (JReportesBind3Set) request.getAttribute("m_colCL2"); JReportesBind3Set m_colCL3 = (JReportesBind3Set) request.getAttribute("m_colCL3"); String fsi_filtro = (String) request.getAttribute("fsi_filtro"); html += sep + m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro + sep + "\r\n"; if (m_bSelectL1.booleanValue()) { for (int i = 0; i < m_colL1.getNumRows(); i++) { if (m_colL1.getAbsRow(i).getWillShow()) html += sep + m_colL1.getAbsRow(i).getColName() + sep; } html += "\r\n"; } if (m_bSelectL2.booleanValue()) { for (int i = 0; i < m_colL2.getNumRows(); i++) { if (m_colL2.getAbsRow(i).getWillShow()) html += sep + m_colL2.getAbsRow(i).getColName() + sep; } html += "\r\n"; } if (m_bSelectL3.booleanValue()) { for (int i = 0; i < m_colL3.getNumRows(); i++) { if (m_colL3.getAbsRow(i).getWillShow()) html += sep + m_colL3.getAbsRow(i).getColName() + sep; } html += "\r\n"; } if (m_bSelectL1.booleanValue()) { for (int RL1 = 0; RL1 < m_setL1.getNumRows(); RL1++) { for (int CL1 = 0; CL1 < m_colL1.getNumRows(); CL1++) { if (m_colL1.getAbsRow(CL1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSTS(m_colL1.getAbsRow(CL1).getColName()), m_colL1.getAbsRow(CL1).getFormat(), m_colL1.getAbsRow(CL1).getBindDataType(), request); html += sep + cabval + sep; } } html += "\r\n"; // Nivel 2 if (m_bSelectL2.booleanValue()) { for (int RL2 = 0; RL2 < m_setL1.getAbsRow(RL1).getSetL2().getNumRows(); RL2++) { for (int CL2 = 0; CL2 < m_colL2.getNumRows(); CL2++) { if (m_colL2.getAbsRow(CL2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2) .getSTS(m_colL2.getAbsRow(CL2).getColName()), m_colL2.getAbsRow(CL2).getFormat(), m_colL2.getAbsRow(CL2).getBindDataType(), request); html += sep + cabval + sep; } } html += "\r\n"; // Nivel 3 if (m_bSelectL3.booleanValue()) { for (int RL3 = 0; RL3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getNumRows(); RL3++) { for (int CL3 = 0; CL3 < m_colL3.getNumRows(); CL3++) { if (m_colL3.getAbsRow(CL3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getAbsRow(RL3).getSTS(m_colL3.getAbsRow(CL3).getColName()), m_colL3.getAbsRow(CL3).getFormat(), m_colL3.getAbsRow(CL3).getBindDataType(), request); html += sep + cabval + sep; } } html += "\r\n"; } if (m_bComputeL3.booleanValue()) { for (int RC3 = 0; RC3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getNumRows(); RC3++) { for (int CC3 = 0; CC3 < m_colCL3.getNumRows(); CC3++) { if (m_colCL3.getAbsRow(CC3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getAbsRow(RC3) .getSTS(m_colCL3.getAbsRow(CC3).getColName()), m_colCL3.getAbsRow(CC3).getFormat(), m_colCL3.getAbsRow(CC3).getBindDataType(), request); html += sep + cabval + sep; } } html += "\r\n"; } } // Fin SI CL3 } // Fin SI L3 } if (m_bComputeL2.booleanValue()) { for (int RC2 = 0; RC2 < m_setL1.getAbsRow(RL1).getSetCL2().getNumRows(); RC2++) { for (int CC2 = 0; CC2 < m_colCL2.getNumRows(); CC2++) { if (m_colCL2.getAbsRow(CC2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetCL2().getAbsRow(RC2) .getSTS(m_colCL2.getAbsRow(CC2).getColName()), m_colCL2.getAbsRow(CC2).getFormat(), m_colCL2.getAbsRow(CC2).getBindDataType(), request); html += sep + cabval + sep; } } html += "\r\n"; } } // Fin SI CL2 } // Fin SI L2 } if (m_bComputeL1.booleanValue()) { for (int RC1 = 0; RC1 < m_setCL1.getNumRows(); RC1++) { for (int CC1 = 0; CC1 < m_colCL1.getNumRows(); CC1++) { if (m_colCL1.getAbsRow(CC1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setCL1.getAbsRow(RC1).getSTS(m_colCL1.getAbsRow(CC1).getColName()), m_colCL1.getAbsRow(CC1).getFormat(), m_colCL1.getAbsRow(CC1).getBindDataType(), request); html += cabval; } } html += "\r\n"; } } // Fin SI CL1 } // Fin SI L1 return html; } public String generarArchivoDOM(HttpServletRequest request, HttpServletResponse response, Document document) throws ServletException, IOException { JReportesSet m_RepSet = (JReportesSet) request.getAttribute("m_RepSet"); JReportesLevel1 m_setL1 = (JReportesLevel1) request.getAttribute("m_setL1"); JReportesCompL1Set m_setCL1 = (JReportesCompL1Set) request.getAttribute("m_setCL1"); Boolean m_bSelectL1 = (Boolean) request.getAttribute("m_bSelectL1"); Boolean m_bSelectL2 = (Boolean) request.getAttribute("m_bSelectL2"); Boolean m_bSelectL3 = (Boolean) request.getAttribute("m_bSelectL3"); Boolean m_bComputeL1 = (Boolean) request.getAttribute("m_bComputeL1"); Boolean m_bComputeL2 = (Boolean) request.getAttribute("m_bComputeL2"); Boolean m_bComputeL3 = (Boolean) request.getAttribute("m_bComputeL3"); JReportesBind3Set m_colL1 = (JReportesBind3Set) request.getAttribute("m_colL1"); JReportesBind3Set m_colL2 = (JReportesBind3Set) request.getAttribute("m_colL2"); JReportesBind3Set m_colL3 = (JReportesBind3Set) request.getAttribute("m_colL3"); JReportesBind3Set m_colCL1 = (JReportesBind3Set) request.getAttribute("m_colCL1"); JReportesBind3Set m_colCL2 = (JReportesBind3Set) request.getAttribute("m_colCL2"); JReportesBind3Set m_colCL3 = (JReportesBind3Set) request.getAttribute("m_colCL3"); String fsi_filtro = (String) request.getAttribute("fsi_filtro"); Element reporte = new Element("reporte"); document.setRootElement(reporte); reporte.setAttribute(new Attribute("id", Integer.toString(m_RepSet.getAbsRow(0).getID_Report()))); reporte.setAttribute( new Attribute("descripcion", m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro)); if (m_bSelectL1.booleanValue()) { Element sentencia = new Element("sentencia"); sentencia.setAttribute(new Attribute("nivel", "1")); reporte.addContent(sentencia); for (int RL1 = 0; RL1 < m_setL1.getNumRows(); RL1++) { Element rl1 = new Element("linea"); sentencia.addContent(rl1); for (int CL1 = 0; CL1 < m_colL1.getNumRows(); CL1++) { if (m_colL1.getAbsRow(CL1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSTS(m_colL1.getAbsRow(CL1).getColName()), m_colL1.getAbsRow(CL1).getFormat(), m_colL1.getAbsRow(CL1).getBindDataType(), request); rl1.addContent(new Element(m_colL1.getAbsRow(CL1).getColName()).setText(cabval)); } } // Nivel 2 if (m_bSelectL2.booleanValue()) { Element sentencia2 = new Element("sentencia"); sentencia2.setAttribute(new Attribute("nivel", "2")); sentencia.addContent(sentencia2); for (int RL2 = 0; RL2 < m_setL1.getAbsRow(RL1).getSetL2().getNumRows(); RL2++) { Element rl2 = new Element("linea"); sentencia2.addContent(rl2); for (int CL2 = 0; CL2 < m_colL2.getNumRows(); CL2++) { if (m_colL2.getAbsRow(CL2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2) .getSTS(m_colL2.getAbsRow(CL2).getColName()), m_colL2.getAbsRow(CL2).getFormat(), m_colL2.getAbsRow(CL2).getBindDataType(), request); rl2.addContent(new Element(m_colL2.getAbsRow(CL2).getColName()).setText(cabval)); } } // Nivel 3 if (m_bSelectL3.booleanValue()) { Element sentencia3 = new Element("sentencia"); sentencia3.setAttribute(new Attribute("nivel", "3")); sentencia2.addContent(sentencia3); for (int RL3 = 0; RL3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getNumRows(); RL3++) { Element rl3 = new Element("linea"); sentencia3.addContent(rl3); for (int CL3 = 0; CL3 < m_colL3.getNumRows(); CL3++) { if (m_colL3.getAbsRow(CL3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getAbsRow(RL3).getSTS(m_colL3.getAbsRow(CL3).getColName()), m_colL3.getAbsRow(CL3).getFormat(), m_colL3.getAbsRow(CL3).getBindDataType(), request); rl3.addContent( new Element(m_colL3.getAbsRow(CL3).getColName()).setText(cabval)); } } } if (m_bComputeL3.booleanValue()) { Element agregado3 = new Element("agregado"); agregado3.setAttribute(new Attribute("nivel", "3")); sentencia2.addContent(agregado3); for (int RC3 = 0; RC3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getNumRows(); RC3++) { Element rc3 = new Element("linea"); agregado3.addContent(rc3); for (int CC3 = 0; CC3 < m_colCL3.getNumRows(); CC3++) { if (m_colCL3.getAbsRow(CC3).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getAbsRow(RC3) .getSTS(m_colCL3.getAbsRow(CC3).getColName()), m_colCL3.getAbsRow(CC3).getFormat(), m_colCL3.getAbsRow(CC3).getBindDataType(), request); rc3.addContent(new Element(m_colCL3.getAbsRow(CC3).getColName()) .setText(cabval)); } } } } // Fin SI CL3 } // Fin SI L3 } if (m_bComputeL2.booleanValue()) { Element agregado2 = new Element("agregado"); agregado2.setAttribute(new Attribute("nivel", "2")); sentencia.addContent(agregado2); for (int RC2 = 0; RC2 < m_setL1.getAbsRow(RL1).getSetCL2().getNumRows(); RC2++) { Element rc2 = new Element("linea"); agregado2.addContent(rc2); for (int CC2 = 0; CC2 < m_colCL2.getNumRows(); CC2++) { if (m_colCL2.getAbsRow(CC2).getWillShow()) { String cabval = JUtil.FormatearRep( m_setL1.getAbsRow(RL1).getSetCL2().getAbsRow(RC2) .getSTS(m_colCL2.getAbsRow(CC2).getColName()), m_colCL2.getAbsRow(CC2).getFormat(), m_colCL2.getAbsRow(CC2).getBindDataType(), request); rc2.addContent( new Element(m_colCL2.getAbsRow(CC2).getColName()).setText(cabval)); } } } } // Fin SI CL2 } // Fin SI L2 } if (m_bComputeL1.booleanValue()) { Element agregado = new Element("agregado"); agregado.setAttribute(new Attribute("nivel", "1")); reporte.addContent(agregado); for (int RC1 = 0; RC1 < m_setCL1.getNumRows(); RC1++) { Element rc1 = new Element("linea"); agregado.addContent(rc1); for (int CC1 = 0; CC1 < m_colCL1.getNumRows(); CC1++) { if (m_colCL1.getAbsRow(CC1).getWillShow()) { String cabval = JUtil.FormatearRep( m_setCL1.getAbsRow(RC1).getSTS(m_colCL1.getAbsRow(CC1).getColName()), m_colCL1.getAbsRow(CC1).getFormat(), m_colCL1.getAbsRow(CC1).getBindDataType(), request); rc1.addContent(new Element(m_colCL1.getAbsRow(CC1).getColName()).setText(cabval)); } } } } // Fin SI CL1 } // Fin SI L1 Format format = Format.getPrettyFormat(); format.setEncoding("utf-8"); format.setTextMode(TextMode.NORMALIZE); XMLOutputter xmlOutputer = new XMLOutputter(format); return xmlOutputer.outputString(document); } public void generarArchivoXLS(HttpServletRequest request, HttpServletResponse response, Workbook wb) throws ServletException, IOException { JReportesSet m_RepSet = (JReportesSet) request.getAttribute("m_RepSet"); JReportesLevel1 m_setL1 = (JReportesLevel1) request.getAttribute("m_setL1"); JReportesCompL1Set m_setCL1 = (JReportesCompL1Set) request.getAttribute("m_setCL1"); Boolean m_bSelectL1 = (Boolean) request.getAttribute("m_bSelectL1"); Boolean m_bSelectL2 = (Boolean) request.getAttribute("m_bSelectL2"); Boolean m_bSelectL3 = (Boolean) request.getAttribute("m_bSelectL3"); Boolean m_bComputeL1 = (Boolean) request.getAttribute("m_bComputeL1"); Boolean m_bComputeL2 = (Boolean) request.getAttribute("m_bComputeL2"); Boolean m_bComputeL3 = (Boolean) request.getAttribute("m_bComputeL3"); JReportesBind3Set m_colL1 = (JReportesBind3Set) request.getAttribute("m_colL1"); JReportesBind3Set m_colL2 = (JReportesBind3Set) request.getAttribute("m_colL2"); JReportesBind3Set m_colL3 = (JReportesBind3Set) request.getAttribute("m_colL3"); JReportesBind3Set m_colCL1 = (JReportesBind3Set) request.getAttribute("m_colCL1"); JReportesBind3Set m_colCL2 = (JReportesBind3Set) request.getAttribute("m_colCL2"); JReportesBind3Set m_colCL3 = (JReportesBind3Set) request.getAttribute("m_colCL3"); String fsi_filtro = (String) request.getAttribute("fsi_filtro"); Sheet sheet = wb.createSheet("reporte " + Integer.toString(m_RepSet.getAbsRow(0).getID_Report())); short nrow = 0; Row row = sheet.createRow(nrow++); Font font = wb.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(HSSFColor.DARK_BLUE.index); Cell cell = row.createCell(0); cell.setCellValue(m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(CellStyle.ALIGN_CENTER); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); cellStyle.setFont(font); cell.setCellStyle(cellStyle); JRepCellStyles cellStyles = new JRepCellStyles(wb); /* Font fenc = wb.createFont(); fenc.setBoldweight(Font.BOLDWEIGHT_BOLD); fenc.setColor(HSSFColor.WHITE.index); Font fnorm = wb.createFont(); fnorm.setColor(HSSFColor.BLACK.index); /////////////////////////////////////////////////////////////////////////////////////////////////////// CellStyle cellStyle = wb.createCellStyle(); cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER); cellStyle.setFont(font); if(alin != null) { if(alin.equals("center")) cellStyle.setAlignment(CellStyle.ALIGN_CENTER); else if(alin.equals("right")) cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); else cellStyle.setAlignment(CellStyle.ALIGN_LEFT); } if(tipocel != null) { if(tipocel.equals("encabezado")) { cellStyle.setBorderTop(CellStyle.BORDER_THIN); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cellStyle.setFillPattern(CellStyle.BIG_SPOTS); } else if(tipocel.equals("agregado")) { cellStyle.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cellStyle.setFillPattern(CellStyle.BIG_SPOTS); } } /////////////////////////////////////////////////////////////////////////////////////////////////////// */ if (m_bSelectL1.booleanValue()) { Row rowl = sheet.createRow(nrow++); for (int i = 0; i < m_colL1.getNumRows(); i++) { if (m_colL1.getAbsRow(i).getWillShow()) { JUtil.DatoXLS(cellStyles, rowl, i, m_colL1.getAbsRow(i).getColName().toUpperCase(), "general", "STRING", m_colL1.getAbsRow(i).getAlinHor(), "encabezado", "fenc", request); //celll1.getCellStyle().setBorderTop(CellStyle.BORDER_THIN); //celll1.getCellStyle().setBorderBottom(CellStyle.BORDER_THIN); } } } if (m_bSelectL2.booleanValue()) { Row rowl = sheet.createRow(nrow++); for (int i = 0; i < m_colL2.getNumRows(); i++) { if (m_colL2.getAbsRow(i).getWillShow()) { JUtil.DatoXLS(cellStyles, rowl, i, m_colL2.getAbsRow(i).getColName().toUpperCase(), "general", "STRING", m_colL2.getAbsRow(i).getAlinHor(), "encabezado", "fenc", request); //celll2.getCellStyle().setBorderTop(CellStyle.BORDER_THIN); //celll2.getCellStyle().setBorderBottom(CellStyle.BORDER_THIN); } } } if (m_bSelectL3.booleanValue()) { Row rowl = sheet.createRow(nrow++); for (int i = 0; i < m_colL3.getNumRows(); i++) { if (m_colL3.getAbsRow(i).getWillShow()) { JUtil.DatoXLS(cellStyles, rowl, i, m_colL3.getAbsRow(i).getColName().toUpperCase(), "general", "STRING", m_colL3.getAbsRow(i).getAlinHor(), "encabezado", "fenc", request); //celll3.getCellStyle().setBorderTop(CellStyle.BORDER_THIN); //celll3.getCellStyle().setBorderBottom(CellStyle.BORDER_THIN); } } } if (m_bSelectL1.booleanValue()) { for (int RL1 = 0; RL1 < m_setL1.getNumRows(); RL1++) { Row rowl1 = sheet.createRow(nrow++); for (int CL1 = 0; CL1 < m_colL1.getNumRows(); CL1++) { if (m_colL1.getAbsRow(CL1).getWillShow()) JUtil.DatoXLS(cellStyles, rowl1, CL1, m_setL1.getAbsRow(RL1).getSTS(m_colL1.getAbsRow(CL1).getColName()), m_colL1.getAbsRow(CL1).getFormat(), m_colL1.getAbsRow(CL1).getBindDataType(), m_colL1.getAbsRow(CL1).getAlinHor(), null, "fnorm", request); } // Nivel 2 if (m_bSelectL2.booleanValue()) { for (int RL2 = 0; RL2 < m_setL1.getAbsRow(RL1).getSetL2().getNumRows(); RL2++) { Row rowl2 = sheet.createRow(nrow++); for (int CL2 = 0; CL2 < m_colL2.getNumRows(); CL2++) { if (m_colL2.getAbsRow(CL2).getWillShow()) JUtil.DatoXLS(cellStyles, rowl2, CL2, m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2) .getSTS(m_colL2.getAbsRow(CL2).getColName()), m_colL2.getAbsRow(CL2).getFormat(), m_colL2.getAbsRow(CL2).getBindDataType(), m_colL2.getAbsRow(CL2).getAlinHor(), null, "fnorm", request); } // Nivel 3 if (m_bSelectL3.booleanValue()) { for (int RL3 = 0; RL3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getNumRows(); RL3++) { Row rowl3 = sheet.createRow(nrow++); for (int CL3 = 0; CL3 < m_colL3.getNumRows(); CL3++) { if (m_colL3.getAbsRow(CL3).getWillShow()) JUtil.DatoXLS(cellStyles, rowl3, CL3, m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetL3() .getAbsRow(RL3).getSTS(m_colL3.getAbsRow(CL3).getColName()), m_colL3.getAbsRow(CL3).getFormat(), m_colL3.getAbsRow(CL3).getBindDataType(), m_colL3.getAbsRow(CL3).getAlinHor(), null, "fnorm", request); } } if (m_bComputeL3.booleanValue()) { for (int RC3 = 0; RC3 < m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getNumRows(); RC3++) { Row rowc3 = sheet.createRow(nrow++); for (int CC3 = 0; CC3 < m_colCL3.getNumRows(); CC3++) { if (m_colCL3.getAbsRow(CC3).getWillShow()) JUtil.DatoXLS(cellStyles, rowc3, CC3, m_setL1.getAbsRow(RL1).getSetL2().getAbsRow(RL2).getSetCL3() .getAbsRow(RC3) .getSTS(m_colCL3.getAbsRow(CC3).getColName()), m_colCL3.getAbsRow(CC3).getFormat(), m_colCL3.getAbsRow(CC3).getBindDataType(), m_colCL3.getAbsRow(CC3).getAlinHor(), "agregado", "fenc", request); } } } // Fin SI CL3 } // Fin SI L3 } if (m_bComputeL2.booleanValue()) { for (int RC2 = 0; RC2 < m_setL1.getAbsRow(RL1).getSetCL2().getNumRows(); RC2++) { Row rowc2 = sheet.createRow(nrow++); for (int CC2 = 0; CC2 < m_colCL2.getNumRows(); CC2++) { if (m_colCL2.getAbsRow(CC2).getWillShow()) JUtil.DatoXLS(cellStyles, rowc2, CC2, m_setL1.getAbsRow(RL1).getSetCL2().getAbsRow(RC2) .getSTS(m_colCL2.getAbsRow(CC2).getColName()), m_colCL2.getAbsRow(CC2).getFormat(), m_colCL2.getAbsRow(CC2).getBindDataType(), m_colCL2.getAbsRow(CC2).getAlinHor(), "agregado", "fenc", request); } } } // Fin SI CL2 } // Fin SI L2 } if (m_bComputeL1.booleanValue()) { for (int RC1 = 0; RC1 < m_setCL1.getNumRows(); RC1++) { Row rowc1 = sheet.createRow(nrow++); for (int CC1 = 0; CC1 < m_colCL1.getNumRows(); CC1++) { if (m_colCL1.getAbsRow(CC1).getWillShow()) JUtil.DatoXLS(cellStyles, rowc1, CC1, m_setCL1.getAbsRow(RC1).getSTS(m_colCL1.getAbsRow(CC1).getColName()), m_colCL1.getAbsRow(CC1).getFormat(), m_colCL1.getAbsRow(CC1).getBindDataType(), m_colCL1.getAbsRow(CC1).getAlinHor(), "agregado", "fenc", request); } } } // Fin SI CL1 } // Fin SI L1 int colsmer; if (m_colL1.getNumRows() > m_colL2.getNumRows() && m_colL1.getNumRows() > m_colL3.getNumRows()) colsmer = m_colL1.getNumRows() - 1; else if (m_colL2.getNumRows() > m_colL1.getNumRows() && m_colL2.getNumRows() > m_colL3.getNumRows()) colsmer = m_colL2.getNumRows() - 1; else colsmer = m_colL3.getNumRows() - 1; sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (colsmer == -1 ? 0 : colsmer))); } @SuppressWarnings({ "unused" }) public void CargarReporte(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DocumentException { super.doPost(request, response); int m_ID_Report = Integer.parseInt(request.getParameter("REPID")); int m_LinesNum = 0; Boolean m_bFilterL1 = new Boolean(true); Boolean m_bSelectL1 = new Boolean(true); Boolean m_bSelectL2 = new Boolean(true); Boolean m_bSelectL3 = new Boolean(true); Boolean m_bComputeL1 = new Boolean(true); Boolean m_bComputeL2 = new Boolean(true); Boolean m_bComputeL3 = new Boolean(true); // Construye las estructuras JReportesSet m_RepSet = new JReportesSet(request); m_RepSet.m_Where = "ID_Report = " + m_ID_Report; m_RepSet.Open(); boolean m_Graficar = m_RepSet.getAbsRow(0).getGraficar(); // empieza por el select de primer nivel JReportesBind2Set m_selectL1 = new JReportesBind2Set(request); m_selectL1.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '1' and ID_IsCompute = '0'"; m_selectL1.m_OrderBy = "ID_Sentence ASC"; m_selectL1.Open(); if (m_selectL1.getNumRows() < 1) m_bSelectL1 = Boolean.FALSE; JReportesBind3Set m_colL1 = new JReportesBind3Set(request); m_colL1.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '1' and ID_IsCompute = '0'"; m_colL1.m_OrderBy = "ID_Column asc"; m_colL1.Open(); // sigue por el select de segundo nivel JReportesBind2Set m_selectL2 = new JReportesBind2Set(request); m_selectL2.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '2' and ID_IsCompute = '0'"; m_selectL2.m_OrderBy = "ID_Sentence ASC"; m_selectL2.Open(); if (m_selectL2.getNumRows() < 1) m_bSelectL2 = Boolean.FALSE; JReportesBind3Set m_colL2 = new JReportesBind3Set(request); m_colL2.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '2' and ID_IsCompute = '0'"; m_colL2.m_OrderBy = "ID_Column asc"; m_colL2.Open(); // sigue por el select de tercer nivel JReportesBind2Set m_selectL3 = new JReportesBind2Set(request); m_selectL3.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '3' and ID_IsCompute = '0'"; m_selectL3.m_OrderBy = "ID_Sentence ASC"; m_selectL3.Open(); if (m_selectL3.getNumRows() < 1) m_bSelectL3 = Boolean.FALSE; JReportesBind3Set m_colL3 = new JReportesBind3Set(request); m_colL3.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '3' and ID_IsCompute = '0'"; m_colL3.m_OrderBy = "ID_Column asc"; m_colL3.Open(); // Ahora revisa las sentencias compute // empieza por el compute de primer nivel JReportesBind2Set m_computeL1 = new JReportesBind2Set(request); m_computeL1.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '1' and ID_IsCompute = '1'"; m_computeL1.m_OrderBy = "ID_Sentence ASC"; m_computeL1.Open(); if (m_computeL1.getNumRows() < 1) m_bComputeL1 = Boolean.FALSE; JReportesBind3Set m_colCL1 = new JReportesBind3Set(request); m_colCL1.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '1' and ID_IsCompute = '1'"; m_colCL1.m_OrderBy = "ID_Column asc"; m_colCL1.Open(); // sigue por el compute de segundo nivel JReportesBind2Set m_computeL2 = new JReportesBind2Set(request); m_computeL2.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '2' and ID_IsCompute = '1'"; m_computeL2.m_OrderBy = "ID_Sentence ASC"; m_computeL2.Open(); if (m_computeL2.getNumRows() < 1) m_bComputeL2 = Boolean.FALSE; JReportesBind3Set m_colCL2 = new JReportesBind3Set(request); m_colCL2.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '2' and ID_IsCompute = '1'"; m_colCL2.m_OrderBy = "ID_Column asc"; m_colCL2.Open(); // sigue por el compute de tercer nivel JReportesBind2Set m_computeL3 = new JReportesBind2Set(request); m_computeL3.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '3' and ID_IsCompute = '1'"; m_computeL3.m_OrderBy = "ID_Sentence ASC"; m_computeL3.Open(); if (m_computeL3.getNumRows() < 1) m_bComputeL3 = Boolean.FALSE; JReportesBind3Set m_colCL3 = new JReportesBind3Set(request); m_colCL3.m_Where = "ID_Report = '" + m_ID_Report + "' and ID_Sentence = '3' and ID_IsCompute = '1'"; m_colCL3.m_OrderBy = "ID_Column asc"; m_colCL3.Open(); //System.out.println("CARGADAS LAS SENTENCIAS"); // Ahora carga los datos JReportesLevel1 m_setL1 = new JReportesLevel1(request); // Carga la sentencia del compute; JReportesCompL1Set m_setCL1 = new JReportesCompL1Set(request); if (m_bSelectL1.booleanValue()) { if (m_bFilterL1.booleanValue()) { // si existe un filtro especial lo cargar String sqll1 = VerifyFilerClause(new StringBuffer(m_selectL1.getRow(0).getSelect_Clause()), request); //System.out.println(sqll1); m_setL1.setSQL(sqll1); } else { //out.println(m_selectL1.getRow(0).getSelect_Clause()); m_setL1.setSQL(m_selectL1.getRow(0).getSelect_Clause()); } m_setL1.Open(); m_LinesNum += m_setL1.getNumRows(); if (m_bComputeL1.booleanValue()) { if (m_bFilterL1.booleanValue()) // si existe un filtro especial lo cargar m_setCL1.setSQL( VerifyFilerClause(new StringBuffer(m_computeL1.getRow(0).getSelect_Clause()), request)); else m_setCL1.setSQL(m_computeL1.getRow(0).getSelect_Clause()); //System.out.println(m_setCL1.getSQL()); m_setCL1.Open(); m_LinesNum += m_setCL1.getNumRows(); } if (m_bSelectL2.booleanValue()) { for (int contL1 = 0; contL1 < m_setL1.getNumRows(); contL1++) { REP_LEVEL1 pNodeL1 = (REP_LEVEL1) m_setL1.getAbsRow(contL1); pNodeL1.getSetL2().setSQL(VerifyWhereClause( new StringBuffer(m_selectL2.getAbsRow(0).getSelect_Clause()), pNodeL1)); //System.out.println(pNodeL1.getSetL2().getSQL()); pNodeL1.getSetL2().Open(); m_LinesNum += pNodeL1.getSetL2().getNumRows(); if (m_bComputeL2.booleanValue()) { pNodeL1.getSetCL2().setSQL(VerifyWhereClause( new StringBuffer(m_computeL2.getRow(0).getSelect_Clause()), pNodeL1)); //System.out.println(pNodeL1.getSetCL2().getSQL()); pNodeL1.getSetCL2().Open(); m_LinesNum += pNodeL1.getSetCL2().getNumRows(); } if (m_bSelectL3.booleanValue()) { for (int contL2 = 0; contL2 < pNodeL1.getSetL2().getNumRows(); contL2++) { REP_LEVEL2 pNodeL2 = pNodeL1.getSetL2().getAbsRow(contL2); pNodeL2.getSetL3().setSQL(VerifyWhereClause( new StringBuffer(m_selectL3.getAbsRow(0).getSelect_Clause()), pNodeL2)); //System.out.println(pNodeL2.getSetL3().getSQL()); pNodeL2.getSetL3().Open(); m_LinesNum += pNodeL2.getSetL3().getNumRows(); if (m_bComputeL3.booleanValue()) { pNodeL2.getSetCL3().setSQL(VerifyWhereClause( new StringBuffer(m_computeL3.getAbsRow(0).getSelect_Clause()), pNodeL2)); //System.out.println(pNodeL2.getSetCL3().getSQL()); pNodeL2.getSetCL3().Open(); m_LinesNum += pNodeL2.getSetCL3().getNumRows(); } } } } } } //Verifica a donde irse boolean graficar = false; if (m_Graficar) // es grfica graficar = (request.getParameter("fsi_sino").equals("1") ? true : false); if (graficar) // es grfica { String GRAF = request.getParameter("fsi_graf"); boolean enCols = (request.getParameter("fsi_encols").equals("1") ? true : false); boolean linejes = (request.getParameter("fsi_linejes").equals("1") ? true : false); byte tipo = Byte.parseByte(request.getParameter("fsi_tipo")); String fsi_filtro = (String) request.getAttribute("fsi_filtro"); String formato = request.getParameter("formato"); JFsiGraficas graf; if (GRAF.equals("BAR")) graf = new JFsiGrafBarras(m_colL1, m_setL1, m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro, enCols, linejes, tipo, m_RepSet.getAbsRow(0).getHW(), m_RepSet.getAbsRow(0).getVW()); else if (GRAF.equals("LIN")) graf = new JFsiGrafLineas(m_colL1, m_setL1, m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro, enCols, linejes, tipo, m_RepSet.getAbsRow(0).getHW(), m_RepSet.getAbsRow(0).getVW()); else if (GRAF.equals("CIRC")) graf = new JFsiGrafCirc(m_colL1, m_setL1, m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro, enCols, tipo, m_RepSet.getAbsRow(0).getHW(), m_RepSet.getAbsRow(0).getVW()); else graf = new JFsiGrafAreas(m_colL1, m_setL1, m_RepSet.getAbsRow(0).getDescription() + " " + fsi_filtro, enCols, linejes, tipo, m_RepSet.getAbsRow(0).getHW(), m_RepSet.getAbsRow(0).getVW()); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(graf.getBufferedImage(), formato, baos); byte[] imageInByte = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(imageInByte); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, ("image/" + formato), imageInByte.length, ("grafica." + formato)); } catch (IOException ioe) { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.print("Error en el grfico: " + ioe); out.flush(); ioe.printStackTrace(out); } } else { String rep_permitido = "true"; request.setAttribute("rep_permitido", rep_permitido); // Ahora pone los atributos para el jsp request.setAttribute("m_RepSet", m_RepSet); request.setAttribute("m_setL1", m_setL1); request.setAttribute("m_setCL1", m_setCL1); request.setAttribute("m_bSelectL1", m_bSelectL1); request.setAttribute("m_bSelectL2", m_bSelectL2); request.setAttribute("m_bSelectL3", m_bSelectL3); request.setAttribute("m_bComputeL1", m_bComputeL1); request.setAttribute("m_bComputeL2", m_bComputeL2); request.setAttribute("m_bComputeL3", m_bComputeL3); request.setAttribute("m_selectL1", m_selectL1); request.setAttribute("m_selectL2", m_selectL2); request.setAttribute("m_selectL3", m_selectL3); request.setAttribute("m_computeL1", m_computeL1); request.setAttribute("m_computeL2", m_computeL2); request.setAttribute("m_computeL3", m_computeL3); request.setAttribute("m_colL1", m_colL1); request.setAttribute("m_colL2", m_colL2); request.setAttribute("m_colL3", m_colL3); request.setAttribute("m_colCL1", m_colCL1); request.setAttribute("m_colCL2", m_colCL2); request.setAttribute("m_colCL3", m_colCL3); if (request.getParameter("exportacion").equals("html")) { //Para archivos muy pequeos //response.setContentType("text/html"); //PrintWriter out = response.getWriter(); //out.print(generarReporteHtml(request, response)); byte[] byteArray = generarReporteHtml(request, response, true).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "text/html", byteArray.length, "reporte.html"); } else if (request.getParameter("exportacion").equals("odt")) { //response.setContentType("application/vnd.oasis.opendocument.text"); //PrintWriter out = response.getWriter(); //out.print(generarReporteHtml(request, response)); byte[] byteArray = generarReporteHtml(request, response, false).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/vnd.oasis.opendocument.text", byteArray.length, "reporte.odt"); } else if (request.getParameter("exportacion").equals("doc")) { //response.setContentType("application/msword"); //PrintWriter out = response.getWriter(); //out.print(generarReporteHtml(request, response)); byte[] byteArray = generarReporteHtml(request, response, false).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/msword", byteArray.length, "reporte.doc"); } else if (request.getParameter("exportacion").equals("rtf")) { //response.setContentType("application/rtf"); //PrintWriter out = response.getWriter(); //out.print(generarReporteHtml(request, response)); byte[] byteArray = generarReporteHtml(request, response, false).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/rtf", byteArray.length, "reporte.rtf"); } else if (request.getParameter("exportacion").equals("xls")) { //response.setContentType("application/vnd.ms-excel"); //OutputStream Out = response.getOutputStream(); //Workbook wb = new HSSFWorkbook(); //generarArchivoXLS(request, response, wb); //wb.write(Out); //Out.close(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Workbook wb = new HSSFWorkbook(); generarArchivoXLS(request, response, wb); wb.write(baos); byte[] byteArray = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/vnd.ms-excel", byteArray.length, "reporte.xls"); } else if (request.getParameter("exportacion").equals("ods")) { //response.setContentType("application/vnd.oasis.opendocument.spreadsheet"); //OutputStream Out = response.getOutputStream(); //Workbook wb = new HSSFWorkbook(); //generarArchivoXLS(request, response, wb); //wb.write(Out); //Out.close(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Workbook wb = new HSSFWorkbook(); generarArchivoXLS(request, response, wb); wb.write(baos); byte[] byteArray = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/vnd.oasis.opendocument.spreadsheet", byteArray.length, "reporte.ods"); } else if (request.getParameter("exportacion").equals("csv")) { //response.setContentType("text/plain"); //PrintWriter out = response.getWriter(); //out.print(generarArchivoCSV(request, response, "|")); byte[] byteArray = generarArchivoCSV(request, response, "|").getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "text/plain", byteArray.length, "reporte.csv"); } else if (request.getParameter("exportacion").equals("xml")) { Document document = new Document(); //response.setContentType("application/xml"); //PrintWriter out = response.getWriter(); //out.print(generarArchivoDOM(request, response, document)); byte[] byteArray = generarArchivoDOM(request, response, document).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "text/xml", byteArray.length, "reporte.xml"); } else if (request.getParameter("exportacion").equals("pdf")) { //response.setContentType("application/pdf"); //OutputStream Out = response.getOutputStream(); //ITextRenderer renderer = new ITextRenderer(); //renderer.setDocumentFromString(generarReporteHtml(request, response)); //renderer.layout(); //renderer.createPDF(Out); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(generarReporteHtml(request, response, true)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); renderer.layout(); renderer.createPDF(baos); byte[] byteArray = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "application/pdf", byteArray.length, "reporte.pdf"); } else if (request.getParameter("exportacion").equals("sql")) { //response.setContentType("text/plain"); //PrintWriter out = response.getWriter(); //out.print(generarArchivoSQL(request, response)); byte[] byteArray = generarArchivoSQL(request, response).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "text/plain", byteArray.length, "reporte.sql"); } else //xhtml { //response.setContentType("text/plain"); //PrintWriter out = response.getWriter(); //out.print(generarReporteHtml(request, response)); byte[] byteArray = generarReporteHtml(request, response, true).getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); JBajarArchivo fd = new JBajarArchivo(); fd.doDownload(response, getServletConfig().getServletContext(), bais, "text/plain", byteArray.length, "reporte.txt"); } //irApag("/forsetiweb/reportes/rep_reportes_imp.jsp", request, response); } } private boolean VerificarFiltro(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { short idmensaje = -1; String mensaje = "", Descripcion = ""; JReportesBindFSet setF = new JReportesBindFSet(request); setF.m_Where = "ID_Report = '" + p(request.getParameter("REPID")) + "'"; setF.m_OrderBy = "ID_Column ASC"; setF.Open(); for (int i = 0; i < setF.getNumRows(); i++) { String atr = request.getParameter(setF.getAbsRow(i).getPriDataName()); String atr2 = request.getParameter(setF.getAbsRow(i).getSecDataName()); Descripcion += setF.getAbsRow(i).getPriDataName() + ": "; if (!setF.getAbsRow(i).getFromCatalog()) // No es de catalogo { if (setF.getAbsRow(i).getBindDataType().equals("INT") || setF.getAbsRow(i).getBindDataType().equals("BYTE")) { if (setF.getAbsRow(i).getPriDefault().equals("{mes}")) { int mes = Integer.parseInt(atr); Descripcion += JUtil.convertirMesLargo(mes); } else if (setF.getAbsRow(i).getPriDefault().length() > 0 && setF.getAbsRow(i).getPriDefault().substring(0, 1).equals("[")) { Descripcion += JUtil.obtValorDeFiltro(setF.getAbsRow(i).getPriDefault(), atr); } else { Descripcion += atr; } if (setF.getAbsRow(i).getIsRange()) { if (setF.getAbsRow(i).getSecDefault().equals("{mes}")) { int mes2 = Integer.parseInt(atr2); Descripcion += " a " + JUtil.convertirMesLargo(mes2); } else if (setF.getAbsRow(i).getSecDefault().length() > 0 && setF.getAbsRow(i).getSecDefault().substring(0, 1).equals("[")) { Descripcion += " a " + JUtil.obtValorDeFiltro(setF.getAbsRow(i).getSecDefault(), atr2); } else { Descripcion += " a " + atr2; } } } else if (setF.getAbsRow(i).getBindDataType().equals("BOOL")) { Descripcion += atr.equals("1") ? "SI" : "NO"; } else if (setF.getAbsRow(i).getBindDataType().equals("TIME")) { Descripcion += atr; if (setF.getAbsRow(i).getIsRange()) { Descripcion += " a " + atr2; } } else if (setF.getAbsRow(i).getBindDataType().equals("DECIMAL") || setF.getAbsRow(i).getBindDataType().equals("MONEY")) { if (setF.getAbsRow(i).getPriDefault().length() > 0 && setF.getAbsRow(i).getPriDefault().substring(0, 1).equals("[")) { Descripcion += JUtil.obtValorDeFiltro(setF.getAbsRow(i).getPriDefault(), atr); } else { Descripcion += atr; } if (setF.getAbsRow(i).getIsRange()) { if (setF.getAbsRow(i).getSecDefault().length() > 0 && setF.getAbsRow(i).getSecDefault().substring(0, 1).equals("[")) { Descripcion += " a " + JUtil.obtValorDeFiltro(setF.getAbsRow(i).getSecDefault(), atr2); } else { Descripcion += " a " + atr2; } } } else // STRING O CUALQUIER OTRO MAS { if (setF.getAbsRow(i).getPriDefault().length() > 0 && setF.getAbsRow(i).getPriDefault().substring(0, 1).equals("[")) { Descripcion += JUtil.obtValorDeFiltro(setF.getAbsRow(i).getPriDefault(), atr); } else { Descripcion += atr; } if (setF.getAbsRow(i).getIsRange()) { if (setF.getAbsRow(i).getSecDefault().length() > 0 && setF.getAbsRow(i).getSecDefault().substring(0, 1).equals("[")) { Descripcion += JUtil.obtValorDeFiltro(setF.getAbsRow(i).getSecDefault(), atr); } else { Descripcion += " a " + atr2; } } } } // -------------------------------------------------------------------------------- else // Si es de catalogo { JListasCatalogosSet cats = new JListasCatalogosSet(request); cats.ConCat(true); int idcatalogo = Integer.parseInt(setF.getAbsRow(i).getSelect_Clause()); cats.m_Where = "ID_Catalogo = '" + idcatalogo + "'"; cats.Open(); JProcessSet setcat = new JProcessSet(request); setcat.setSelect(cats.getAbsRow(0).getSelect_Clause()); setcat.m_Where = "Clave = '" + q(atr) + "'"; setcat.Open(); if (atr.equals("0") && (cats.getAbsRow(0).getSeguridad().equals("PROVEEDORES") || cats.getAbsRow(0).getSeguridad().equals("CLIENTES"))) { //Cuando es un catalogo de proveedores o de clientes, y la clave es cero (proveedor o cliente de mostrador) permitir el paso a pesar de que la clave cero no existe en proveedores ni clientes Descripcion += "Mostrador"; } else { if (setcat.getNumRows() == 0) // Significa que la clave especificada en el atributo no existe en el catlogo { idmensaje = 3; mensaje = "ERROR: El atributo " + setF.getAbsRow(i).getPriDataName() + " de este filtro, no pertenece a ningn elemento del catlogo. Si no recuerdas la clave, puedes seleccionarla buscndola sobre el catlogo emergente"; break; } Descripcion += setcat.getAbsRow(0).getSTS("Col2"); } if (!cats.getAbsRow(0).getSeguridad().equals("")) // Significa que es catalogo de seguridad { // Los catalogos de seguridad, no pueden ser rango if (setF.getAbsRow(i).getIsRange()) { idmensaje = 3; mensaje = "ERROR: El atributo " + setF.getAbsRow(i).getPriDataName() + " de este filtro, no puede pertenecer a un rango, porque el catlogo requiere seguridad"; break; } else { // Revisa el nivel de seguridad del catalogo String usuario = getSesion(request).getID_Usuario(); String seg = cats.getAbsRow(0).getSeguridad(); if (seg.equals("VENTAS")) // Revisa por la seguridad en ventas { JUsuariosSubmoduloVentasPerm set = new JUsuariosSubmoduloVentasPerm(request, usuario, atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de venta " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("COMPRAS")) // Revisa por la seguridad en compras { JUsuariosSubmoduloComprasPerm set = new JUsuariosSubmoduloComprasPerm(request, usuario, atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de compra " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("BANCOS")) // Revisa por la seguridad en bancos { JUsuariosSubmoduloBancosPerm set = new JUsuariosSubmoduloBancosPerm(request, usuario, "0", atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de banco " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("CAJAS")) // Revisa por la seguridad en cajas { JUsuariosSubmoduloBancosPerm set = new JUsuariosSubmoduloBancosPerm(request, usuario, "1", atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de caja " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("BODEGAS")) // Revisa por la seguridad en bodegas { JUsuariosSubmoduloBodegasPerm set = new JUsuariosSubmoduloBodegasPerm(request, usuario, atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de bodega " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("PRODUCCION")) // Revisa por la seguridad en entidades de produccion { JUsuariosSubmoduloProduccionPerm set = new JUsuariosSubmoduloProduccionPerm(request, usuario, atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de produccin " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("NOMINA")) // Revisa por la seguridad en entidades de nmina { JUsuariosSubmoduloNominaPerm set = new JUsuariosSubmoduloNominaPerm(request, usuario, atr); set.Open(); if (set.getNumRows() < 1) { idmensaje = 3; mensaje = "ERROR: No tienes acceso a la entidad de nmina " + atr + " del atributo " + setF.getAbsRow(i).getPriDataName(); break; } } else if (seg.equals("PROVEEDORES") || seg.equals("CLIENTES") || seg.equals("EMPLEADOS")) { // Si es de proveedores, clientes o empleados // Simplemente ignora porque la seguridad la // trae en la entidad de compra o venta } else // Error no se ha especificado esta etiqueta de seguridad { idmensaje = 3; mensaje = "ERROR: No existe la etiqueta de seguridad: " + seg + ". Revisa con el proveedor del sistema sobre este error"; break; } } } if (setF.getAbsRow(i).getIsRange()) { JProcessSet setcat2 = new JProcessSet(request); setcat2.setSelect(cats.getAbsRow(0).getSelect_Clause()); setcat2.m_Where = "Clave = '" + q(atr2) + "'"; setcat2.Open(); if (setcat2.getNumRows() == 0) // Significa que la clave especificada en el atributo no existe en el catlogo { idmensaje = 3; mensaje = "ERROR: El atributo " + setF.getAbsRow(i).getPriDataName() + " (Hasta) de este rango, no pertenece a ningn elemento del catlogo. Si no recuerdas la clave, puedes seleccionarla buscndola sobre el catlogo emergente"; break; } Descripcion += " a " + setcat2.getAbsRow(0).getSTS("Col2"); //request.getParameter(setF.getAbsRow(i).getSecDataName() + "_FSIDESC"); } } Descripcion += ", "; } if (idmensaje != -1) { getSesion(request).setID_Mensaje(idmensaje, mensaje); irApag("/forsetiweb/caja_mensajes.jsp", request, response); return false; } String fsi_filtro; if (Descripcion == null || Descripcion.equals("")) fsi_filtro = ""; else fsi_filtro = Descripcion.substring(0, Descripcion.length() - 2); request.setAttribute("fsi_filtro", fsi_filtro); return true; } @SuppressWarnings({ "rawtypes" }) private String VerifyFilerClause(StringBuffer select, HttpServletRequest request) throws ServletException, IOException, DocumentException { //System.out.println("------------------------------------------------------------------------------------"); int totalatrs = 0, totalfil = 0; JReportesBindFSet setF = new JReportesBindFSet(request); setF.m_Where = "ID_Report = '" + p(request.getParameter("REPID")) + "'"; setF.m_OrderBy = "ID_Column ASC"; setF.Open(); int initial = select.indexOf("[", 0); int fin = (initial == -1) ? -1 : select.indexOf("]", initial); while (initial != -1 && fin != -1) { String atr = select.substring(initial + 1, fin); // ej ID_Empleado totalatrs += 1; //System.out.println("ATRIBUTO: " + atr + " Ini: " + (initial+1) + " Fin: " + fin); Enumeration nombresAtr = request.getParameterNames(); while (nombresAtr.hasMoreElements()) { String nombreAtr = (String) nombresAtr.nextElement(); if (atr.equals(nombreAtr)) { totalfil += 1; //System.out.println(nombreAtr); } } initial = select.indexOf("[", fin); fin = (initial == -1) ? -1 : select.indexOf("]", initial); } if (totalatrs != totalfil) throw new DocumentException( "Intento de inyeccin SQL detectada. El total de atributos no coincide con el total de elementos del filtro, se ha registrado tu usuario y host desde el cual estas queriendo corromper el sistema"); //System.out.println("-----------------------" + totalatrs + " : " + totalfil + "------------------------"); initial = select.indexOf("[", 0); fin = (initial == -1) ? -1 : select.indexOf("]", initial); while (initial != -1 && fin != -1) { String key = select.substring(initial + 1, fin); // ej ID_Empleado // Carga los valores por default Enumeration nombresAtr = request.getParameterNames(); while (nombresAtr.hasMoreElements()) { String nombreAtr = (String) nombresAtr.nextElement(); String valorAtr = (String) request.getParameter(nombreAtr); if (nombreAtr.equals(key)) { if (valorAtr.matches("\\d{1,2}/(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/\\d{4}")) // Es fecha.... valorAtr = JUtil.obtFechaSQL(valorAtr); //System.out.println(select + "\n"); //System.out.println("KV:" + nombreAtr + "|" + valorAtr + "\n"); for (int i = 0; i < setF.getNumRows(); i++) { if (setF.getAbsRow(i).getPriDataName().equals(nombreAtr)) { //System.out.println("FILTRO1:" + nombreAtr + "|" + setF.getAbsRow(i).getPriDefault() + "\n"); if (!setF.getAbsRow(i).getFromCatalog()) // No es de catalogo { if (setF.getAbsRow(i).getPriDefault().length() > 0 && setF.getAbsRow(i).getPriDefault().substring(0, 1).equals("[")) //Es lista de seleccion { //En filtros de seleccin, verificar que efectivamente exista la seleccin. Si no existe, significa intento de inyeccin SQL a travs de la modificacin directa del codigo html del filtro if (!JUtil.verificarElementoDeFiltro(setF.getAbsRow(i).getPriDefault(), valorAtr)) throw new DocumentException( "Intento de inyeccin SQL detectada, se ha registrado tu usuario y host desde el cual estas queriendo corromper el sistema"); select.replace(initial, fin + 1, valorAtr); } else select.replace(initial, fin + 1, q(valorAtr)); //Como es captura directa, utiliza q() para agregar escapes de ' al valor introducido por el usuario para evitar errores de sql o intentos de ataques de inyeccin sql } else // Si es de catalogo { select.replace(initial, fin + 1, valorAtr); } } if (setF.getAbsRow(i).getSecDataName().equals(nombreAtr)) { //System.out.println("FILTRO2:" + nombreAtr + "|" + setF.getAbsRow(i).getSecDefault() + "\n"); if (!setF.getAbsRow(i).getFromCatalog()) // No es de catalogo { if (setF.getAbsRow(i).getSecDefault().length() > 0 && setF.getAbsRow(i).getSecDefault().substring(0, 1).equals("[")) //Es lista de seleccion { //En filtros de seleccin, verificar que efectivamente exista la seleccin. Si no existe, significa intento de inyeccin SQL a travs de la modificacin directa del codigo html del filtro if (!JUtil.verificarElementoDeFiltro(setF.getAbsRow(i).getSecDefault(), valorAtr)) throw new DocumentException( "Intento de inyeccin SQL detectada, se ha registrado tu usuario y host desde el cual estas queriendo corromper el sistema"); select.replace(initial, fin + 1, valorAtr); } else select.replace(initial, fin + 1, q(valorAtr)); //Como es captura directa, utiliza q() para agregar escapes de ' al valor introducido por el usuario para evitar errores de sql o intentos de ataques de inyeccin sql } else // Si es de catalogo { select.replace(initial, fin + 1, valorAtr); } } } } } initial = select.indexOf("[", 0); fin = (initial == -1) ? -1 : select.indexOf("]", initial); } return select.toString(); } private String VerifyWhereClause(StringBuffer select, REP_LEVEL1 pNodeL1) { int initial = select.indexOf("[", 0); int fin = (initial == -1) ? -1 : select.indexOf("]", initial); while (initial != -1 && fin != -1) { //String extract = select.substring(initial, (fin + 1)); String key = select.substring(initial + 1, fin); String replace = pNodeL1.getSTS(key); //AfxMessageBox(select); select.replace(initial, fin + 1, replace); //AfxMessageBox(select); initial = select.indexOf("[", 0); fin = (initial == -1) ? -1 : select.indexOf("]", initial); } return select.toString(); } private String VerifyWhereClause(StringBuffer select, REP_LEVEL2 pNodeL2) { int initial = select.indexOf("[", 0); int fin = (initial == -1) ? -1 : select.indexOf("]", initial); while (initial != -1 && fin != -1) { //String extract = select.substring(initial, (fin + 1)); String key = select.substring(initial + 1, fin); String replace = pNodeL2.getSTS(key); //AfxMessageBox(select); select.replace(initial, fin + 1, replace); //AfxMessageBox(select); initial = select.indexOf("[", 0); fin = (initial == -1) ? -1 : select.indexOf("]", initial); } return select.toString(); } }