@Override void add(final List<Map<String, ?>> rows, final Values values, final Source source) throws JRException { JRDataSource dataSource = values.getObject(source.key, JRDataSource.class); Assert.isTrue( dataSource != null, "The Datasource object referenced by key: " + source.key + " does not exist. Check" + " that the key is correctly spelled in the config.yaml file.\n\t This is one of the" + " sources for the !mergeDataSources."); JRDesignField jrField = new JRDesignField(); while (dataSource.next()) { Map<String, Object> row = Maps.newHashMap(); for (Map.Entry<String, String> field : source.fields.entrySet()) { jrField.setName(field.getKey()); row.put(field.getValue(), dataSource.getFieldValue(jrField)); } rows.add(row); } }
protected void setOldValues() throws JRException { if (fields != null && fields.length > 0) { for (int i = 0; i < fields.length; i++) { JRFillField field = fields[i]; field.setPreviousOldValue(field.getOldValue()); field.setOldValue(field.getValue()); field.setValue(dataSource.getFieldValue(field)); } } if (variables != null && variables.length > 0) { for (int i = 0; i < variables.length; i++) { JRFillVariable variable = variables[i]; variable.setPreviousOldValue(variable.getOldValue()); variable.setOldValue(variable.getValue()); } } }
protected boolean advanceDataSource() throws JRException { boolean hasNext; hasNext = (reportMaxCount == null || reportMaxCount.intValue() > reportCount) && dataSource.next(); return hasNext; }