@Test public void testSearchMultipleCriteria() throws Exception { SearchFeatureRequest request = new SearchFeatureRequest(); request.setLayerId(LAYER_ID); request.setCrs("EPSG:4326"); SearchCriterion searchCriterion1 = new SearchCriterion(); searchCriterion1.setAttributeName(REGION_ATTRIBUTE); searchCriterion1.setOperator("like"); searchCriterion1.setValue("'%egion 1'"); SearchCriterion searchCriterion2 = new SearchCriterion(); searchCriterion2.setAttributeName(REGION_ATTRIBUTE); searchCriterion2.setOperator("like"); searchCriterion2.setValue("'%egion 2'"); request.setCriteria(new SearchCriterion[] {searchCriterion1, searchCriterion2}); request.setBooleanOperator("or"); SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute( SearchFeatureRequest.COMMAND, request, null, "en"); Assert.assertFalse(response.isError()); Assert.assertEquals(LAYER_ID, response.getLayerId()); List<Feature> features = Arrays.asList(response.getFeatures()); Assert.assertNotNull(features); Assert.assertEquals(4, features.size()); List<String> actual = new ArrayList<String>(); for (Feature feature : features) { actual.add(feature.getLabel()); } Assert.assertTrue(actual.contains("Country 1")); Assert.assertTrue(actual.contains("Country 2")); Assert.assertTrue(actual.contains("Country 3")); Assert.assertTrue(actual.contains("Country 4")); }
@Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); } }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  @Override SearchFeatureRequest getEmptyCommandRequest(); @Override SearchFeatureResponse getEmptyCommandResponse(); @Override void execute(SearchFeatureRequest request, SearchFeatureResponse response); }
SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { @Override public void execute(SearchFeatureRequest request, SearchFeatureResponse response) throws Exception { String layerId = request.getLayerId(); if (null == layerId) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer"); } String crs = request.getCrs(); if (null == crs) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); } Filter filter = createFilter(request, layerId); log.debug("filter to apply : {}", filter); List<InternalFeature> features = layerService.getFeatures(layerId, geoService.getCrs(request.getCrs()), filter, null, request.getFeatureIncludes(), request.getOffSet(), request.getMax()); response.setLayerId(layerId); int max = request.getMax(); if (max == SearchFeatureRequest.MAX_UNLIMITED) { max = features.size(); } if (max > features.size()) { max = features.size(); } Feature[] maxList = new Feature[max]; for (int i = 0; i < max; i++) { Feature feature = converter.toDto(features.get(i)); feature.setCrs(crs); maxList[i] = feature; } response.setFeatures(maxList); }  @Override SearchFeatureRequest getEmptyCommandRequest(); @Override SearchFeatureResponse getEmptyCommandResponse(); @Override void execute(SearchFeatureRequest request, SearchFeatureResponse response);  }