MapContentProvider extends AbstractJrxmlContentProvider { @Override public void inspectInputParametersFromJrxml( Map<String, ParameterDescription> parameterDescriptions, List<JAXBElement<? extends ProcessletInputDefinition>> inputs, XMLAdapter jrxmlAdapter, Map<String, String> parameters, List<String> handledParameters ) { Map<String, Pair<Integer, Integer>> mapIds = new HashMap<String, Pair<Integer, Integer>>(); for ( String parameterName : parameters.keySet() ) { if ( !handledParameters.contains( parameterName ) ) { if ( isMapParameter( parameterName ) ) { String mapId = getIdentifierFromParameter( parameterName ); OMElement imgElement = jrxmlAdapter.getElement( jrxmlAdapter.getRootElement(), new XPath( ". + parameterName + "}']/jasper:reportElement", JrxmlUtils.nsContext ) ); if ( imgElement != null ) { if ( parameterName.endsWith( SUFFIXES.MAP_SUFFIX.text ) ) { if ( !mapIds.containsKey( mapId ) ) { int width = jrxmlAdapter.getRequiredNodeAsInteger( imgElement, new XPath( "@width", nsContext ) ); int height = jrxmlAdapter.getRequiredNodeAsInteger( imgElement, new XPath( "@height", nsContext ) ); mapIds.put( mapId, new Pair<Integer, Integer>( width, height ) ); } } } if ( !mapIds.containsKey( mapId ) ) { mapIds.put( mapId, null ); } handledParameters.add( parameterName ); } } } for ( String mapId : mapIds.keySet() ) { LOG.debug( "Found map component with id " + mapId ); ComplexInputDefinition comp = new ComplexInputDefinition(); addInput( comp, parameterDescriptions, mapId, 1, 0 ); ComplexFormatType format = new ComplexFormatType(); format.setEncoding( "UTF-8" ); format.setMimeType( MIME_TYPE ); format.setSchema( SCHEMA ); comp.setDefaultFormat( format ); inputs.add( new JAXBElement<ComplexInputDefinition>( new QName( "ProcessInput" ), ComplexInputDefinition.class, comp ) ); } } MapContentProvider( 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 ); static final double INCH2M; }
@Test public void testInspectInputParametersFromJrxml() { MapContentProvider wmsContentProvider = getProvider(); Map<String, String> parameters = new HashMap<String, String>(); parameters.put( "mapMAP_img", "java.lang.String" ); parameters.put( "mapMAP_legend", "java.lang.String" ); parameters.put( "LEGEND", "java.lang.String" ); List<JAXBElement<? extends ProcessletInputDefinition>> inputs = new ArrayList<JAXBElement<? extends ProcessletInputDefinition>>(); XMLAdapter adapter = new XMLAdapter( TestMapContentProviderTest.class.getResourceAsStream( "../../testWPSreportTemplate.jrxml" ) ); List<String> handledParams = new ArrayList<String>(); wmsContentProvider.inspectInputParametersFromJrxml( new HashMap<String, ParameterDescription>(), inputs, adapter, parameters, handledParams ); assertEquals( 3, parameters.size() ); assertEquals( 2, handledParams.size() ); assertEquals( 1, inputs.size() ); assertEquals( "MAP", inputs.get( 0 ).getValue().getIdentifier().getValue() ); }