Esempio n. 1
0
 /**
  * Metodo privado que rellena el map usado para cargar los contenidos generales de las vistas.
  *
  * @param map, Mapa vacío
  * @param tipoForm, nombre del bean del formulario que maneja la vista
  */
 private void fillInitialMap(Map<String, Object> map, String tipoForm) {
   // Se inserta el nombre del formulario que presenta la vista
   map.put("modelAttribute", tipoForm);
   // Informacion para el renderizado de la pagina
   map.put(
       "firstOptionText",
       this.messageSource.getMessage("page.common.option.select", null, WebCoreUtils.getLocale()));
   map.put("userLang", WebCoreUtils.getLocale().getLanguage());
 }
 /**
  * Convierte entre un objeto de base de datos y uno de capa de presentacion.
  *
  * @param bean objeto con la informacion de la base de datos
  * @return objeto de capa de presentacion
  */
 @Override
 protected String[] beanToStrings(ComunidadAutonomaBean bean) {
   String[] retorno =
       new String[] {
         WriteUtil.formatValue(bean.getCodigo()),
         WriteUtil.formatValue(bean.getDescripcion()),
         WriteUtil.formatValue(
             bean.getActivo()
                 ? this.messageSource.getMessage("common.si", null, WebCoreUtils.getLocale())
                 : this.messageSource.getMessage("common.no", null, WebCoreUtils.getLocale()))
       };
   return retorno;
 }
Esempio n. 3
0
  /**
   * Peticion para exportar las etiquetas pendientes de generar
   *
   * @param request Peticion
   * @param response Respuesta
   * @return Componente tile al que se redirige (si es correcta la generación del pdf se devuelve
   *     null)
   */
  @RequestMapping(value = "/persona/etiquetasPendientes")
  public String etiquetasPendientes(HttpServletRequest request, HttpServletResponse response) {

    // Generar el informe en formato Excel
    PersonaQueryBean personaQueryBean =
        (PersonaQueryBean) request.getSession().getAttribute("personaQueryBean");

    String username = (String) SecurityAccess.getUserInformation().getUsername();

    String reportName = "etiquetasPersonasReport";
    String reportTitle =
        this.messageSource.getMessage("page.breadcrumb.persona", null, WebCoreUtils.getLocale());
    String reportType = "PDF";
    String fullReportName = null;
    String contentType = null;

    Boolean vacio = false;

    try {
      fullReportName = "etiquetasPendientesReport.pdf";
      contentType = "application/pdf";

      byte[] byteArray =
          this.personaService.etiquetasPersonas(
              username, personaQueryBean, reportType, reportName, reportTitle);
      if (byteArray == null) {
        vacio = true;
      } else {
        response.reset();
        response.setContentType(contentType);
        response.setHeader(
            "Content-disposition", "attachment" + ";filename=\"" + fullReportName + "\"");
        response.addHeader("Pragma", "no cache");
        response.addHeader("Cache-control", "private, must-revalidate");

        ServletOutputStream outstream = response.getOutputStream();
        outstream.write(byteArray);
        outstream.flush();
        outstream.close();
      }
    } catch (IOException e) {
      LOGGER.error(e.getMessage());
      return "app/errorEtiquetas";
    }

    if (vacio) {
      LOGGER.info("No hay registros");
      return "app/sinEtiquetas";
    }

    return null;
  }
Esempio n. 4
0
  /**
   * Peticion para exportar la etiqueta de una persona
   *
   * @param request Peticion
   * @param response Respuesta
   * @return Componente tile al que se redirige (si es correcta la generación del pdf se devuelve
   *     null)
   */
  @RequestMapping(value = "/persona/etiquetaPersona")
  public String etiquetaPersona(HttpServletRequest request, HttpServletResponse response) {

    // Generar el informe en formato Excel
    PersonaQueryBean personaQueryBean = new PersonaQueryBean();
    String idPersona = (String) RequestUtil.getStringParameter(request, "idPersona");
    personaQueryBean.setIdPersona(Long.valueOf(idPersona));

    String username = (String) SecurityAccess.getUserInformation().getUsername();
    String reportName = "etiquetasPersonasReport";
    String reportTitle =
        this.messageSource.getMessage("page.breadcrumb.persona", null, WebCoreUtils.getLocale());
    String reportType = "PDF";
    String fullReportName = null;
    String contentType = null;

    try {

      fullReportName = "etiquetaPersonaReport.pdf";
      contentType = "application/pdf";

      byte[] byteArray =
          this.personaService.etiquetaPersona(
              username, personaQueryBean, reportType, reportName, reportTitle);

      response.reset();
      response.setContentType(contentType);
      response.setHeader(
          "Content-disposition", "attachment" + ";filename=\"" + fullReportName + "\"");
      response.addHeader("Pragma", "no cache");
      response.addHeader("Cache-control", "private, must-revalidate");

      ServletOutputStream outstream = response.getOutputStream();
      outstream.write(byteArray);
      outstream.flush();
      outstream.close();
    } catch (IOException e) {
      LOGGER.error(e.getMessage());
      return "app/errorPage";
    }

    return null;
  }
Esempio n. 5
0
  /**
   * Peticion para exportar el pdf de detalle de una persona
   *
   * @param request Peticion
   * @param response Respuesta
   * @return Componente tile al que se redirige (si es correcta la generación del pdf se devuelve
   *     null)
   */
  @RequestMapping(value = "/persona/exportPersona")
  public String exportPersona(HttpServletRequest request, HttpServletResponse response) {

    // Generar el informe en formato Excel
    PersonaQueryBean personaQueryBean = new PersonaQueryBean();
    String idPersona = (String) RequestUtil.getStringParameter(request, "idPersona");
    personaQueryBean.setIdPersona(Long.valueOf(idPersona));

    String username = (String) SecurityAccess.getUserInformation().getUsername();
    String reportName = "personaDetalleReport";
    String reportTitle =
        this.messageSource.getMessage("page.breadcrumb.persona", null, WebCoreUtils.getLocale());
    String reportType = RequestUtil.getStringParameter(request, "exportType", null);
    String fullReportName = null;
    String contentType = null;

    try {
      if (reportType != null) {
        if (!reportType.equalsIgnoreCase("Exportar")) {
          if (reportType.equalsIgnoreCase("XLS")) {
            fullReportName = "personaDetalleReport.xls";
            contentType = "application/xls";
          } else if (reportType.equalsIgnoreCase("PDF")) {
            fullReportName = "personaDetalleReport.pdf";
            contentType = "application/pdf";
          } else if (reportType.equalsIgnoreCase("DOCX")) {
            fullReportName = "personaDetalleReport.doc";
            contentType = "application/doc";
          } else {
            throw new CoreException("error.export");
          }

          byte[] byteArray =
              this.personaService.exportPersona(
                  username, personaQueryBean, reportType, reportName, reportTitle);

          response.reset();
          response.setContentType(contentType);
          response.setHeader(
              "Content-disposition", "attachment" + ";filename=\"" + fullReportName + "\"");
          response.addHeader("Pragma", "no cache");
          response.addHeader("Cache-control", "private, must-revalidate");

          ServletOutputStream outstream = response.getOutputStream();
          outstream.write(byteArray);
          outstream.flush();
          outstream.close();
        } else {
          LOGGER.error("Error en el formato de tipo de exportacion; " + reportType);
          return Constantes.ERRORPAGE;
        }
      } else {
        throw new CoreException("error.request.export");
      }

    } catch (IOException e) {
      LOGGER.error(e.getMessage());
      return "app/errorPage";
    }

    return null;
  }