@Test public void tesGetFeatureReader() throws IOException { final InputStream dataStream = TestData.openStream(this, CUBEWERX_GOVUNITCE.DATA); TestHttpResponse httpResponse = new TestHttpResponse("text/xml; subtype=gml/3.1.1", "UTF-8", dataStream); TestHttpProtocol mockHttp = new TestHttpProtocol(httpResponse); createTestProtocol(CUBEWERX_GOVUNITCE.CAPABILITIES, mockHttp); URL describeUrl = TestData.getResource(this, CUBEWERX_GOVUNITCE.SCHEMA); wfs.setDescribeFeatureTypeURLOverride(describeUrl); WFS_1_1_0_DataStore ds = new WFS_1_1_0_DataStore(wfs); DefaultQuery query = new DefaultQuery(CUBEWERX_GOVUNITCE.FEATURETYPENAME); FeatureReader<SimpleFeatureType, SimpleFeature> featureReader; featureReader = ds.getFeatureReader(query, Transaction.AUTO_COMMIT); assertNotNull(featureReader); assertTrue(featureReader.hasNext()); assertNotNull(featureReader.next()); assertTrue(featureReader.hasNext()); assertNotNull(featureReader.next()); assertTrue(featureReader.hasNext()); assertNotNull(featureReader.next()); assertFalse(featureReader.hasNext()); }
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, final Transaction transaction) throws IOException { if (Filter.EXCLUDE.equals(query.getFilter())) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getQueryType(query)); } query = new DefaultQuery(query); Filter[] filters = wfs.splitFilters(query.getFilter()); Filter supportedFilter = filters[0]; Filter postFilter = filters[1]; System.out.println("Supported filter: " + supportedFilter); System.out.println("Unupported filter: " + postFilter); ((DefaultQuery) query).setFilter(supportedFilter); ((DefaultQuery) query).setMaxFeatures(getMaxFeatures(query)); final CoordinateReferenceSystem queryCrs = query.getCoordinateSystem(); WFSResponse response = executeGetFeatures(query, transaction, ResultType.RESULTS); Object result = WFSExtensions.process(this, response); GetFeatureParser parser; if (result instanceof WFSException) { throw (WFSException) result; } else if (result instanceof GetFeatureParser) { parser = (GetFeatureParser) result; } else { throw new IllegalStateException("Unknown response result for GetFeature: " + result); } final SimpleFeatureType contentType = getQueryType(query); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = new WFSFeatureReader((GetFeatureParser) parser); if (!reader.hasNext()) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(contentType); } final SimpleFeatureType readerType = reader.getFeatureType(); CoordinateReferenceSystem readerCrs = readerType.getCoordinateReferenceSystem(); if (queryCrs != null && !queryCrs.equals(readerCrs)) { try { reader = new ReprojectFeatureReader(reader, queryCrs); } catch (Exception e) { throw new DataSourceException(e); } } if (Filter.INCLUDE != postFilter) { reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, postFilter); } if (!contentType.equals(readerType)) { final boolean cloneContents = false; reader = new ReTypeFeatureReader(reader, contentType, cloneContents); } if (this.maxFeaturesHardLimit.intValue() > 0 || query.getMaxFeatures() != Integer.MAX_VALUE) { int maxFeatures = maxFeaturesHardLimit.intValue() > 0 ? Math.min(maxFeaturesHardLimit.intValue(), query.getMaxFeatures()) : query.getMaxFeatures(); reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } return reader; }
WFS_1_1_0_DataStore implements WFSDataStore { public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, final Transaction transaction) throws IOException { if (Filter.EXCLUDE.equals(query.getFilter())) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getQueryType(query)); } query = new DefaultQuery(query); Filter[] filters = wfs.splitFilters(query.getFilter()); Filter supportedFilter = filters[0]; Filter postFilter = filters[1]; System.out.println("Supported filter: " + supportedFilter); System.out.println("Unupported filter: " + postFilter); ((DefaultQuery) query).setFilter(supportedFilter); ((DefaultQuery) query).setMaxFeatures(getMaxFeatures(query)); final CoordinateReferenceSystem queryCrs = query.getCoordinateSystem(); WFSResponse response = executeGetFeatures(query, transaction, ResultType.RESULTS); Object result = WFSExtensions.process(this, response); GetFeatureParser parser; if (result instanceof WFSException) { throw (WFSException) result; } else if (result instanceof GetFeatureParser) { parser = (GetFeatureParser) result; } else { throw new IllegalStateException("Unknown response result for GetFeature: " + result); } final SimpleFeatureType contentType = getQueryType(query); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = new WFSFeatureReader((GetFeatureParser) parser); if (!reader.hasNext()) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(contentType); } final SimpleFeatureType readerType = reader.getFeatureType(); CoordinateReferenceSystem readerCrs = readerType.getCoordinateReferenceSystem(); if (queryCrs != null && !queryCrs.equals(readerCrs)) { try { reader = new ReprojectFeatureReader(reader, queryCrs); } catch (Exception e) { throw new DataSourceException(e); } } if (Filter.INCLUDE != postFilter) { reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, postFilter); } if (!contentType.equals(readerType)) { final boolean cloneContents = false; reader = new ReTypeFeatureReader(reader, contentType, cloneContents); } if (this.maxFeaturesHardLimit.intValue() > 0 || query.getMaxFeatures() != Integer.MAX_VALUE) { int maxFeatures = maxFeaturesHardLimit.intValue() > 0 ? Math.min(maxFeaturesHardLimit.intValue(), query.getMaxFeatures()) : query.getMaxFeatures(); reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } return reader; } }
WFS_1_1_0_DataStore implements WFSDataStore { public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, final Transaction transaction) throws IOException { if (Filter.EXCLUDE.equals(query.getFilter())) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getQueryType(query)); } query = new DefaultQuery(query); Filter[] filters = wfs.splitFilters(query.getFilter()); Filter supportedFilter = filters[0]; Filter postFilter = filters[1]; System.out.println("Supported filter: " + supportedFilter); System.out.println("Unupported filter: " + postFilter); ((DefaultQuery) query).setFilter(supportedFilter); ((DefaultQuery) query).setMaxFeatures(getMaxFeatures(query)); final CoordinateReferenceSystem queryCrs = query.getCoordinateSystem(); WFSResponse response = executeGetFeatures(query, transaction, ResultType.RESULTS); Object result = WFSExtensions.process(this, response); GetFeatureParser parser; if (result instanceof WFSException) { throw (WFSException) result; } else if (result instanceof GetFeatureParser) { parser = (GetFeatureParser) result; } else { throw new IllegalStateException("Unknown response result for GetFeature: " + result); } final SimpleFeatureType contentType = getQueryType(query); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = new WFSFeatureReader((GetFeatureParser) parser); if (!reader.hasNext()) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(contentType); } final SimpleFeatureType readerType = reader.getFeatureType(); CoordinateReferenceSystem readerCrs = readerType.getCoordinateReferenceSystem(); if (queryCrs != null && !queryCrs.equals(readerCrs)) { try { reader = new ReprojectFeatureReader(reader, queryCrs); } catch (Exception e) { throw new DataSourceException(e); } } if (Filter.INCLUDE != postFilter) { reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, postFilter); } if (!contentType.equals(readerType)) { final boolean cloneContents = false; reader = new ReTypeFeatureReader(reader, contentType, cloneContents); } if (this.maxFeaturesHardLimit.intValue() > 0 || query.getMaxFeatures() != Integer.MAX_VALUE) { int maxFeatures = maxFeaturesHardLimit.intValue() > 0 ? Math.min(maxFeaturesHardLimit.intValue(), query.getMaxFeatures()) : query.getMaxFeatures(); reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } return reader; } WFS_1_1_0_DataStore(final WFSProtocol wfs); }
WFS_1_1_0_DataStore implements WFSDataStore { public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, final Transaction transaction) throws IOException { if (Filter.EXCLUDE.equals(query.getFilter())) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getQueryType(query)); } query = new DefaultQuery(query); Filter[] filters = wfs.splitFilters(query.getFilter()); Filter supportedFilter = filters[0]; Filter postFilter = filters[1]; System.out.println("Supported filter: " + supportedFilter); System.out.println("Unupported filter: " + postFilter); ((DefaultQuery) query).setFilter(supportedFilter); ((DefaultQuery) query).setMaxFeatures(getMaxFeatures(query)); final CoordinateReferenceSystem queryCrs = query.getCoordinateSystem(); WFSResponse response = executeGetFeatures(query, transaction, ResultType.RESULTS); Object result = WFSExtensions.process(this, response); GetFeatureParser parser; if (result instanceof WFSException) { throw (WFSException) result; } else if (result instanceof GetFeatureParser) { parser = (GetFeatureParser) result; } else { throw new IllegalStateException("Unknown response result for GetFeature: " + result); } final SimpleFeatureType contentType = getQueryType(query); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = new WFSFeatureReader((GetFeatureParser) parser); if (!reader.hasNext()) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(contentType); } final SimpleFeatureType readerType = reader.getFeatureType(); CoordinateReferenceSystem readerCrs = readerType.getCoordinateReferenceSystem(); if (queryCrs != null && !queryCrs.equals(readerCrs)) { try { reader = new ReprojectFeatureReader(reader, queryCrs); } catch (Exception e) { throw new DataSourceException(e); } } if (Filter.INCLUDE != postFilter) { reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, postFilter); } if (!contentType.equals(readerType)) { final boolean cloneContents = false; reader = new ReTypeFeatureReader(reader, contentType, cloneContents); } if (this.maxFeaturesHardLimit.intValue() > 0 || query.getMaxFeatures() != Integer.MAX_VALUE) { int maxFeatures = maxFeaturesHardLimit.intValue() > 0 ? Math.min(maxFeaturesHardLimit.intValue(), query.getMaxFeatures()) : query.getMaxFeatures(); reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } return reader; } WFS_1_1_0_DataStore(final WFSProtocol wfs); void setMaxFeatures(Integer maxFeatures); Integer getMaxFeatures(); boolean isPreferPostOverGet(); void setPreferPostOverGet(Boolean booleanValue); WFSServiceInfo getInfo(); SimpleFeatureType getSchema(final String prefixedTypeName); SimpleFeatureType getSchema(Name name); List<Name> getNames(); String[] getTypeNames(); void dispose(); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query,
            final Transaction transaction); WFSFeatureSource getFeatureSource(final String typeName); LockingManager getLockingManager(); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Filter filter, Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName,
            Transaction transaction); SimpleFeatureSource getFeatureSource(Name typeName); void updateSchema(Name typeName, SimpleFeatureType featureType); void updateSchema(String typeName, SimpleFeatureType featureType); void createSchema(SimpleFeatureType featureType); QName getFeatureTypeName(String typeName); String getFeatureTypeTitle(String typeName); String getFeatureTypeAbstract(String typeName); ReferencedEnvelope getFeatureTypeWGS84Bounds(String typeName); ReferencedEnvelope getFeatureTypeBounds(String typeName); CoordinateReferenceSystem getFeatureTypeCRS(String typeName); Set<String> getFeatureTypeKeywords(String typeName); URL getDescribeFeatureTypeURL(String typeName); String getServiceAbstract(); Set<String> getServiceKeywords(); URI getServiceProviderUri(); URL getCapabilitiesURL(); String getServiceTitle(); String getServiceVersion(); ReferencedEnvelope getBounds(final Query query); int getCount(final Query query); @Override String toString(); }
WFS_1_1_0_DataStore implements WFSDataStore { public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query, final Transaction transaction) throws IOException { if (Filter.EXCLUDE.equals(query.getFilter())) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(getQueryType(query)); } query = new DefaultQuery(query); Filter[] filters = wfs.splitFilters(query.getFilter()); Filter supportedFilter = filters[0]; Filter postFilter = filters[1]; System.out.println("Supported filter: " + supportedFilter); System.out.println("Unupported filter: " + postFilter); ((DefaultQuery) query).setFilter(supportedFilter); ((DefaultQuery) query).setMaxFeatures(getMaxFeatures(query)); final CoordinateReferenceSystem queryCrs = query.getCoordinateSystem(); WFSResponse response = executeGetFeatures(query, transaction, ResultType.RESULTS); Object result = WFSExtensions.process(this, response); GetFeatureParser parser; if (result instanceof WFSException) { throw (WFSException) result; } else if (result instanceof GetFeatureParser) { parser = (GetFeatureParser) result; } else { throw new IllegalStateException("Unknown response result for GetFeature: " + result); } final SimpleFeatureType contentType = getQueryType(query); FeatureReader<SimpleFeatureType, SimpleFeature> reader; reader = new WFSFeatureReader((GetFeatureParser) parser); if (!reader.hasNext()) { return new EmptyFeatureReader<SimpleFeatureType, SimpleFeature>(contentType); } final SimpleFeatureType readerType = reader.getFeatureType(); CoordinateReferenceSystem readerCrs = readerType.getCoordinateReferenceSystem(); if (queryCrs != null && !queryCrs.equals(readerCrs)) { try { reader = new ReprojectFeatureReader(reader, queryCrs); } catch (Exception e) { throw new DataSourceException(e); } } if (Filter.INCLUDE != postFilter) { reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, postFilter); } if (!contentType.equals(readerType)) { final boolean cloneContents = false; reader = new ReTypeFeatureReader(reader, contentType, cloneContents); } if (this.maxFeaturesHardLimit.intValue() > 0 || query.getMaxFeatures() != Integer.MAX_VALUE) { int maxFeatures = maxFeaturesHardLimit.intValue() > 0 ? Math.min(maxFeaturesHardLimit.intValue(), query.getMaxFeatures()) : query.getMaxFeatures(); reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures); } return reader; } WFS_1_1_0_DataStore(final WFSProtocol wfs); void setMaxFeatures(Integer maxFeatures); Integer getMaxFeatures(); boolean isPreferPostOverGet(); void setPreferPostOverGet(Boolean booleanValue); WFSServiceInfo getInfo(); SimpleFeatureType getSchema(final String prefixedTypeName); SimpleFeatureType getSchema(Name name); List<Name> getNames(); String[] getTypeNames(); void dispose(); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(Query query,
            final Transaction transaction); WFSFeatureSource getFeatureSource(final String typeName); LockingManager getLockingManager(); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Filter filter, Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(String typeName,
            Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(String typeName,
            Transaction transaction); SimpleFeatureSource getFeatureSource(Name typeName); void updateSchema(Name typeName, SimpleFeatureType featureType); void updateSchema(String typeName, SimpleFeatureType featureType); void createSchema(SimpleFeatureType featureType); QName getFeatureTypeName(String typeName); String getFeatureTypeTitle(String typeName); String getFeatureTypeAbstract(String typeName); ReferencedEnvelope getFeatureTypeWGS84Bounds(String typeName); ReferencedEnvelope getFeatureTypeBounds(String typeName); CoordinateReferenceSystem getFeatureTypeCRS(String typeName); Set<String> getFeatureTypeKeywords(String typeName); URL getDescribeFeatureTypeURL(String typeName); String getServiceAbstract(); Set<String> getServiceKeywords(); URI getServiceProviderUri(); URL getCapabilitiesURL(); String getServiceTitle(); String getServiceVersion(); ReferencedEnvelope getBounds(final Query query); int getCount(final Query query); @Override String toString();  }