SearchFeatureCommand implements CommandHasRequest<SearchFeatureRequest, SearchFeatureResponse> { Filter createFilter(SearchFeatureRequest request, String layerId) throws GeomajasException { Filter f = null; VectorLayer layer = configurationService.getVectorLayer(layerId); if (layer == null) { throw new GeomajasException(ExceptionCode.LAYER_NOT_FOUND, layerId); } String idName = layer.getLayerInfo().getFeatureInfo().getIdentifier().getName(); if (null != request.getCriteria()) { for (SearchCriterion criterion : request.getCriteria()) { Filter temp; String attributeName = criterion.getAttributeName(); String operator = criterion.getOperator(); if ((SearchFeatureRequest.ID_ATTRIBUTE.equals(attributeName) || attributeName.equals(idName)) && (null == operator || "=".equals(operator))) { temp = filterService.createFidFilter(new String[]{criterion.getValue()}); } else { String c = criterion.toString().replace('*', '%').replace('?', '_'); temp = filterService.parseFilter(c); } if (f == null) { f = temp; } else { f = filterService.createLogicFilter(f, request.getBooleanOperator(), temp); } } } String filter = request.getFilter(); if (filter != null) { if (f == null) { f = filterService.parseFilter(filter); } else { f = filterService.createAndFilter(filterService.parseFilter(filter), f); } } if (f == null) { f = filterService.createTrueFilter(); } return f; }  @Override SearchFeatureRequest getEmptyCommandRequest(); @Override SearchFeatureResponse getEmptyCommandResponse(); @Override void execute(SearchFeatureRequest request, SearchFeatureResponse response);  }
@Test @DirtiesContext public void createFilterTest() throws Exception { SearchFeatureRequest request = new SearchFeatureRequest(); request.setLayerId(LAYER_ID); request.setCrs("EPSG:4326"); SearchCriterion searchCriterion = new SearchCriterion(); Filter filter; searchCriterion.setAttributeName(ID_ATTRIBUTE); searchCriterion.setOperator("="); searchCriterion.setValue("'1'"); request.setCriteria(new SearchCriterion[] {searchCriterion}); filter = searchFeatureCommand.createFilter(request, LAYER_ID); Assert.assertTrue(filter instanceof Id); searchCriterion.setAttributeName(ID_ATTRIBUTE); searchCriterion.setOperator("like"); searchCriterion.setValue("'%a%'"); request.setCriteria(new SearchCriterion[] {searchCriterion}); filter = searchFeatureCommand.createFilter(request, LAYER_ID); Assert.assertFalse(filter instanceof Id); }