protected BandData loadBandData(Report report, Map<String, Object> handledParams) { BandData rootBand = new BandData(BandData.ROOT_BAND_NAME); rootBand.setData(new HashMap<>(handledParams)); rootBand.addReportFieldFormats(report.getReportFieldFormats()); rootBand.setFirstLevelBandDefinitionNames(new HashSet<>()); dataExtractor.extractData(report, handledParams, rootBand); return rootBand; }
protected BandData loadBandData(Report report, Map<String, Object> handledParams) { BandData rootBand = new BandData(BandData.ROOT_BAND_NAME); rootBand.setData(new HashMap<>(handledParams)); rootBand.addReportFieldFormats(report.getReportFieldFormats()); rootBand.setFirstLevelBandDefinitionNames(new HashSet<>()); dataExtractor.extractData(report, handledParams, rootBand); return rootBand; }
protected void writeValueFormats(Report report, Element root) { Element reportTemplatesElement = root.addElement("formats"); for (ReportFieldFormat reportFieldFormat : report.getReportFieldFormats()) { Element reportTemplateElement = reportTemplatesElement.addElement("format"); reportTemplateElement.addAttribute("name", reportFieldFormat.getName()); reportTemplateElement.addAttribute("format", reportFieldFormat.getFormat()); } }
protected void writeValueFormats(Report report, Element root) { Element reportTemplatesElement = root.addElement("formats"); for (ReportFieldFormat reportFieldFormat : report.getReportFieldFormats()) { Element reportTemplateElement = reportTemplatesElement.addElement("format"); reportTemplateElement.addAttribute("name", reportFieldFormat.getName()); reportTemplateElement.addAttribute("format", reportFieldFormat.getFormat()); } }
@Test public void stressTest() throws IOException, URISyntaxException { int queries = 100; int recordsPerQuery = 10000; Report report = createReport(queries, recordsPerQuery); BandData rootBand = new BandData(BandData.ROOT_BAND_NAME); rootBand.setData(new HashMap<>()); rootBand.addReportFieldFormats(report.getReportFieldFormats()); rootBand.setFirstLevelBandDefinitionNames(new HashSet<>()); long start = System.currentTimeMillis(); try { new DataExtractorImpl(new DefaultLoaderFactory().setGroovyDataLoader( new GroovyDataLoader(new DefaultScriptingImpl()))).extractData(report, new HashMap<>(), rootBand); } finally { System.out.println( String.format("Report processing stress test (%d queries and %d records per query) took %d ms", queries, recordsPerQuery, System.currentTimeMillis() - start) ); } }
@Test public void testDataLinkage() { Report report = createReport(); BandData rootBand = new BandData(BandData.ROOT_BAND_NAME); rootBand.setData(new HashMap<>()); rootBand.addReportFieldFormats(report.getReportFieldFormats()); rootBand.setFirstLevelBandDefinitionNames(new HashSet<>()); new DataExtractorImpl(new DefaultLoaderFactory().setGroovyDataLoader( new GroovyDataLoader(new DefaultScriptingImpl()))).extractData(report, new HashMap<>(), rootBand); List<BandData> bands = rootBand.getChildrenByName("Band1"); for (BandData band : bands) { if (((Integer)1).equals(band.getParameterValue("link"))) { Assert.assertEquals(1, band.getParameterValue("col1")); Assert.assertEquals(10, band.getParameterValue("col2")); Assert.assertEquals(100, band.getParameterValue("col3")); } else if (((Integer)2).equals(band.getParameterValue("link"))) { Assert.assertEquals(2, band.getParameterValue("col1")); Assert.assertEquals(20, band.getParameterValue("col2")); Assert.assertEquals(200, band.getParameterValue("col3")); } } }