SubreportContentProvider extends AbstractJrxmlContentProvider { @Override public void inspectInputParametersFromJrxml( Map<String, ParameterDescription> parameterDescription, List<JAXBElement<? extends ProcessletInputDefinition>> inputs, XMLAdapter jrxmlAdapter, Map<String, String> parameters, List<String> handledParameters ) { if ( parameters.containsKey( getDirParameter() ) && !handledParameters.contains( getDirParameter() ) && jrxmlAdapter.getNode( jrxmlAdapter.getRootElement(), new XPath( ". + getDirParameter() + "}'", nsContext ) ) != null ) { LOG.debug( "Found subreport for '{}'", parameterPrefix ); XMLAdapter subreportAdapter = new XMLAdapter( subreportJrxml ); List<OMElement> paramElements = subreportAdapter.getElements( subreportAdapter.getRootElement(), new XPath( "/jasper:jasperReport/jasper:parameter", nsContext ) ); for ( OMElement paramElement : paramElements ) { String paramName = paramElement.getAttributeValue( new QName( "name" ) ); String paramType = paramElement.getAttributeValue( new QName( "class" ) ); LOG.debug( "Found subreport parameter '{}', type {}", paramName, paramType ); subreportParameters.put( paramName, paramType ); } String datasourceParam = parameters.get( getDatasourceParameter() ); if ( datasourceParam != null ) { handledParameters.add( getDatasourceParameter() ); subreportParameters.put( getDatasourceParameter(), datasourceParam ); } List<String> handledSubreportParameters = new ArrayList<String>(); for ( JrxmlContentProvider contentProvider : getContentProviders( datasourceParam ) ) { contentProvider.inspectInputParametersFromJrxml( parameterDescription, inputs, subreportAdapter, subreportParameters, handledSubreportParameters ); } handledParameters.add( getDirParameter() ); } } SubreportContentProvider( Workspace workspace, String parameterName, URL url, ResourceBundle resourceBundle ); @Override void inspectInputParametersFromJrxml( Map<String, ParameterDescription> parameterDescription,
                                                 List<JAXBElement<? extends ProcessletInputDefinition>> inputs,
                                                 XMLAdapter jrxmlAdapter, Map<String, String> parameters,
                                                 List<String> handledParameters ); @Override Pair<InputStream, Boolean> prepareJrxmlAndReadInputParameters( InputStream jrxml,
                                                                          Map<String, Object> params,
                                                                          ProcessletInputs in,
                                                                          List<CodeType> processedIds,
                                                                          Map<String, String> parameters );  }
@Test public void testInspectInputParametersFromJrxml() { Map<String, String> parameters = new HashMap<String, String>(); parameters.put( "SUBREPORT_dir", "java.lang.String" ); parameters.put( "SUBREPORT_datasource", "net.sf.jasperreports.engine.JRDataSource" ); List<JAXBElement<? extends ProcessletInputDefinition>> inputs = new ArrayList<JAXBElement<? extends ProcessletInputDefinition>>(); XMLAdapter jrxmlAdapter = new XMLAdapter( TestOtherContentProviderTest.class.getResourceAsStream( "../templateWithInlineTable.jrxml" ) ); List<String> handledParameters = new ArrayList<String>(); subreportContentProvider.inspectInputParametersFromJrxml( new HashMap<String, ParameterDescription>(), inputs, jrxmlAdapter, parameters, handledParameters ); assertEquals( 2, handledParameters.size() ); assertEquals( 3, inputs.size() ); }