Package org.geomajas.command.dto

Examples of org.geomajas.command.dto.SearchFeatureResponse


    searchCriterion.setOperator("like");
    searchCriterion.setValue("'%1'");
    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());
    List<Feature> features = Arrays.asList(response.getFeatures());
    Assert.assertNotNull(features);
    Assert.assertEquals(2, features.size());
    List<String> actual = new ArrayList<String>();
    for (Feature feature : features) {
      actual.add(feature.getLabel());
View Full Code Here


    searchCriterion.setOperator("like");
    searchCriterion.setValue("'%1'");
    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());
    List<Feature> features = Arrays.asList(response.getFeatures());
    Assert.assertNotNull(features);
    Assert.assertEquals(0, features.size());
  }
View Full Code Here

    searchCriterion.setOperator("like");
    searchCriterion.setValue("'R%'");
    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());
    List<Feature> features = Arrays.asList(response.getFeatures());
    Assert.assertNotNull(features);
    Assert.assertEquals(3, features.size());
    List<String> actual = new ArrayList<String>();
    for (Feature feature : features) {
      actual.add(feature.getLabel());
View Full Code Here

    searchCriterion2.setValue("'%egion 2'");
    request.setCriteria(new SearchCriterion[] {searchCriterion1, searchCriterion2});
    request.setBooleanOperator("or");

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

    // test
    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) {
View Full Code Here

    // 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
    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) {
View Full Code Here

    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());
    Assert.assertEquals(LAYER_ID, response.getLayerId());
    features = response.getFeatures();
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.length);
    Assert.assertEquals("Country 3", features[0].getLabel());
    geometry = features[0].getGeometry();
    Assert.assertNotNull(geometry);
View Full Code Here

        layer = (VectorLayer) map.getMapModel().getLayer("clientLayerBeans");
        GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() {

          public void execute(CommandResponse response) {
            if (response instanceof SearchFeatureResponse) {
              SearchFeatureResponse resp = (SearchFeatureResponse) response;
              for (org.geomajas.layer.feature.Feature dtoFeature : resp.getFeatures()) {
                Feature feature = new Feature(dtoFeature, layer);
                if (null != featureAttributeWindow) {
                  featureAttributeWindow.destroy();
                  featureAttributeWindow = null;
                }
View Full Code Here

    Feature[] features = null;
    String token = securityContext.getToken();
    String locale = request.getLocale();
    if (request.getSearchFeatureRequest() != null) {
      log.debug("CSV export using FeatureRequest");
      SearchFeatureResponse result = (SearchFeatureResponse) dispatch.execute(SearchFeatureRequest.COMMAND,
          request.getSearchFeatureRequest(), token, locale);
      if (result.isError()) {
        response.getErrorMessages().addAll(result.getErrorMessages());
        response.getErrors().addAll(result.getErrors());
      } else {
        features = result.getFeatures();
      }
    } else if (request.getSearchByLocationRequest() != null) {
      log.debug("CSV export using LocationRequest");
      SearchByLocationResponse result = (SearchByLocationResponse) dispatch.execute(
          SearchByLocationRequest.COMMAND, request.getSearchByLocationRequest(), token, locale);
      if (result.isError()) {
        response.getErrorMessages().addAll(result.getErrorMessages());
        response.getErrors().addAll(result.getErrors());
      } else {
        List<Feature> res = result.getFeatureMap().get(request.getLayerId());
        if (res != null) {
          features = res.toArray(new Feature[res.size()]);
        } else {
          features = new Feature[0];
        }
      }
    } else if (request.getSearchByCriterionRequest() != null) {
      log.debug("CSV export using CriterionRequest");
      FeatureSearchResponse result = (FeatureSearchResponse) dispatch.execute(FeatureSearchRequest.COMMAND,
          request.getSearchByCriterionRequest(), token, locale);
      if (result.isError()) {
        response.getErrorMessages().addAll(result.getErrorMessages());
        response.getErrors().addAll(result.getErrors());
      } else {
        List<Feature> res = result.getFeatureMap().get(request.getLayerId());
        if (res != null) {
          features = res.toArray(new Feature[res.size()]);
        } else {
          features = new Feature[0];
        }
View Full Code Here

      command.setCommandRequest(request);
      GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() {

        public void execute(CommandResponse response) {
          if (response instanceof SearchFeatureResponse) {
            SearchFeatureResponse resp = (SearchFeatureResponse) response;
            if (null != resp.getFeatures() && resp.getFeatures().length > 0) {
              // build map of features to allow fast update
              Map<String, Integer> map = new HashMap<String, Integer>();
              for (int i = 0 ; i < features.size() ; i++) {
                Feature feature = features.get(i);
                map.put(feature.getId(), i);
              }

              for (org.geomajas.layer.feature.Feature dto : resp.getFeatures()) {
                Feature feature = features.get(map.get(dto.getId()));
                if (incAttr) {
                  feature.setAttributes(dto.getAttributes());
                }
                if (incGeom) {
View Full Code Here

        command.setCommandRequest(request);
        GwtCommandDispatcher.getInstance().execute(command, new CommandCallback() {

          public void execute(CommandResponse response) {
            if (response instanceof SearchFeatureResponse) {
              SearchFeatureResponse resp = (SearchFeatureResponse) response;
              List<Feature> features = new ArrayList<Feature>();
              for (org.geomajas.layer.feature.Feature dtoFeature : resp.getFeatures()) {
                Feature feature = new Feature(dtoFeature, layer);
                layer.getFeatureStore().addFeature(feature);
                features.add(feature);
              }
              SearchEvent event = new SearchEvent(layer, features);
View Full Code Here

TOP

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

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.