Package org.geomajas.command.dto

Examples of org.geomajas.command.dto.SearchFeatureRequest


  private SearchFeatureCommand searchFeatureCommand;

  @Test
  public void testSearchOneCriterionNoLimit() throws Exception {
    // prepare command
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    request.setMax(SearchFeatureRequest.MAX_UNLIMITED);
    SearchCriterion searchCriterion = new SearchCriterion();
    searchCriterion.setAttributeName(REGION_ATTRIBUTE);
    searchCriterion.setOperator("like");
    searchCriterion.setValue("'%1'");
    request.setCriteria(new SearchCriterion[] {searchCriterion});

    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");
View Full Code Here


  }

  @Test
  public void testSearchOneCriterionOffset() throws Exception {
    // prepare command
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    request.setMax(SearchFeatureRequest.MAX_UNLIMITED);
    request.setOffSet(2);
    SearchCriterion searchCriterion = new SearchCriterion();
    searchCriterion.setAttributeName(REGION_ATTRIBUTE);
    searchCriterion.setOperator("like");
    searchCriterion.setValue("'%1'");
    request.setCriteria(new SearchCriterion[] {searchCriterion});

    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");
View Full Code Here

  }

  @Test
  public void testSearchOneCriterionLimit() throws Exception {
    // prepare command
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    request.setMax(3);
    SearchCriterion searchCriterion = new SearchCriterion();
    searchCriterion.setAttributeName(REGION_ATTRIBUTE);
    searchCriterion.setOperator("like");
    searchCriterion.setValue("'R%'");
    request.setCriteria(new SearchCriterion[] {searchCriterion});

    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");
View Full Code Here

  }

  @Test
  public void testSearchMultipleCriteria() throws Exception {
    // prepare command
    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");

    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");
View Full Code Here

  }

  @Test
  public void testSearchNoCriteria() throws Exception {
    // prepare command
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");

    // test
View Full Code Here

  // @todo need to test no filter, no criteria (return all?)

  @Test
  public void testSearchTransform() throws Exception {
    // prepare command, verify original coordinates first
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    request.setMax(3); // this immediately tests whether returning less than the maximum works
    SearchCriterion searchCriterion = new SearchCriterion();
    searchCriterion.setAttributeName(NAME_ATTRIBUTE);
    searchCriterion.setOperator("like");
    searchCriterion.setValue("'%3'");
    request.setCriteria(new SearchCriterion[] {searchCriterion});

    // execute
    SearchFeatureResponse response = (SearchFeatureResponse) dispatcher.execute(
        SearchFeatureRequest.COMMAND, request, null, "en");

    // test
    Assert.assertFalse(response.isError());
    Assert.assertEquals(LAYER_ID, response.getLayerId());
    Feature[] features = response.getFeatures();
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.length);
    Assert.assertEquals("Country 3", features[0].getLabel());
    Geometry geometry = features[0].getGeometry();
    Assert.assertNotNull(geometry);
    Coordinate coor = geometry.getGeometries()[0].getGeometries()[0].getCoordinates()[0];
    Assert.assertEquals(-1, coor.getX(), DOUBLE_TOLERANCE);
    Assert.assertEquals(0, coor.getY(), DOUBLE_TOLERANCE);

    // try again using mercator
    request.setCrs("EPSG:900913");
    response = (SearchFeatureResponse) dispatcher.execute(SearchFeatureRequest.COMMAND, request, null, "en");
    if (response.isError()) {
      response.getErrors().get(0).printStackTrace();
    }
    Assert.assertFalse(response.isError());
View Full Code Here

  @Test
  @DirtiesContext // @todo need to check why this is necessary, otherwise next test fails? (GetVectorTileCommandTest)
  // probably cause by directly using the command service which has an injected security context
  public void createFilterTest() throws Exception {
    SearchFeatureRequest request = new SearchFeatureRequest();
    request.setLayerId(LAYER_ID);
    request.setCrs("EPSG:4326");
    SearchCriterion searchCriterion = new SearchCriterion();
    Filter filter;

    // needs to be FidFilter when equals test on id
    searchCriterion.setAttributeName(ID_ATTRIBUTE);
    searchCriterion.setOperator("=");
    searchCriterion.setValue("'1'");
    request.setCriteria(new SearchCriterion[] {searchCriterion});
    filter = searchFeatureCommand.createFilter(request, LAYER_ID);
    Assert.assertTrue(filter instanceof FidFilter);

    // but *not* when other test
    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 FidFilter);
  }
View Full Code Here

    super(model, layer);
  }

  public void setFeatures(List<Feature> features) {
    this.features = features;
    SearchFeatureRequest featReq = new SearchFeatureRequest();
    featReq.setCriteria(buildCriteria());
    featReq.setBooleanOperator("OR");
    featReq.setCrs(model.getCrs());
    featReq.setLayerId(layer.getServerLayerId());
    featReq.setFilter(layer.getFilter());
    featReq.setFeatureIncludes(GwtCommandDispatcher.getInstance().getLazyFeatureIncludesSelect());
    setRequest(featReq);
  }
View Full Code Here

    map.getMapModel().addMapModelHandler(new MapModelHandler() {

      public void onMapModelChange(MapModelEvent event) {
        final VectorLayer layer = map.getMapModel().getVectorLayer("clientLayerBeansEditableGrid");
        grid.setLayer(layer);
        SearchFeatureRequest searchFeatureRequest = new SearchFeatureRequest();
        searchFeatureRequest.setCrs(map.getMapModel().getCrs());
        searchFeatureRequest.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ATTRIBUTES);
        searchFeatureRequest.setLayerId("layerBeansEditableGrid");
        GwtCommand searchCommand = new GwtCommand(SearchFeatureRequest.COMMAND);
        searchCommand.setCommandRequest(searchFeatureRequest);

        GwtCommandDispatcher.getInstance().execute(searchCommand,
            new AbstractCommandCallback<SearchFeatureResponse>() {
View Full Code Here

    map.getMapModel().addMapModelHandler(new MapModelHandler() {

      public void onMapModelChange(MapModelEvent event) {
        final VectorLayer layer = map.getMapModel().getVectorLayer("clientLayerCountries110mGrid");
        grid.setLayer(layer);
        SearchFeatureRequest searchFeatureRequest = new SearchFeatureRequest();
        searchFeatureRequest.setCrs(map.getMapModel().getCrs());
        searchFeatureRequest.setFeatureIncludes(GeomajasConstant.FEATURE_INCLUDE_ATTRIBUTES);
        searchFeatureRequest.setLayerId("layerCountries110m");
        GwtCommand searchCommand = new GwtCommand(SearchFeatureRequest.COMMAND);
        searchCommand.setCommandRequest(searchFeatureRequest);

        GwtCommandDispatcher.getInstance().execute(searchCommand,
            new AbstractCommandCallback<SearchFeatureResponse>() {
View Full Code Here

TOP

Related Classes of org.geomajas.command.dto.SearchFeatureRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.