public void rewind() throws JRException { if (dataSource != null) { if (dataSource instanceof JRRewindableDataSource) { if (log.isDebugEnabled()) { log.debug("Rewinding the list data source"); } ((JRRewindableDataSource) dataSource).moveFirst(); } else { log.warn("Cannot rewind list data source as it is not a JRRewindableDataSource"); } } }
@Test public void testManyToOneAttribute() throws Exception { List<InternalFeature> features = service.getFeatures(LAYER_BEANS, geoService.getCrs2("EPSG:4326"), null, null, GeomajasConstant.FEATURE_INCLUDE_ALL); JRRewindableDataSource data = new InternalFeatureDataSource(features); data.moveFirst(); JRField stringAttribute = createField("stringAttr", String.class); JRField many2OneString = createField("manyToOneAttr.stringAttr", String.class); int index = 0; while (index < features.size()) { Assert.assertTrue(data.next()); InternalFeature feature = features.get(index++); Assert.assertEquals(feature.getAttributes().get("stringAttr").getValue(), data.getFieldValue(stringAttribute)); ManyToOneAttribute manyToOne = (ManyToOneAttribute) feature.getAttributes().get("manyToOneAttr"); if (null != manyToOne.getValue()) { Assert.assertEquals(manyToOne.getValue().getAttributeValue("stringAttr"), data.getFieldValue(many2OneString)); } else { Assert.assertEquals(null, data.getFieldValue(many2OneString)); } } }
public JasperReportBuilder rebuild() throws DRException { builded = false; reportDesign = null; jasperDesign = null; jasperReport = null; parameters = null; jasperPrint = null; if (dataSource != null && dataSource instanceof JRRewindableDataSource) { try { ((JRRewindableDataSource) dataSource).moveFirst(); } catch (JRException e) { throw new DRException(e); } } return this; }
@Override public void rewind() throws JRException { if (subreportFiller == null) { return; } cancelSubreportFill(); initSubreportFiller(null);//FIXME used cached evaluator if (getConnectionExpression() == null && dataSource != null) { if(dataSource instanceof JRRewindableDataSource) { ((JRRewindableDataSource) dataSource).moveFirst(); } else { // if (log.isWarnEnabled()) // log.warn("The subreport is placed on a non-splitting band, but it does not have a rewindable data source."); throw new JRException( EXCEPTION_MESSAGE_KEY_NO_REWINDABLE_DATA_SOURCE, (Object[])null ); } } }
@Override public JRRewindableDataSource getSubreportDatasource(String table, String[] matchfields, Object[] keyValues) { // find table ODLTableReadOnly tableObj= TableUtils.findTable(ds, table); if(tableObj==null){ throw new RuntimeException("Cannot find table referenced in subreport: " + table); } return new FilteredReportDatasource(tableObj, matchfields, keyValues,continueCb); }
@Override public JRDataSource evaluate(ReportParameters reportParameters) { if (moveFirst && dataSource != null && dataSource instanceof JRRewindableDataSource) { try { ((JRRewindableDataSource) dataSource).moveFirst(); } catch (JRException e) { } } moveFirst = true; return dataSource; }
@Override public JRRewindableDataSource getSubreportDatasource(String table) { return getSubreportDatasource(table, new String[]{}, new Object[]{}); }
@Override public JRRewindableDataSource getSubreportDatasource(String table, String matchfield, Object keyValue) { return getSubreportDatasource(table, new String[]{matchfield}, new Object[]{keyValue}); }
JRRewindableDataSource getSubreportDatasource(String table);
JRRewindableDataSource getSubreportDatasource(String table,String matchfield, Object keyValue);
JRRewindableDataSource getSubreportDatasource(String table,String matchfields[], Object []keyValues);