Package org.geomajas.layer.bean

Examples of org.geomajas.layer.bean.FeatureBean


  private EntityAttributeService service;

  @Test
  public void testNoAttributes() throws LayerException {
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    FeatureBean bean = new FeatureBean();
    service.setAttributes(bean, layerBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
  }
View Full Code Here


  }

  @Test
  public void testPrimitiveAttributes() throws LayerException {
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    FeatureBean bean = new FeatureBean();
    attributes.put("stringAttr", new StringAttribute("s1"));
    attributes.put("doubleAttr", new DoubleAttribute(1.23));
    attributes.put("longAttr", new LongAttribute(12L));
    attributes.put("floatAttr", new FloatAttribute(1.67F));
    attributes.put("shortAttr", new ShortAttribute((short) 6));
    attributes.put("urlAttr", new UrlAttribute("http://haha"));
    service.setAttributes(bean, layerBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
    Assert.assertEquals("s1", bean.getStringAttr());
    Assert.assertEquals(1.23, bean.getDoubleAttr(), 0.0001);
    Assert.assertEquals(12L, bean.getLongAttr().longValue());
    Assert.assertEquals(1.67F, bean.getFloatAttr(), 0.0001);
    Assert.assertEquals(6, bean.getShortAttr().shortValue());
    Assert.assertEquals("http://haha", bean.getUrlAttr());
  }
View Full Code Here

  }

  @Test
  public void testManyToOneAttribute() throws LayerException {
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    FeatureBean bean = new FeatureBean();
    AssociationValue value = new AssociationValue(new LongAttribute(),new HashMap<String, Attribute<?>>(), false);
    value.getAllAttributes().put("stringAttr",new StringAttribute("mto"));
    attributes.put("manyToOneAttr", new ManyToOneAttribute(value));
    service.setAttributes(bean, layerBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
    Assert.assertNotNull(bean.getManyToOneAttr());
    Assert.assertEquals("mto",bean.getManyToOneAttr().getStringAttr());
    // test replacing
    ManyToOneAttributeBean original = new ManyToOneAttributeBean();
    original.setId(5L);
    original.setStringAttr("original");
    bean.setManyToOneAttr(original);
    service.setAttributes(bean, layerBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
    Assert.assertNotNull(bean.getManyToOneAttr());
    // should be replaced
    Assert.assertNotSame(original,bean.getManyToOneAttr());
    Assert.assertEquals(null,bean.getManyToOneAttr().getId());
  }
View Full Code Here

  }
 
  @Test
  public void testNonEditable() throws LayerException {
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    FeatureBean bean = new FeatureBean();
    AssociationValue value = new AssociationValue(new LongAttribute(),new HashMap<String, Attribute<?>>(), false);
    value.getAllAttributes().put("stringAttr",new StringAttribute("mto"));
    attributes.put("manyToOneAttr", new ManyToOneAttribute(value));
    attributes.put("stringAttr", new StringAttribute("top"));
    service.setAttributes(bean, layerNonEditableBeans.getLayerInfo().getFeatureInfo(), new DummyMapper(), attributes);
    Assert.assertNotNull(bean.getManyToOneAttr());
    Assert.assertNull(bean.getManyToOneAttr().getStringAttr());
    Assert.assertNull(bean.getStringAttr());
  }
View Full Code Here

      return new FeatureEntity((FeatureBean) object);
    }

    public Entity findOrCreateEntity(String dataSourceName, Object id) throws LayerException {
      if (dataSourceName.equals(FeatureBean.class.getName())) {
        return new FeatureEntity(new FeatureBean());
      }
      if (dataSourceName.equals(ManyToOneAttributeBean.class.getName())) {
        return new ManyToOneEntity(new ManyToOneAttributeBean());
      }
      throw new LayerException();
View Full Code Here

    Iterator<FeatureBean> iterator =
        (Iterator<FeatureBean>) beanLayer.getElements(filterService.createTrueFilter(), 0, 0);
    int count = 0;
    int check = 0;
    while (iterator.hasNext()) {
      FeatureBean featureBean = iterator.next();
      count++;
      if (3 == featureBean.getId()) {
        Assert.assertEquals("changed", featureBean.getStringAttr());
      }
      check |= 1 << (featureBean.getId() - 1);
    }
    Assert.assertEquals(3, count);
    Assert.assertEquals(7, check);
  }
View Full Code Here

    Iterator<FeatureBean> iterator =
        (Iterator<FeatureBean>) beanLayer.getElements(filterService.createTrueFilter(), 0, 0);
    int count = 0;
    int check = 0;
    while (iterator.hasNext()) {
      FeatureBean featureBean = iterator.next();
      count++;
      check |= 1 << (featureBean.getId() - 1);
    }
    Assert.assertEquals(4, count);
    Assert.assertEquals(15, check);

    // now delete again
    Filter filter = filterService.createFidFilter(new String[]{"4"});
    oldFeatures = layerService.getFeatures(LAYER_ID,
        crs, filter, null, VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES);
    Assert.assertEquals(1, oldFeatures.size());
    newFeatures = new ArrayList<InternalFeature>();
    layerService.saveOrUpdate(LAYER_ID, crs, oldFeatures, newFeatures);

    iterator = (Iterator<FeatureBean>) beanLayer.getElements(filterService.createTrueFilter(), 0, 0);
    count = 0;
    check = 0;
    while (iterator.hasNext()) {
      FeatureBean featureBean = iterator.next();
      count++;
      check |= 1 << (featureBean.getId() - 1);
    }
    Assert.assertEquals(3, count);
    Assert.assertEquals(7, check);

  }
View Full Code Here

  @Autowired
  private org.geomajas.security.SecurityManager securityManager;

  @Before
  public void init() {
    featureBean = new FeatureBean();
    featureBean.setId(TEST_ID);
    featureBean.setStringAttr(TEST_STRING);
    featureBean.setIntegerAttr(TEST_INTEGER);
    featureBean.setBooleanAttr(true);
View Full Code Here

TOP

Related Classes of org.geomajas.layer.bean.FeatureBean

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.