Package org.geomajas.layer.feature

Examples of org.geomajas.layer.feature.InternalFeature


  }

  @Test
  public void testFeaturesFiltered() throws Exception {
    List<InternalFeature> features;
    InternalFeature feature;
    Filter filter = filterService.createFidFilter(new String[] {"3"});

    // first run, this should put things in the cache
    recorder.clear();
    features = vectorLayerService.getFeatures(LAYER_BEANS, wgs84, filter, null,
        GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.size());
    feature = features.get(0);
    Assert.assertEquals(2.0, feature.getGeometry().getCoordinates()[0].x, DELTA);
    Assert.assertEquals(1.0, feature.getGeometry().getCoordinates()[0].y, DELTA);
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE,
        "Put item in cache"));

    // get features again, the result should come from the cache and be the same
    recorder.clear();
    features = vectorLayerService.getFeatures(LAYER_BEANS, wgs84, filter, null,
        GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.size());
    feature = features.get(0);
    Assert.assertEquals(2.0, feature.getGeometry().getCoordinates()[0].x, DELTA);
    Assert.assertEquals(1.0, feature.getGeometry().getCoordinates()[0].y, DELTA);
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE,
        "Got item from cache"));
  }
View Full Code Here


  }

  @Test
  public void testFeaturesFilteredTransformed() throws Exception {
    List<InternalFeature> features;
    InternalFeature feature;
    Filter filter = filterService.createFidFilter(new String[] {"3"});

    // first run, this should put things in the cache
    recorder.clear();
    features = vectorLayerService.getFeatures(LAYER_BEANS, mercator, filter, null,
        GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.size());
    feature = features.get(0);
    Assert.assertEquals(222638.98158654713, feature.getGeometry().getCoordinates()[0].x, DELTA);
    Assert.assertEquals(111325.14286638486, feature.getGeometry().getCoordinates()[0].y, DELTA);
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE,
        "Put item in cache"));

    // get features again, the result should come from the cache and be the same
    recorder.clear();
    features = vectorLayerService.getFeatures(LAYER_BEANS, mercator, filter, null,
        GeomajasConstant.FEATURE_INCLUDE_GEOMETRY);
    Assert.assertNotNull(features);
    Assert.assertEquals(1, features.size());
    feature = features.get(0);
    Assert.assertEquals(222638.98158654713, feature.getGeometry().getCoordinates()[0].x, DELTA);
    Assert.assertEquals(111325.14286638486, feature.getGeometry().getCoordinates()[0].y, DELTA);
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE,
        "Got item from cache"));
  }
View Full Code Here

    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE,
        "Got item from cache"));

    // update one item
    recorder.clear();
    InternalFeature org = features.get(0);
    InternalFeature upd = org.clone();
    upd.getAttributes().put("stringAttr", new StringAttribute("something has changed"));
    List<InternalFeature> orgFeatures = new ArrayList<InternalFeature>();
    orgFeatures.add(org);
    List<InternalFeature> updFeatures = new ArrayList<InternalFeature>();
    updFeatures.add(upd);
    vectorLayerService.saveOrUpdate(LAYER_BEANS, geoService.getCrs2("EPSG:4326"), orgFeatures, updFeatures);
View Full Code Here

    ThreadScopeContextHolder.clear();
  }

  @Test
  public void testNormal() throws Exception {
    InternalFeature feature = new InternalFeatureImpl();
    Assert.assertNotNull(attributeService.getAttributes(layerBeans, feature, featureBean));
    Assert.assertEquals(TEST_STRING, feature.getAttributes().get("stringAttr").getValue());
    Assert.assertEquals(TEST_INTEGER, feature.getAttributes().get("integerAttr").getValue());
    Assert.assertTrue((Boolean) feature.getAttributes().get("booleanAttr").getValue());

    Assert.assertFalse(containsLazy(feature.getAttributes()));
    Feature dto = dtoConverter.toDto(feature);
    Assert.assertFalse(containsLazy(dto.getAttributes()));
  }
View Full Code Here

  }

  @Test
  @DirtiesContext // ?? don't know why this is needed, it affects SecurityContextAttributeAuthorizationTest
  public void testLazy() throws Exception {
    InternalFeature feature = new InternalFeatureImpl();
    Assert.assertNotNull(attributeService.getAttributes(lazyLayerBeans, feature, featureBean));
    Assert.assertEquals(TEST_STRING, feature.getAttributes().get("stringAttr").getValue());
    Assert.assertEquals(TEST_INTEGER, feature.getAttributes().get("integerAttr").getValue());
    Assert.assertTrue((Boolean) feature.getAttributes().get("booleanAttr").getValue());

    Assert.assertTrue(containsLazy(feature.getAttributes()));
    Feature dto = dtoConverter.toDto(feature);
    Assert.assertFalse(containsLazy(dto.getAttributes()));
  }
View Full Code Here

    // Apply the new set of InternalFeatures onto the transaction: (ID may be filled in now)
    if (featureTransaction.getNewFeatures() != null) {
      Feature[] resultFeatures = new Feature[newFeatures.size()];
      for (int i = 0; i < newFeatures.size(); i++) {
        InternalFeature internalFeature = newFeatures.get(i);
        resultFeatures[i] = converter.toDto(internalFeature);
      }
      featureTransaction.setNewFeatures(resultFeatures);
    }
    response.setFeatureTransaction(featureTransaction);
View Full Code Here

    MockHttpServletResponse response = new MockHttpServletResponse();
    ModelAndView mav = adapter.handle(request, response, restController);

    Object o = mav.getModel().get(RestController.FEATURE_COLLECTION);
    Assert.assertTrue(o instanceof InternalFeature);
    InternalFeature feature = (InternalFeature) o;

    Assert.assertEquals("bean1", feature.getAttributes().get("stringAttr").getValue());
    Assert.assertEquals(true, feature.getAttributes().get("booleanAttr").getValue());
    Assert.assertEquals("100,23", feature.getAttributes().get("currencyAttr").getValue());
    Calendar c = Calendar.getInstance();
    c.set(2010, 1, 23, 0, 0, 0);
    c.set(Calendar.MILLISECOND, 0);
    Assert.assertEquals(c.getTime(), feature.getAttributes().get("dateAttr").getValue());
    Assert.assertEquals(123.456, feature.getAttributes().get("doubleAttr").getValue());
    Assert.assertEquals(456.789F, feature.getAttributes().get("floatAttr").getValue());
    Assert.assertEquals("http://www.geomajas.org/image1",
        fixSlash(feature.getAttributes().get("imageUrlAttr").getValue().toString()));
    Assert.assertEquals(789, feature.getAttributes().get("integerAttr").getValue());
    Assert.assertEquals(123456789L, feature.getAttributes().get("longAttr").getValue());
    Assert.assertEquals((short) 123, feature.getAttributes().get("shortAttr").getValue());
    Assert.assertEquals("http://www.geomajas.org/url1",
        fixSlash(feature.getAttributes().get("urlAttr").getValue().toString()));

    view.render(mav.getModel(), request, response);
    response.flushBuffer();
    Object json = new JSONParser().parse(response.getContentAsString());
    String isodate = GeoJSONUtil.DATE_FORMAT.format(c.getTime());
View Full Code Here

TOP

Related Classes of org.geomajas.layer.feature.InternalFeature

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.