@Override public void afterGroupInit(String groupName) throws JRScriptletException { String allCities = (String)this.getVariableValue("AllCities"); String city = (String)this.getFieldValue("City"); StringBuilder sb = new StringBuilder(); if (allCities != null) { sb.append(allCities); sb.append(", "); } sb.append(city); this.setVariableValue("AllCities", sb.toString()); }
/** * */ public void afterGroupInit(String groupName) throws JRScriptletException { String allCities = (String)this.getVariableValue("AllCities"); String city = (String)this.getFieldValue("City"); StringBuilder sb = new StringBuilder(); if (allCities != null) { sb.append(allCities); sb.append(", "); } sb.append(city); this.setVariableValue("AllCities", sb.toString()); }
@Override public void afterGroupInit(String groupName) throws JRScriptletException { if (groupName.equals("CityGroup")) { System.out.println("call afterGroupInit : City = " + this.getFieldValue("City")); String allCities = (String)this.getVariableValue("AllCities"); String city = (String)this.getFieldValue("City"); StringBuilder sb = new StringBuilder(); if (allCities != null) { sb.append(allCities); sb.append(", "); } sb.append(city); this.setVariableValue("AllCities", sb.toString()); } }
/** * */ public void afterGroupInit(String groupName) throws JRScriptletException { if (groupName.equals("CityGroup")) { System.out.println("call afterGroupInit : City = " + this.getFieldValue("City")); String allCities = (String)this.getVariableValue("AllCities"); String city = (String)this.getFieldValue("City"); StringBuffer sbuffer = new StringBuffer(); if (allCities != null) { sbuffer.append(allCities); sbuffer.append(", "); } sbuffer.append(city); this.setVariableValue("AllCities", sbuffer.toString()); } }
@Override public void afterDetailEval() throws JRScriptletException { if(columns==null){ columns=(List<String>) getParameterValue(PARAM_COLUMNS); } if(listeners==null){ listeners=(List<DatasetReaderListener>) getParameterValue(PARAM_LISTENERS); } Object[] record=new Object[columns.size()]; int i=0; for(String col : columns){ record[i++]=getFieldValue(col); } for(DatasetReaderListener l : listeners){ if(!l.isValidStatus()){ // This "dirty" solution will stop report running throw new DataPreviewInterruptedException(Messages.DataPreviewScriptlet_InterruptErrorMsg); } l.newRecord(record); } super.afterDetailEval(); }
@Override public void afterReportInit() throws JRScriptletException { try { XYChart xyChart = new XYChartBuilder() .width(515) .height(400) .title("Fruits Order") .xAxisTitle("Day of Week") .yAxisTitle("Quantity (t)") .build(); xyChart.addSeries("Apples", new double[] { 1, 3, 5}, new double[] {4, 10, 7}); xyChart.addSeries("Bananas", new double[] { 1, 2, 3, 4, 5}, new double[] {6, 8, 4, 4, 6}); xyChart.addSeries("Cherries", new double[] { 1, 3, 4, 5}, new double[] {2, 6, 1, 9}); XYStyler styler = xyChart.getStyler(); styler.setLegendPosition(Styler.LegendPosition.InsideNW); styler.setAxisTitlesVisible(true); styler.setDefaultSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Area); styler.setChartBackgroundColor(Color.WHITE); BufferedImage bufferedImage = BitmapEncoder.getBufferedImage(xyChart); super.setVariableValue("ChartImage", bufferedImage); } catch(Exception e) { throw new JRScriptletException(e); } }
@Override public void afterReportInit() throws JRScriptletException { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Java", new Double(43.2)); dataset.setValue("Visual Basic", new Double(10.0)); dataset.setValue("C/C++", new Double(17.5)); dataset.setValue("PHP", new Double(32.5)); dataset.setValue("Perl", new Double(1.0)); JFreeChart chart = ChartFactory.createPieChart3D( "Pie Chart 3D Demo 1", dataset, true, true, false ); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); /* */ this.setVariableValue("Chart", new JCommonDrawableRendererImpl(chart)); }
@Override public void beforeGroupInit(String groupName) throws JRScriptletException { if (groupName.equals("CityGroup")) { System.out.println("call beforeGroupInit : City = " + this.getFieldValue("City")); } }
@Override public void beforeReportInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().beforeReportInit(); } }
@Override public void afterReportInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().afterReportInit(); } }
@Override public void beforePageInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().beforePageInit(); } }
@Override public void afterPageInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().afterPageInit(); } }
@Override public void beforeColumnInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().beforeColumnInit(); } }
@Override public void afterColumnInit() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().afterColumnInit(); } }
@Override public void beforeGroupInit(String groupName) throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().beforeGroupInit(groupName); } }
@Override public void afterGroupInit(String groupName) throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().afterGroupInit(groupName); } }
@Override public void beforeDetailEval() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().beforeDetailEval(); } }
@Override public void afterDetailEval() throws JRScriptletException { for(Iterator<JRAbstractScriptlet> it = dataset.scriptlets.iterator(); it.hasNext();) { it.next().afterDetailEval(); } }
@Override protected void detail() throws JRScriptletException, JRException { super.detail(); List<RecordField> recordFields = sortInfo.getRecordFields(); int fieldCount = recordFields.size(); Object[] record = new Object[fieldCount]; int index = 0; for (RecordField recordField : recordFields) { Object value; if (recordField.isVariable()) { value = dataset.getVariableValue(recordField.getName()); } else { value = dataset.getFieldValue(recordField.getName()); } record[index] = value; ++index; } // also store the original record index SortRecord sortRecord = new SortedDataSource.SortRecord(record, recordIndex); ++recordIndex; records.add(sortRecord); }
protected void group() throws JRException, JRScriptletException { dataset.calculator.estimateGroupRuptures(); dataset.delegateScriptlet.callBeforeGroupInit(); dataset.calculator.initializeVariables(ResetTypeEnum.GROUP, IncrementTypeEnum.GROUP); dataset.delegateScriptlet.callAfterGroupInit(); }
@Override public void beforeDetailEval() throws JRScriptletException { long ellapsedTime = System.currentTimeMillis() - startTime; if (timeout < ellapsedTime) { throw new TimeoutGovernorException( ((JasperReport)getParameterValue(JRParameter.JASPER_REPORT, false)).getName(), timeout ); } }
@Override public void afterPageInit() throws JRScriptletException { // cannot use PAGE_NUMBER variable because of timing issues and because of isResetPageNumber flag pages++; if (maxPages < pages) { throw new MaxPagesGovernorException( ((JasperReport)getParameterValue(JRParameter.JASPER_REPORT, false)).getName(), maxPages ); } }
/** * */ public void beforeGroupInit(String groupName) throws JRScriptletException { if (groupName.equals("CityGroup")) { System.out.println("call beforeGroupInit : City = " + this.getFieldValue("City")); } }
private void setServerTimeZone () throws JRScriptletException { this.setVariableValue("serverTimeZone", TimeZone.getDefault().getDisplayName().toString() + " - " + TimeZone.getDefault().getID().toString() ); }
@SuppressWarnings("unchecked") private void setListOfVirtualSensors () throws JRScriptletException { Collection<VirtualSensor> virtualSensors = (Collection<VirtualSensor>) this.getFieldValue("virtualSensors"); StringBuilder sb = new StringBuilder () ; Iterator iter = (Iterator) virtualSensors.iterator(); String nextName; while (iter.hasNext()) { nextName = ((VirtualSensor)iter.next()).getVirtualSensorName(); sb.append(nextName); if (iter.hasNext()) sb.append(", ") ; } this.setVariableValue("listOfVirtualSensors", sb.toString()); }
private JasperCustomValues getCustomValues() { try { return (JasperCustomValues) getParameterValue(JasperCustomValues.NAME, false); } catch (JRScriptletException e) { throw new JasperDesignException("Custom values not found", e); } }
@Override public void afterReportInit() throws JRScriptletException { super.afterReportInit(); JasperCustomValues customValues = getCustomValues(); if (customValues != null) { customValues.setJasperScriptlet(this); } }
private JasperReportParameters getReportParameters() { if (reportParameters == null) { try { reportParameters = ((JasperScriptlet) getParameterValue(JasperScriptlet.SCRIPTLET_NAME)).getReportParameters(); } catch (JRScriptletException e) { } } return reportParameters; }
@Override @SuppressWarnings("unchecked") public <T> T getFieldValue(String name) { try { return (T) jasperScriptlet.getFieldValue(name); } catch (JRScriptletException e) { throw new DRReportException(e); } }
@Override @SuppressWarnings("unchecked") public <T> T getVariableValue(String name) { try { return (T) jasperScriptlet.getVariableValue(name); } catch (JRScriptletException e) { throw new DRReportException(e); } }
@Override @SuppressWarnings("unchecked") public <T> T getParameterValue(String name) { try { return (T) ((Map<?, ?>) jasperScriptlet.getParameterValue(JRParameter.REPORT_PARAMETERS_MAP)).get(name); } catch (JRScriptletException e) { throw new DRReportException(e); } }
@Override public void afterReportInit() throws JRScriptletException { super.afterReportInit(); JasperCustomValues customValues = getCustomValues(); if (customValues != null && customValues.getStartPageNumber() != null) { setVariableValue(JRVariable.PAGE_NUMBER, customValues.getStartPageNumber()); } }
@Override public void beforeDetailEval() throws JRScriptletException { super.beforeDetailEval(); dynamicSubreport = report(); dynamicSubreport .setPageFormat(515, PageType.A4.getHeight(), PageOrientation.PORTRAIT) .setPageMargin(margin(0)) .columns( col.column("Column1", "field1", type.stringType()), col.column("Column2", "field2", type.integerType())) .title(cmp.text("dynamic subreport")); }
@Override public void beforeDetailEval() throws JRScriptletException { super.beforeDetailEval(); dynamicSubreport = report(); dynamicSubreport .setTemplate(Templates.reportTemplate) .setPageFormat(515, PageType.A4.getHeight(), PageOrientation.PORTRAIT) .setPageMargin(margin(0)) .columns( col.column("Item", "item", type.stringType()), col.column("Quantity", "quantity", type.integerType()), col.column("Unit price", "unitprice", type.integerType())) .title(cmp.text("Dynamic subreport").setStyle(Templates.bold12CenteredStyle)); }
/** * */ public String hello() throws JRScriptletException { return "Hello! I'm the report's scriptlet object."; }
@Override public void beforeReportInit() throws JRScriptletException { System.out.println("call beforeReportInit"); }
@Override public void afterReportInit() throws JRScriptletException { System.out.println("call afterReportInit"); }
@Override public void beforePageInit() throws JRScriptletException { System.out.println("call beforePageInit : PAGE_NUMBER = " + this.getVariableValue("PAGE_NUMBER")); }