Java 类org.springframework.web.servlet.view.jasperreports.JasperReportsMultiFormatView 实例源码

项目:openlmis-stockmanagement    文件:PhysicalInventoryController.java   
/**
 * Print out physical inventory as a PDF file.
 *
 * @param id The UUID of the stock event to print
 * @param format The report format
 * @return ResponseEntity with the "#200 OK" HTTP response status and PDF file on success, or
 *     ResponseEntity containing the error description status.
 */
@GetMapping(value = ID_PATH_VARIABLE, params = "format")
@ResponseBody
public ModelAndView print(@PathVariable("id") UUID id, @RequestParam String format)
    throws JasperReportViewException {
  checkPermission(id);
  checkFormat(format.toLowerCase());

  JasperTemplate printTemplate = templateService.getByName(PRINT_PI);
  if (printTemplate == null) {
    throw new ValidationMessageException(
        new Message(ERROR_REPORTING_TEMPLATE_NOT_FOUND_WITH_NAME, PRINT_PI));
  }

  JasperReportsMultiFormatView jasperView =
      jasperReportService.getJasperReportsView(printTemplate);

  return new ModelAndView(jasperView, getParams(id, format));
}
项目:geomajas-project-server    文件:ReportingController.java   
/**
 * Report on the features of a layer.
 *
 * @param reportName name of the report
 * @param format format for the report (eg "pdf")
 * @param layerId id of the layer
 * @param crs coordinate reference system
 * @param filter filter to apply on layer
 * @param request request object for report parameters
 * @param model mvc model
 * @return name of the view
 */
@RequestMapping(value = "/reporting/f/{layerId}/{reportName}.{format}", method = RequestMethod.GET)
public String reportFeatures(@PathVariable String reportName, @PathVariable String format,
        @PathVariable String layerId, @RequestParam(defaultValue = "EPSG:4326", required = false) String crs,
        @RequestParam(required = false) String filter, HttpServletRequest request, Model model) {
    List<InternalFeature> features;
    try {
        Filter filterObject = null;
        if (null != filter) {
            filterObject = filterService.parseFilter(filter);
        }
        features = vectorLayerService.getFeatures(layerId, geoService.getCrs2(crs), filterObject, null,
                VectorLayerService.FEATURE_INCLUDE_ALL);
        model.addAttribute(DATA_SOURCE, new InternalFeatureDataSource(features));
        addParameters(model, request);
    } catch (GeomajasException ge) {
        log.error(REPORT_DATA_PROBLEM, ge);
        model.addAttribute(DATA_SOURCE, new InternalFeatureDataSource(new ArrayList<InternalFeature>()));
    }
    model.addAttribute(JasperReportsMultiFormatView.DEFAULT_FORMAT_KEY, format);
    return getView(reportName);
}
项目:geomajas-project-server    文件:ReportingController.java   
/**
 * Report on the features of a layer with map image and legend, data coming from the cache.
 *
 * @param reportName name of the report
 * @param format format for the report (eg "pdf")
 * @param layerId id of the layer
 * @param key cache key for data
 * @param request request object for report parameters
 * @param model mvc model
 * @return name of the view
 */
@RequestMapping(value = "/reporting/c/{layerId}/{reportName}.{format}", method = RequestMethod.GET)
public String reportFromCache(@PathVariable String reportName, @PathVariable String format,
        @PathVariable String layerId, @RequestParam(required = true) String key, HttpServletRequest request,
        Model model) {
    try {
        VectorLayer layer = configurationService.getVectorLayer(layerId);
        if (null != layer) {
            ReportingCacheContainer container =
                    cacheManager.get(layer, CacheCategory.RASTER, key, ReportingCacheContainer.class);
            addParameters(model, request);
            if (null != container) {
                model.addAttribute("map", JRImageRenderer.getInstance(container.getMapImageData()));
                model.addAttribute("legend", JRImageRenderer.getInstance(container.getLegendImageData()));
                model.addAttribute(DATA_SOURCE, getDataSource(container));
            } else {
                model.addAttribute(DATA_SOURCE, new InternalFeatureDataSource(new ArrayList<InternalFeature>()));
            }
        }
    } catch (GeomajasException ge) {
        log.error(REPORT_DATA_PROBLEM, ge);
        model.addAttribute(DATA_SOURCE, new InternalFeatureDataSource(new ArrayList<InternalFeature>()));
    }
    model.addAttribute(JasperReportsMultiFormatView.DEFAULT_FORMAT_KEY, format);
    return getView(reportName);
}
项目:training-brainmatics-2016-01    文件:KonfigurasiWeb.java   
@Bean
public JasperReportsViewResolver jasperResolver(){
    JasperReportsViewResolver resolver = new JasperReportsViewResolver();

    resolver.setViewClass(JasperReportsMultiFormatView.class);
    resolver.setOrder(0); // cari template jasper dulu, kalau tidak ketemu, baru cari template thymeleaf
    resolver.setViewNames("report/*");
    resolver.setPrefix("classpath:/");
    resolver.setSuffix(".jrxml");
    resolver.setReportDataKey("dataDalamReport");

    return resolver;
}
项目:ciea    文件:ReporteController.java   
@RequestMapping(value = "/reporte/{reporte}/{formato}", method = RequestMethod.GET)
public ModelAndView getRerporte(
        @PathVariable("reporte") String reporte,
        @PathVariable("formato") String formato,
        @RequestParam(required = false) Map<String, String> parametros) {
    Properties headers = new Properties();
    headers.put("Content-Disposition", "attachment; filename=" + reporte + "." + formato);
    JasperReportsMultiFormatView view = new JasperReportsMultiFormatView();
    view.setJdbcDataSource(dataSource);
    view.setUrl("classpath:" + reporte + ".jrxml");
    view.setHeaders(headers);
    parametros.put("format", formato);
    view.setApplicationContext(appContext);
    return new ModelAndView(view, parametros);
}
项目:openlmis-stockmanagement    文件:JasperReportService.java   
/**
 * Create Jasper Report View.
 * Create Jasper Report (".jasper" file) from bytes from Template entity.
 * Set 'Jasper' exporter parameters, JDBC data source, web application context, url to file.
 *
 * @param jasperTemplate template that will be used to create a view
 * @return created jasper view.
 * @throws JasperReportViewException if there will be any problem with creating the view.
 */
public JasperReportsMultiFormatView getJasperReportsView(JasperTemplate jasperTemplate)
    throws JasperReportViewException {
  JasperReportsMultiFormatView jasperView = new JasperReportsMultiFormatView();
  jasperView.setJdbcDataSource(replicationDataSource);
  jasperView.setUrl(getReportUrlForReportData(jasperTemplate));
  jasperView.setApplicationContext(appContext);
  return jasperView;
}