Java 类net.sf.jasperreports.engine.data.JRBeanCollectionDataSource 实例源码

项目:dynamicreports-jasper    文件:ColumnListDataTypeReport.java   
private JRDataSource createDataSource() {
    List<ReportData> datasource = new ArrayList<ReportData>();

    ReportData data = new ReportData();
    List<String> comments = new ArrayList<String>();
    comments.add("comment1");
    comments.add("comment2");
    comments.add("comment3");
    data.setItem("Book");
    data.setQuantity(new Integer(10));
    data.setComments(comments);
    datasource.add(data);

    data = new ReportData();
    comments = new ArrayList<String>();
    comments.add("comment1");
    comments.add("comment2");
    data.setItem("Notebook");
    data.setQuantity(new Integer(20));
    data.setComments(comments);
    datasource.add(data);

    return new JRBeanCollectionDataSource(datasource);
}
项目:openelisglobal-sandbox    文件:CollectionReport.java   
@Override
public byte[] runReport() throws Exception {
    List<byte[]> byteList = generateReports();
    if (byteList.isEmpty()) {
        HashMap<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("SUBREPORT_DIR", reportPath);
        parameterMap.put("directorName", ConfigurationProperties.getInstance().getPropertyValue(Property.labDirectorName));
        List<ErrorMessages> errorMsgs = new ArrayList<ErrorMessages>();
        ErrorMessages msgs = new ErrorMessages();
        msgs.setMsgLine1(StringUtil.getMessageForKey("report.error.message.noPrintableItems"));
        errorMsgs.add(msgs);
        return JasperRunManager.runReportToPdf(reportPath + "NoticeOfReportError.jasper", parameterMap, new JRBeanCollectionDataSource(
                errorMsgs));
    } else {
        return merge(byteList);
    }
}
项目:logistimo-web-service    文件:JasperClient.java   
public PDFResponseModel generatePDF(String fileName, String template, String bucketName,
    Collection<?> items, Map<String, Object> parameters)
    throws ClassNotFoundException, JRException, IOException {

  JasperPrint jasperPrint;
  InputStream inputStream = null;

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(items);

  try {
    inputStream = storageUtil.getInputStream(bucketName, template);
    jasperPrint = JasperFillManager.fillReport(JasperCompileManager.compileReport(
        inputStream), parameters, beanColDataSource);
    byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
    return new PDFResponseModel(fileName, pdfBytes);
  } catch (ClassNotFoundException | JRException | IOException e) {
    xLogger.severe("Failed to generate PDF for file name - ", fileName, e);
    throw e;
  } finally {
    if (inputStream != null) {
      inputStream.close();
    }
  }
}
项目:oscar-old    文件:FrmPDFServlet.java   
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
项目:oscar-old    文件:EFormPDFServlet.java   
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
项目:GerenciadorEventos    文件:ControllerBaseRelatorio.java   
public void executaRelatorioPDF() throws JRException, IOException {

        InputStream reportStream = null;
        try {
            reportStream = getClass().getResourceAsStream(relatorio);
            //JasperReport report = JasperCompileManager.compileReport(reportStream);

            JRDataSource ds = new JRBeanCollectionDataSource(getDados(), true);
            //JasperPrint jasperPrint = JasperFillManager.fillReport(report, carregaParametros(), ds);
            JasperPrint jasperPrint = JasperFillManager.fillReport(reportStream, carregaParametros(), ds);

            HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
            httpServletResponse.addHeader("Content-disposition", "attachment; filename=" + getArquivoSaida() + ".pdf");
            ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
            JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
            FacesContext.getCurrentInstance().responseComplete();            

        } catch (JRException ex) {
            Logger.getLogger(ControllerBaseRelatorio.class.getName()).log(Level.SEVERE, null, ex);            
        } finally {
            if(reportStream != null)
                reportStream.close();

        }
    }
项目:lams    文件:JasperReportsUtils.java   
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
    if (value instanceof JRDataSource) {
        return (JRDataSource) value;
    }
    else if (value instanceof Collection) {
        return new JRBeanCollectionDataSource((Collection<?>) value);
    }
    else if (value instanceof Object[]) {
        return new JRBeanArrayDataSource((Object[]) value);
    }
    else {
        throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
    }
}
项目:OSCAR-ConCert    文件:FrmCustomedPDFServlet.java   
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req) {

        HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession().getAttribute(HSFO_RX_DATA_KEY);

        JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
        } catch (JRException e) {
            throw new RuntimeException(e);
        }
        return baos;
    }
项目:Omoikane    文件:EtiquetaGenerator.java   
public void generate(String reportURL,Collection<Articulo> articulos)
{
    try {
        InputStream is = loadReport(reportURL);
        JasperDesign design = JRXmlLoader.load(is);
        JasperReport report = JasperCompileManager.compileReport(design);
        jp = JasperFillManager.fillReport(report,new HashMap(),new JRBeanCollectionDataSource(articulos));

        JasperViewer jasperViewer = new JasperViewer(jp, false);
        jasperViewer.setDefaultCloseOperation(JasperViewer.DISPOSE_ON_CLOSE);
        jasperViewer.setTitle("Etiquetas");
        jasperViewer.setZoomRatio((float) 1.25);
        jasperViewer.setExtendedState(JasperViewer.MAXIMIZED_BOTH);
        jasperViewer.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
        jasperViewer.requestFocus();
        jasperViewer.setVisible(true);
    }catch (Exception e) {
        logger.error("Error al generar etiquetas", e);
    }

}
项目:jnami    文件:PDFReportGenerator.java   
public static <T> void generateReport(String report,
        Map<String, Object> params, Collection<T> data,
        String outputFilename) {
    try {
        InputStream reportStream = PDFReportGenerator.class
                .getResourceAsStream(report + ".jasper");
        JasperPrint jasperPrint;
        jasperPrint = JasperFillManager.fillReport(reportStream, params,
                new JRBeanCollectionDataSource(data));
        JasperExportManager.exportReportToPdfFile(jasperPrint,
                outputFilename);

        log.info("Generated Report");
    } catch (JRException e) {
        log.log(Level.WARNING, "Could not generate Report", e);
    }
}
项目:dynamicreports-jasper    文件:CollectionDatasourceReport.java   
private JRDataSource createDataSource() {
    List<Data> data = new ArrayList<Data>();

    List<SubData> subData = new ArrayList<SubData>();
    subData.add(new SubData(toDate(2011, 0, 10), 2));
    subData.add(new SubData(toDate(2011, 0, 15), 3));
    data.add(new Data("DVD", 5, new BigDecimal(30), subData));

    subData = new ArrayList<SubData>();
    subData.add(new SubData(toDate(2011, 0, 11), 1));
    subData.add(new SubData(toDate(2011, 0, 12), 3));
    subData.add(new SubData(toDate(2011, 0, 16), 4));
    data.add(new Data("Book", 8, new BigDecimal(11), subData));

    subData = new ArrayList<SubData>();
    subData.add(new SubData(toDate(2011, 0, 9), 1));
    subData.add(new SubData(toDate(2011, 0, 18), 1));
    data.add(new Data("PDA", 2, new BigDecimal(15), subData));

    return new JRBeanCollectionDataSource(data);
}
项目:Hotel-Properties-Management-System    文件:ShowReport.java   
public void loadReport(String reportName, ReportObject reportObject) {

        logging = LoggingEngine.getInstance();

        try {

            final InputStream inputStream = ShowReport.class
                    .getResourceAsStream("/com/coder/hms/reportTemplates/" + reportName + ".jrxml");
            JasperReport report = JasperCompileManager.compileReport(inputStream);

            HashMap<String, Object> parameters = new HashMap<String, Object>(); 
            List<ReportObject> list = new ArrayList<ReportObject>();
            list.add(reportObject);
            JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);
            JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource);
            final JRViewer viewer = new JRViewer(jasperPrint);

            setType(Type.POPUP);
            setResizable(false);
            setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
            this.setTitle("Reservation [Report]");
            this.setExtendedState(Frame.MAXIMIZED_BOTH);
            this.setAlwaysOnTop(isAlwaysOnTopSupported());
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            getContentPane().setLayout(new BorderLayout());
            this.setIconImage(Toolkit.getDefaultToolkit().
                    getImage(LoginWindow.class.getResource(LOGOPATH)));
            this.setResizable(false);
            getContentPane().add(viewer, BorderLayout.CENTER);

        } catch (JRException e) {
            logging.setMessage("JRException report error!");
        }

    }
项目:logistimo-web-service    文件:GenerateInvoiceTest.java   
@Test
public void testInvoice(){
  List<InvoiceItem> invoiceItems = new ArrayList<>();

  int count = 1;
  for (IDemandItem demandItem : getDemandItems()) {
    InvoiceItem invoiceItem = new InvoiceItem();
    invoiceItem.setItem(demandItem.getMaterialId().toString());
    invoiceItem.setQuantity(demandItem.getQuantity().toString());
    invoiceItem.setRecommended(demandItem.getRecommendedOrderQuantity().toString());
    invoiceItem.setRemarks("Blah");
      invoiceItem.setBatchId("AB/1234/56"+count);
      invoiceItem.setExpiry("11/03/2020");
      invoiceItem.setManufacturer("Serum");
      invoiceItem.setBatchQuantity(BigDecimal.TEN.toPlainString());
    invoiceItem.setSno(String.valueOf(count++));
    invoiceItems.add(invoiceItem);
  }

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(invoiceItems);

  try {

    Map<String, Object> hm = new HashMap<>();
    JasperPrint jasperPrint = JasperFillManager.fillReport(
        JasperCompileManager
            .compileReport(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "test_logistimo_invoice.jrxml")), hm, beanColDataSource);

    JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/logistimo_invoice.pdf");


  } catch (Exception e) {
    e.printStackTrace();
  }


}
项目:OSCAR-ConCert    文件:FrmPDFServlet.java   
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    finally {
        IOUtils.closeQuietly(is);
    }

    return baos;
}
项目:OSCAR-ConCert    文件:EFormPDFServlet.java   
private ByteArrayOutputStream generateHsfoRxPDF(HttpServletRequest req){
    HsfoRxDataHolder rx = (HsfoRxDataHolder) req.getSession()
    .getAttribute(HSFO_RX_DATA_KEY);

    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(rx.getOutlines());
    InputStream is = Thread.currentThread().getContextClassLoader()
    .getResourceAsStream("/oscar/form/prop/Hsfo_Rx.jasper");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
        JasperRunManager.runReportToPdfStream(is, baos, rx.getParams(), ds);
    } catch (JRException e) {
        throw new RuntimeException(e);
    }
    return baos;
}
项目:FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM    文件:Report.java   
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
        InputStream inputStream = new FileInputStream (".\\src\\reports\\test_jasper.jrxml");

        DataBeanMaker dataBeanMaker = new DataBeanMaker();
        ArrayList<DataBean> dataBeanList = dataBeanMaker.getDataBeanList(null);

        JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataBeanList);

        Map parameters = new HashMap();

JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);
//JasperExportManager.exportReportToPdfFile(jasperPrint, "c:/test_jasper.pdf");
    JRViewer jv=new JRViewer(jasperPrint);
JFrame jf = new JFrame();
    jf.getContentPane().add(jv);
    jf.validate();
    jf.setVisible(true);
    jf.setSize(new Dimension(1000,800));
    jf.setLocation(300,100);
    jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
项目:FACE-RECOGNITION-BASED-ATTENDANCE-MANAGEMENT-SYSTEM    文件:Report.java   
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
        InputStream inputStream = new FileInputStream (".\\src\\reports\\test_jasper.jrxml");

        DataBeanMaker dataBeanMaker = new DataBeanMaker();
        ArrayList<DataBean> dataBeanList = dataBeanMaker.getDataBeanList(null);

        JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataBeanList);

        Map parameters = new HashMap();

JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);
//JasperExportManager.exportReportToPdfFile(jasperPrint, "c:/test_jasper.pdf");
    JRViewer jv=new JRViewer(jasperPrint);
JFrame jf = new JFrame();
    jf.getContentPane().add(jv);
    jf.validate();
    jf.setVisible(true);
    jf.setSize(new Dimension(1000,800));
    jf.setLocation(300,100);
    jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
项目:karaku    文件:KarakuBaseReportDetail.java   
@Override
public void generateReport(KarakuReportDetails report, Align align,
        Map<String, Object> params, String type, T bean, Class<?> clazz) {

    try {
        JRDataSource datasource = new JRBeanCollectionDataSource(
                getDetails(bean));
        exportReport.exportDetailReport(report, align,
                withCriteriaVisible(), clazz, datasource, params, type);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_SUCCESS);
    } catch (Exception e) {
        log.warn("Can't create report", e);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_FAILURE);
    }

}
项目:karaku    文件:KarakuBaseReportDetail.java   
@Override
public void generateReport(String path, KarakuReportDetails report,
        Map<String, Object> params, String type, T bean, Class<?> clazz) {

    try {
        JRDataSource datasource = new JRBeanCollectionDataSource(
                getDetails(bean));
        exportReport.exportDetailReport(path, report, clazz, datasource,
                params, type);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_SUCCESS);
    } catch (Exception e) {
        log.warn(ERROR_MESSAGE, e);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_FAILURE);
    }

}
项目:karaku    文件:KarakuBaseReportDetail.java   
@Override
public void generateReport(String path, Map<String, Object> params,
        String type, T bean, Class<?> clazz) {

    try {
        JRDataSource datasource = new JRBeanCollectionDataSource(
                getDetails(bean));
        exportReport.exportReportStatic(path, datasource, params, type);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_SUCCESS);
    } catch (Exception e) {
        log.warn(ERROR_MESSAGE, e);
        controllerHelper.createGlobalFacesMessage(
                FacesMessage.SEVERITY_INFO, BASE_REPORT_CREATE_FAILURE);
    }

}
项目:dwoss    文件:SalesListingProducerOperation.java   
/**
 * Create a filejacket from a collection of lines that are filtered by configuration parameters.
 * Lines are filtered by brand and group.
 * <p>
 * @param config configuration for filtering and file creation
 * @param all    lines to be considered
 * @return a filejacket from a collection of lines that are filtered by configuration parameters.
 */
private FileJacket createListing(ListingConfiguration config, Collection<StackedLine> all) {
    try {
        SortedSet<StackedLine> filtered = all.stream()
                .filter(line -> (config.getAllBrands().contains(line.getBrand()) && config.getGroups().contains(line.getGroup())))
                .collect(Collectors.toCollection(TreeSet::new));
        if ( filtered.isEmpty() ) return null;
        L.info("Creating listing {} with {} lines", config.getName(), filtered.size());
        JRDataSource datasource = new JRBeanCollectionDataSource(filtered);
        JasperPrint jasperPrint = JasperFillManager.fillReport(config.getJasperTemplateFile(), config.toReportParamters(), datasource);
        byte[] pdfContend = JasperExportManager.exportReportToPdf(jasperPrint);
        return new FileJacket(config.getFilePrefix() + config.getName(), ".pdf", pdfContend);
    } catch (JRException ex) {
        throw new RuntimeException(ex);
    }
}
项目:openeos    文件:OsgiTestCase.java   
@Test
public void testAutoRegisterJasperReportsExecuteReport() throws Exception {
    JasperReport report1 = (JasperReport) JRLoader.loadObject(getClass().getClassLoader().getResource(TEST_REPORT_1));

    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    properties.put(Constants.SERVICE_RANKING, 0);
    properties.put(org.openeos.reporting.jasperreports.Constants.SERVICE_REPORT_ID, TEST_REPORT_1);
    ServiceRegistration<JasperReport> register1 = bc.registerService(JasperReport.class, report1, properties);

    HashMap<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(JRParameter.REPORT_DATA_SOURCE, new JRBeanCollectionDataSource(createSampleBeans()));
    InputStream result = reportingService.generateReport(TEST_REPORT_1, "application/pdf", parameters);
    PdfReader reader = new PdfReader(result);
    assertEquals(1, reader.getNumberOfPages());
    reader.close();
    register1.unregister();
}
项目:jnami    文件:ReportViewer.java   
private <T> void viewReport(String reportFile, Map<String, Object> params,
        Collection<T> data) {
    try {
        InputStream reportIS = ReportViewer.class
                .getResourceAsStream(reportFile + ".jasper");
        JasperPrint jasperPrint;
        jasperPrint = JasperFillManager.fillReport(reportIS, params,
                new JRBeanCollectionDataSource(data));
        // JasperExportManager.exportReportToPdfFile(jasperPrint,
        // "/home/fabian/test.pdf");
        log.info("Generated Report");
        JasperViewer.viewReport(jasperPrint, false);
    } catch (JRException e) {
        log.log(Level.WARNING, "Could not generate Report", e);
    }
}
项目:spring4-understanding    文件:AbstractJasperReportsTests.java   
protected Map<String, Object> getModel() {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("ReportTitle", "Dear Lord!");
    model.put("dataSource", new JRBeanCollectionDataSource(getData()));
    extendModel(model);
    return model;
}
项目:spring4-understanding    文件:JasperReportsUtils.java   
/**
 * Convert the given report data value to a {@code JRDataSource}.
 * <p>In the default implementation, a {@code JRDataSource},
 * {@code java.util.Collection} or object array is detected.
 * The latter are converted to {@code JRBeanCollectionDataSource}
 * or {@code JRBeanArrayDataSource}, respectively.
 * @param value the report data value to convert
 * @return the JRDataSource (never {@code null})
 * @throws IllegalArgumentException if the value could not be converted
 * @see net.sf.jasperreports.engine.JRDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanCollectionDataSource
 * @see net.sf.jasperreports.engine.data.JRBeanArrayDataSource
 */
public static JRDataSource convertReportData(Object value) throws IllegalArgumentException {
    if (value instanceof JRDataSource) {
        return (JRDataSource) value;
    }
    else if (value instanceof Collection) {
        return new JRBeanCollectionDataSource((Collection<?>) value);
    }
    else if (value instanceof Object[]) {
        return new JRBeanArrayDataSource((Object[]) value);
    }
    else {
        throw new IllegalArgumentException("Value [" + value + "] cannot be converted to a JRDataSource");
    }
}
项目:training-brainmatics-2016-01    文件:MateriController.java   
private JasperPrint generateMateriJasperReport() throws JRException, IOException {
    Map<String, Object> reportParameters = new HashMap<>();
    reportParameters.put("tanggalCetak", new Date());
    JRBeanCollectionDataSource reportData 
            = new JRBeanCollectionDataSource(IteratorUtils.toList(md.findAll().iterator()));
    JasperPrint materiReport = JasperFillManager.fillReport(getMateriJasper(), reportParameters, 
            reportData);
    return materiReport;
}
项目:jasperreports    文件:DataSourceApp.java   
/**
 *
 */
public void fill4() throws JRException
{
    long start = System.currentTimeMillis();
    //Preparing parameters
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("ReportTitle", "Address Report");
    parameters.put("DataFile", "CustomBeanFactory.java - Bean Collection");

    JasperFillManager.fillReportToFile("build/reports/DataSourceReport.jasper", parameters, new JRBeanCollectionDataSource(CustomBeanFactory.getBeanCollection()));
    System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FunctionsApp.java   
/**
 *
 */
public JRDataSource createDataSource(
    JasperReportsContext jasperReportsContext, 
    Locale locale 
    ) 
{
    FunctionsInfo functionsInfo = FunctionsInfo.getInstance(jasperReportsContext, locale);
    Collection<FunctionCategoryBean> categories = functionsInfo.getCategories(); 
    return new JRBeanCollectionDataSource(categories);
}
项目:pitanga-system    文件:Relatorio.java   
public void gerarRelatorioEstados(List<Uf> estados) throws JRException {

        InputStream fonte = Relatorio.class.getResourceAsStream("/br/com/pitanga/report/RelatorioEstados.jrxml");

        JasperReport report = JasperCompileManager.compileReport(fonte);
        JasperPrint print = JasperFillManager.fillReport(report, null, new JRBeanCollectionDataSource(estados));
        JasperViewer.viewReport(print, false);
    }
项目:pitanga-system    文件:Relatorio.java   
public void gerarRelatorioCidades(List<Cidade> cidades) throws JRException {

        InputStream fonte = Relatorio.class.getResourceAsStream("/br/com/pitanga/report/RelatorioCidades.jrxml");

        JasperReport report = JasperCompileManager.compileReport(fonte);
        JasperPrint print = JasperFillManager.fillReport(report, null, new JRBeanCollectionDataSource(cidades));
        JasperViewer.viewReport(print, false);
    }
项目:eMonocot    文件:PdfWritingTest.java   
@Test
public final void testJasperReportsWriter() throws Exception {

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("name", "Joe");

    //With the data-source
    JRDataSource jrNameDatasource = new JRBeanCollectionDataSource(itemsToWrite);
    JasperReport jrNameReport = JasperCompileManager.compileReport(
            new ClassPathResource("org/emonocot/job/download/reports/name_report1.jrxml").getInputStream());
    //The FillManager delegates to a 'Filler' that have fillReportStart(), fillReportContent() and fillReportEnd() methods
    JasperPrint jrNamePrint = JasperFillManager.fillReport(jrNameReport, params, jrNameDatasource);
    JasperExportManager.exportReportToPdfFile(jrNamePrint, "target/jrNames.pdf");
}
项目:PDFReporter-Studio    文件:PersonBeansDataSource.java   
public JRDataSource create(JasperReport arg0) throws JRException {

    ArrayList<PersonBean> list = new ArrayList<PersonBean>();
    list.add(new PersonBean("Chengan"));
    list.add(new PersonBean("Giulio"));
    list.add(new PersonBean("Slavic"));
    list.add(new PersonBean("Teodor"));

    return new JRBeanCollectionDataSource(list);
}
项目:jaspersoft-studio-midpoint-integration    文件:MidPointRemoteQueryExecutor.java   
@Override
public JRDataSource createDatasource() throws JRException {

    ObjectListType results = null;
    try {
        if (queryString == null && script == null) {
            throw new JRException(
                    "Neither query, nor script defined in the report.");
        }

        if (queryString != null) {
            results = reportPort.processReport(queryString, converToReportParameterType(false), createRawOption());

        } else {
            if (script.contains("AuditEventRecord")) {
                AuditEventRecordListType auditResults = reportPort.evaluateAuditScript(script, converToReportParameterType(true));
                return new JRBeanCollectionDataSource(auditResults.getObject());
            } else {

                RemoteReportParametersType reportParamters = converToReportParameterType(false);
                LOGGER.debug("coverted to report parameters: {}",reportParamters);
                results = reportPort.evaluateScript(script, reportParamters);
            }
        }
    } catch (SchemaException e) {
        throw new JRException(e);
    }
    return new MidPointRemoteDataSource(results.getObject());

}
项目:openimaj    文件:IREvalResult.java   
@Override
public JasperPrint getSummaryReport(String title, String info) throws JRException {
    InputStream inputStream = IREvalResult.class.getResourceAsStream("IREvalSummaryReport.jrxml");
    ArrayList<IREvalResult> list = new ArrayList<IREvalResult>();
    list.add(this);
    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list);

    Map<String, Object> parameters = new HashMap<String, Object>();

    JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
    JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, beanColDataSource);

    return jasperPrint;
}
项目:karaku    文件:KarakuBaseReportAdvanced.java   
@Override
public void generateReport(String path, Map<String, Object> params,
        String type, Map<String, Object> listFilters, List<String> listOrder)
        throws ReportException {

    JRDataSource dataSource = new JRBeanCollectionDataSource(this.getList(
            listFilters, listOrder));
    this.exportReport.exportReportStatic(path, dataSource, params, type);

}
项目:karaku    文件:KarakuBaseReportAdvanced.java   
/**
 * Se utiliza para REPORTES ESTÁTICOS
 * 
 * @param blocks
 * @param params
 * @return
 */

@Override
public void generateReportStatic(String fileReport,
        Map<String, Object> params, String type,
        Map<String, Object> listFilters, List<String> listOrder)
        throws ReportException {

    JRDataSource datasource = new JRBeanCollectionDataSource(this.getList(
            listFilters, listOrder));
    this.exportReport.exportReportStatic(fileReport, datasource, params,
            type);
}
项目:karaku    文件:KarakuBaseReportSimple.java   
@Override
public <T> void generateReport(Map<String, Object> params, String type,
        List<Column> columns, IKarakuBaseLogic<T, ?> logic, Where<T> where,
        Class<T> clazz) throws ReportException {

    JRDataSource datasource = new JRBeanCollectionDataSource(getList(logic,
            where));
    exportReport.exportSimpleReport(columns, clazz, datasource, params,
            type);
}
项目:karaku    文件:KarakuBaseStaticReport.java   
@Override
public <T> void generateReport(String fileReport,
        Map<String, Object> params, String type,
        IKarakuBaseLogic<T, ?> logic, Where<T> where)
        throws ReportException {

    JRDataSource dataSource = new JRBeanCollectionDataSource(getList(logic,
            where));
    exportReport.exportReportStatic(fileReport, dataSource, params, type);
}
项目:karaku    文件:KarakuReportBlockGrid.java   
public JRDataSource buildDataSource(List<Column> columns,
        List<?> listElement) {

    this.columns = columns;

    if (!ListHelper.hasElements(listElement)) {
        return new DRDataSource();
    }

    Object first = listElement.get(0);

    if (first instanceof BaseEntity) {
        return new JRBeanCollectionDataSource(listElement);

    }

    List<String> columnsDataSource = new ArrayList<String>();
    for (Column column : columns) {
        columnsDataSource.add(column.getField());
    }

    DRDataSource ds = new DRDataSource(
            ListHelper.asArray(columnsDataSource));
    for (Object o : listElement) {
        ds.add((Object[]) o);
    }

    return ds;
}
项目:dwoss    文件:DocumentSupporterOperation.java   
private JRDataSource toNormalizedDataSource(Document document) {
    ArrayList<Position> positions = new ArrayList<>();
    for (Position position : document.getPositions().values()) {
        Position p = position;
        String description = position.getDescription().replace("•", " "); // Possible unprintable Character.
        p.setDescription(description);
        positions.add(p);
    }
    return new JRBeanCollectionDataSource(positions);
}