ImageContentProvider extends AbstractJrxmlContentProvider { @Override public void inspectInputParametersFromJrxml( Map<String, ParameterDescription> parameterDescriptions, List<JAXBElement<? extends ProcessletInputDefinition>> inputs, XMLAdapter jrxmlAdapter, Map<String, String> parameters, List<String> handledParameters ) { OMElement root = jrxmlAdapter.getRootElement(); for ( String parameterName : parameters.keySet() ) { if ( !handledParameters.contains( parameterName ) && jrxmlAdapter.getElement( root, new XPath( ". + parameterName + "}']", JrxmlUtils.nsContext ) ) != null ) { ComplexInputDefinition comp = new ComplexInputDefinition(); addInput( comp, parameterDescriptions, parameterName, 1, 0 ); ComplexFormatType defaultFormat = new ComplexFormatType(); defaultFormat.setMimeType( "image/png" ); comp.setDefaultFormat( defaultFormat ); inputs.add( new JAXBElement<ComplexInputDefinition>( new QName( "ProcessInput" ), ComplexInputDefinition.class, comp ) ); handledParameters.add( parameterName ); } } } ImageContentProvider( Workspace workspace ); @Override void inspectInputParametersFromJrxml( Map<String, ParameterDescription> parameterDescriptions,
                                                 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() { ImageContentProvider imgContentProvider = new ImageContentProvider( null ); Map<String, String> parameters = new HashMap<String, String>(); parameters.put( "DATE", "java.util.Date" ); parameters.put( "DESCRIPTION", "java.lang.String" ); parameters.put( "MAPSCALE", "java.lang.Integer" ); parameters.put( "printOptTxt", "java.lang.Boolean" ); parameters.put( "mapMAP_img", "java.lang.String" ); parameters.put( "mapMAP_legend", "java.lang.String" ); List<JAXBElement<? extends ProcessletInputDefinition>> inputs = new ArrayList<JAXBElement<? extends ProcessletInputDefinition>>(); XMLAdapter adapter = new XMLAdapter( TestOtherContentProviderTest.class.getResourceAsStream( "../testWPSreportTemplate.jrxml" ) ); List<String> handledParams = new ArrayList<String>(); imgContentProvider.inspectInputParametersFromJrxml( new HashMap<String, ParameterDescription>(), inputs, adapter, parameters, handledParams ); assertEquals( 6, parameters.size() ); assertEquals( 2, handledParams.size() ); assertEquals( 2, inputs.size() ); JAXBElement<? extends ProcessletInputDefinition> imgUrl = null; JAXBElement<? extends ProcessletInputDefinition> imgBin = null; for ( JAXBElement<? extends ProcessletInputDefinition> in : inputs ) { if ( "mapMAP_img".equals( in.getValue().getIdentifier().getValue() ) ) { imgUrl = in; } else if ( "mapMAP_legend".equals( in.getValue().getIdentifier().getValue() ) ) { imgBin = in; } } assertNotNull( imgUrl ); assertNotNull( imgBin ); assertTrue( imgUrl.getDeclaredType() == ComplexInputDefinition.class ); assertTrue( imgBin.getDeclaredType() == ComplexInputDefinition.class ); assertEquals( "image/png", ( ( (ComplexInputDefinition) imgUrl.getValue() ).getDefaultFormat().getMimeType() ) ); assertEquals( 0, ( ( (ComplexInputDefinition) imgUrl.getValue() ).getOtherFormats().size() ) ); }