QueryAnalyzer { public QueryAnalyzer( List<org.deegree.protocol.wfs.query.Query> wfsQueries, WebFeatureService controller, WfsFeatureStoreManager service, boolean checkInputDomain ) throws OWSException { this.controller = controller; this.service = service; this.checkAreaOfUse = checkInputDomain; if ( wfsQueries.isEmpty() ) { String msg = "Either the typeName parameter must be present or the query must provide feature ids."; throw new OWSException( msg, INVALID_PARAMETER_VALUE, "typeName" ); } List<Pair<AdHocQuery, org.deegree.protocol.wfs.query.Query>> adHocQueries = convertStoredQueries( wfsQueries ); Query[] queries = new Query[adHocQueries.size()]; for ( int i = 0; i < adHocQueries.size(); i++ ) { AdHocQuery wfsQuery = adHocQueries.get( i ).first; Query query = validateQuery( wfsQuery ); queries[i] = query; queryToWFSQuery.put( query, adHocQueries.get( i ).second ); if ( wfsQuery.getSrsName() != null ) { requestedCrs = wfsQuery.getSrsName(); } else { requestedCrs = controller.getDefaultQueryCrs(); } if ( wfsQuery.getProjectionClauses() != null ) { for ( TypeName typeName : wfsQuery.getTypeNames() ) { QName bestMatch = findBestMatchingFeatureTypeName( typeName ); this.projections.put( bestMatch, Arrays.asList( wfsQuery.getProjectionClauses() ) ); } } } for ( Query query : queries ) { if ( query.getTypeNames().length == 0 ) { for ( FeatureStore fs : service.getStores() ) { List<Query> fsQueries = fsToQueries.get( fs ); if ( fsQueries == null ) { fsQueries = new ArrayList<Query>(); fsToQueries.put( fs, fsQueries ); } fsQueries.add( query ); } } else { FeatureStore fs = service.getStore( query.getTypeNames()[0].getFeatureTypeName() ); List<Query> fsQueries = fsToQueries.get( fs ); if ( fsQueries == null ) { fsQueries = new ArrayList<Query>(); fsToQueries.put( fs, fsQueries ); } fsQueries.add( query ); } } } QueryAnalyzer( List<org.deegree.protocol.wfs.query.Query> wfsQueries, WebFeatureService controller,
                          WfsFeatureStoreManager service, boolean checkInputDomain ); Collection<FeatureType> getFeatureTypes(); Map<FeatureStore, List<Query>> getQueries(); org.deegree.protocol.wfs.query.Query getQuery( Query query ); ICRS getRequestedCRS(); Map<QName, List<ProjectionClause>> getProjections();  }
@Test public void testQueryAnalyzer() throws Exception { List<org.deegree.protocol.wfs.query.Query> wfsQueries = createQueries(); WebFeatureService controller = mockController(); WfsFeatureStoreManager manager = mockManager(); QueryAnalyzer queryAnalyzer = new QueryAnalyzer( wfsQueries, controller, manager, false ); Map<FeatureStore, List<Query>> queries = queryAnalyzer.getQueries(); assertThat( queries.size(), is( 1 ) ); assertThat( queries.values().iterator().next().size(), is( 2 ) ); Map<QName, List<ProjectionClause>> projections = queryAnalyzer.getProjections(); assertThat( projections.size(), is( 2 ) ); assertThat( projections.get( FEATURETYPE_CP ).size(), is( 2 ) ); assertThat( projections.get( FEATURETYPE_AU ).size(), is( 1 ) ); }