@Test public void testSplitFilters() throws IOException, ServiceException { String baseDirectory = "GeoServer_2.2.x/2.0.0/"; URL urlCap = url(baseDirectory + "/GetCapabilities.xml"); HTTPResponse httpResp = new TestHttpResponse("text/xml", "UTF-8", urlCap); EntityResolver resolver = null; WFSGetCapabilities capabilities = new GetCapabilitiesResponse(httpResp, resolver).getCapabilities(); WFSStrategy strategy = new StrictWFS_2_0_Strategy(); strategy.setCapabilities(capabilities); WFSConfig config = new WFSConfig(); GetFeatureRequest request = new GetFeatureRequest(config, strategy); final QName typeName = request.getTypeName(); org.opengis.filter.expression.Expression expr = new LiteralExpressionImpl("searchedproperty"); String pattern = "value*"; String wildcardMulti = "*"; String wildcardSingle = "?"; String escape = "\\"; Filter filter = new LikeFilterImpl(expr, pattern, wildcardMulti, wildcardSingle, escape); Filter[] filters = strategy.splitFilters(typeName, filter); Assert.assertNotNull(filters); Assert.assertEquals(2, filters.length); Assert.assertTrue(filters[0].evaluate(filter)); }
@Override public Filter[] splitFilters(QName typeName, Filter filter) { FilterCapabilities filterCapabilities = getFilterCapabilities(); Capabilities filterCaps = new Capabilities(); if (filterCapabilities != null) { filterCaps.addAll(filterCapabilities); if (Versions.v1_0_0.equals(getServiceVersion())) { SpatialCapabilities spatialCaps = filterCapabilities.getSpatialCapabilities(); if (spatialCaps != null) { SpatialOperators spatialOps = spatialCaps.getSpatialOperators(); if (spatialOps != null) { if (null != spatialOps.getOperator("Intersect")) { trace( "WFS 1.0 capabilities states the spatial operator Intersect. ", "Assuming it is Intersects and adding Intersects as a supported filter type"); filterCaps.addName(Intersects.NAME); } } } } if (Versions.v2_0_0.equals(getServiceVersion())) { ScalarCapabilities spatialCaps = filterCapabilities.getScalarCapabilities(); addNamesFilterOGC(spatialCaps, filterCaps); } } filter = simplify(filter); Filter server; Filter post; Integer complianceLevel = getConfig().getFilterCompliance(); if (null == complianceLevel) { complianceLevel = XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH; } FilterCompliancePreProcessor compliancePreProcessor = new FilterCompliancePreProcessor(complianceLevel); filter.accept(compliancePreProcessor, null); filter = compliancePreProcessor.getFilter(); Id fidFilter = compliancePreProcessor.getFidFilter(); if (!fidFilter.getIdentifiers().isEmpty()) { server = fidFilter; post = Filter.EXCLUDE.equals(filter) ? Filter.INCLUDE : filter; } else { CapabilitiesFilterSplitter splitter = new CapabilitiesFilterSplitter(filterCaps, null, null); filter.accept(splitter, null); server = splitter.getFilterPre(); post = splitter.getFilterPost(); } return new Filter[] {server, post}; }
AbstractWFSStrategy extends WFSStrategy { @Override public Filter[] splitFilters(QName typeName, Filter filter) { FilterCapabilities filterCapabilities = getFilterCapabilities(); Capabilities filterCaps = new Capabilities(); if (filterCapabilities != null) { filterCaps.addAll(filterCapabilities); if (Versions.v1_0_0.equals(getServiceVersion())) { SpatialCapabilities spatialCaps = filterCapabilities.getSpatialCapabilities(); if (spatialCaps != null) { SpatialOperators spatialOps = spatialCaps.getSpatialOperators(); if (spatialOps != null) { if (null != spatialOps.getOperator("Intersect")) { trace( "WFS 1.0 capabilities states the spatial operator Intersect. ", "Assuming it is Intersects and adding Intersects as a supported filter type"); filterCaps.addName(Intersects.NAME); } } } } if (Versions.v2_0_0.equals(getServiceVersion())) { ScalarCapabilities spatialCaps = filterCapabilities.getScalarCapabilities(); addNamesFilterOGC(spatialCaps, filterCaps); } } filter = simplify(filter); Filter server; Filter post; Integer complianceLevel = getConfig().getFilterCompliance(); if (null == complianceLevel) { complianceLevel = XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH; } FilterCompliancePreProcessor compliancePreProcessor = new FilterCompliancePreProcessor(complianceLevel); filter.accept(compliancePreProcessor, null); filter = compliancePreProcessor.getFilter(); Id fidFilter = compliancePreProcessor.getFidFilter(); if (!fidFilter.getIdentifiers().isEmpty()) { server = fidFilter; post = Filter.EXCLUDE.equals(filter) ? Filter.INCLUDE : filter; } else { CapabilitiesFilterSplitter splitter = new CapabilitiesFilterSplitter(filterCaps, null, null); filter.accept(splitter, null); server = splitter.getFilterPre(); post = splitter.getFilterPost(); } return new Filter[] {server, post}; } }
AbstractWFSStrategy extends WFSStrategy { @Override public Filter[] splitFilters(QName typeName, Filter filter) { FilterCapabilities filterCapabilities = getFilterCapabilities(); Capabilities filterCaps = new Capabilities(); if (filterCapabilities != null) { filterCaps.addAll(filterCapabilities); if (Versions.v1_0_0.equals(getServiceVersion())) { SpatialCapabilities spatialCaps = filterCapabilities.getSpatialCapabilities(); if (spatialCaps != null) { SpatialOperators spatialOps = spatialCaps.getSpatialOperators(); if (spatialOps != null) { if (null != spatialOps.getOperator("Intersect")) { trace( "WFS 1.0 capabilities states the spatial operator Intersect. ", "Assuming it is Intersects and adding Intersects as a supported filter type"); filterCaps.addName(Intersects.NAME); } } } } if (Versions.v2_0_0.equals(getServiceVersion())) { ScalarCapabilities spatialCaps = filterCapabilities.getScalarCapabilities(); addNamesFilterOGC(spatialCaps, filterCaps); } } filter = simplify(filter); Filter server; Filter post; Integer complianceLevel = getConfig().getFilterCompliance(); if (null == complianceLevel) { complianceLevel = XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH; } FilterCompliancePreProcessor compliancePreProcessor = new FilterCompliancePreProcessor(complianceLevel); filter.accept(compliancePreProcessor, null); filter = compliancePreProcessor.getFilter(); Id fidFilter = compliancePreProcessor.getFidFilter(); if (!fidFilter.getIdentifiers().isEmpty()) { server = fidFilter; post = Filter.EXCLUDE.equals(filter) ? Filter.INCLUDE : filter; } else { CapabilitiesFilterSplitter splitter = new CapabilitiesFilterSplitter(filterCaps, null, null); filter.accept(splitter, null); server = splitter.getFilterPre(); post = splitter.getFilterPost(); } return new Filter[] {server, post}; } AbstractWFSStrategy(); }
AbstractWFSStrategy extends WFSStrategy { @Override public Filter[] splitFilters(QName typeName, Filter filter) { FilterCapabilities filterCapabilities = getFilterCapabilities(); Capabilities filterCaps = new Capabilities(); if (filterCapabilities != null) { filterCaps.addAll(filterCapabilities); if (Versions.v1_0_0.equals(getServiceVersion())) { SpatialCapabilities spatialCaps = filterCapabilities.getSpatialCapabilities(); if (spatialCaps != null) { SpatialOperators spatialOps = spatialCaps.getSpatialOperators(); if (spatialOps != null) { if (null != spatialOps.getOperator("Intersect")) { trace( "WFS 1.0 capabilities states the spatial operator Intersect. ", "Assuming it is Intersects and adding Intersects as a supported filter type"); filterCaps.addName(Intersects.NAME); } } } } if (Versions.v2_0_0.equals(getServiceVersion())) { ScalarCapabilities spatialCaps = filterCapabilities.getScalarCapabilities(); addNamesFilterOGC(spatialCaps, filterCaps); } } filter = simplify(filter); Filter server; Filter post; Integer complianceLevel = getConfig().getFilterCompliance(); if (null == complianceLevel) { complianceLevel = XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH; } FilterCompliancePreProcessor compliancePreProcessor = new FilterCompliancePreProcessor(complianceLevel); filter.accept(compliancePreProcessor, null); filter = compliancePreProcessor.getFilter(); Id fidFilter = compliancePreProcessor.getFidFilter(); if (!fidFilter.getIdentifiers().isEmpty()) { server = fidFilter; post = Filter.EXCLUDE.equals(filter) ? Filter.INCLUDE : filter; } else { CapabilitiesFilterSplitter splitter = new CapabilitiesFilterSplitter(filterCaps, null, null); filter.accept(splitter, null); server = splitter.getFilterPre(); post = splitter.getFilterPost(); } return new Filter[] {server, post}; } AbstractWFSStrategy(); abstract Configuration getWfsConfiguration(); @Override String getVersion(); @Override GetCapabilitiesRequest createGetCapabilitiesRequest(URL server); @Override void setConfig(WFSConfig config); @Override WFSConfig getConfig(); @Override abstract Version getServiceVersion(); @Override boolean supportsOperation(WFSOperationType operation, HttpMethod method); @Override URL getOperationURL(WFSOperationType operation, HttpMethod method); @Override String getDefaultOutputFormat(WFSOperationType operation); @Override void dispose(); @Override Filter[] splitFilters(QName typeName, Filter filter); @Override URL buildUrlGET(WFSRequest request); @Override String getPostContentType(WFSRequest wfsRequest); @Override InputStream getPostContents(WFSRequest request); @Override Map<QName, Class<?>> getFieldTypeMappings(); }
AbstractWFSStrategy extends WFSStrategy { @Override public Filter[] splitFilters(QName typeName, Filter filter) { FilterCapabilities filterCapabilities = getFilterCapabilities(); Capabilities filterCaps = new Capabilities(); if (filterCapabilities != null) { filterCaps.addAll(filterCapabilities); if (Versions.v1_0_0.equals(getServiceVersion())) { SpatialCapabilities spatialCaps = filterCapabilities.getSpatialCapabilities(); if (spatialCaps != null) { SpatialOperators spatialOps = spatialCaps.getSpatialOperators(); if (spatialOps != null) { if (null != spatialOps.getOperator("Intersect")) { trace( "WFS 1.0 capabilities states the spatial operator Intersect. ", "Assuming it is Intersects and adding Intersects as a supported filter type"); filterCaps.addName(Intersects.NAME); } } } } if (Versions.v2_0_0.equals(getServiceVersion())) { ScalarCapabilities spatialCaps = filterCapabilities.getScalarCapabilities(); addNamesFilterOGC(spatialCaps, filterCaps); } } filter = simplify(filter); Filter server; Filter post; Integer complianceLevel = getConfig().getFilterCompliance(); if (null == complianceLevel) { complianceLevel = XMLHandlerHints.VALUE_FILTER_COMPLIANCE_HIGH; } FilterCompliancePreProcessor compliancePreProcessor = new FilterCompliancePreProcessor(complianceLevel); filter.accept(compliancePreProcessor, null); filter = compliancePreProcessor.getFilter(); Id fidFilter = compliancePreProcessor.getFidFilter(); if (!fidFilter.getIdentifiers().isEmpty()) { server = fidFilter; post = Filter.EXCLUDE.equals(filter) ? Filter.INCLUDE : filter; } else { CapabilitiesFilterSplitter splitter = new CapabilitiesFilterSplitter(filterCaps, null, null); filter.accept(splitter, null); server = splitter.getFilterPre(); post = splitter.getFilterPost(); } return new Filter[] {server, post}; } AbstractWFSStrategy(); abstract Configuration getWfsConfiguration(); @Override String getVersion(); @Override GetCapabilitiesRequest createGetCapabilitiesRequest(URL server); @Override void setConfig(WFSConfig config); @Override WFSConfig getConfig(); @Override abstract Version getServiceVersion(); @Override boolean supportsOperation(WFSOperationType operation, HttpMethod method); @Override URL getOperationURL(WFSOperationType operation, HttpMethod method); @Override String getDefaultOutputFormat(WFSOperationType operation); @Override void dispose(); @Override Filter[] splitFilters(QName typeName, Filter filter); @Override URL buildUrlGET(WFSRequest request); @Override String getPostContentType(WFSRequest wfsRequest); @Override InputStream getPostContents(WFSRequest request); @Override Map<QName, Class<?>> getFieldTypeMappings(); static final Configuration FILTER_1_0_CONFIGURATION; static final Configuration WFS_1_0_CAPABILITIES_CONFIGURATION; static final Configuration WFS_1_0_CONFIGURATION; static final Configuration FILTER_1_1_CONFIGURATION; static final Configuration WFS_1_1_CONFIGURATION; static final Configuration FILTER_2_0_CONFIGURATION; static final Configuration WFS_2_0_CONFIGURATION; }