Package org.geomajas.layer.feature

Examples of org.geomajas.layer.feature.Attribute


    try {
      Map<String, Attribute> attribs = new HashMap<String, Attribute>();
      for (AttributeInfo attribute : getFeatureInfo().getAttributes()) {
        String name = attribute.getName();
        if (!name.equals(getGeometryAttributeName())) {
          Attribute value = this.getAttribute(feature, name);
          attribs.put(name, value);
        }
      }
      return attribs;
    } catch (Exception e) {
View Full Code Here


    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);
    List<Object> attr = new ArrayList<Object>();

    for (AttributeDescriptor ads : featureType.getAttributeDescriptors()) {
      if (!ads.equals(featureType.getGeometryDescriptor())) {
        Attribute a = feature.getAttributes().get(ads.getName().getLocalPart());
        if (null != a) {
          attr.add(a.getValue());
        } else {
          attr.add(null);
        }
      } else {
        attr.add(feature.getGeometry());
View Full Code Here

                          Map<String, Attribute> featureAttributes) {
    Map<String, Attribute> filteredAttributes = new HashMap<String, Attribute>();
    for (Map.Entry<String, Attribute> entry : featureAttributes.entrySet()) {
      String key = entry.getKey();
      if (securityContext.isAttributeReadable(layerId, feature, key)) {
        Attribute attribute = entry.getValue();
        attribute.setEditable(securityContext.isAttributeWritable(layerId, feature, key));
        filteredAttributes.put(key, attribute);
      }
    }
    return filteredAttributes;
  }
View Full Code Here

    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    for (AttributeInfo attribute : featureInfo.getAttributes()) {
      String name = attribute.getName();
      if (!name.equals(geometryAttributeName)) {
        Attribute value;
        if (lazy) {
          // need to use the correct lazy type to allow instanceof to work
          if (attribute instanceof AssociationAttributeInfo) {
            switch (((AssociationAttributeInfo) attribute).getType()) {
              case MANY_TO_ONE:
View Full Code Here

    if (null != res) {
      // add and clear data according to the feature includes
      // unfortunately the data needs to be there for the security tests and can only be removed later
      if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_LABEL) != 0) {
        String labelAttr = labelStyle.getLabelAttributeName();
        Attribute attribute = featureModel.getAttribute(feature, labelAttr);
        if (null != attribute && null != attribute.getValue()) {
          res.setLabel(attribute.getValue().toString());
        }
      }

      // If allowed, add the geometry (transformed!) to the InternalFeature:
      if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_GEOMETRY) != 0) {
View Full Code Here

  public void testGetAttributes() throws LayerException {
    Iterator it = layer.getElements(Filter.INCLUDE, 0, 1);
    Assert.assertTrue(it.hasNext());
    Object f1 = it.next();
    Assert.assertFalse(it.hasNext());
    Attribute many = featureModel.getAttribute(f1, "many");
    Assert.assertTrue(many instanceof OneToManyAttribute);
    Assert.assertNotNull(many.getValue());
    Iterator<AssociationValue> it2 = ((OneToManyAttribute) many).getValue().iterator();
    Assert.assertTrue(it2.hasNext());
    AssociationValue v = it2.next();
    Attribute<?> manyInMany = v.getAllAttributes().get("manyInMany");
    Assert.assertNotNull(manyInMany);
    Assert.assertTrue(manyInMany instanceof OneToManyAttribute);
    Attribute<?> oneInMany = v.getAllAttributes().get("oneInMany");
    Assert.assertNotNull(oneInMany);
    Assert.assertTrue(oneInMany instanceof ManyToOneAttribute);
    Attribute one = featureModel.getAttribute(f1, "one");
    Assert.assertTrue(one instanceof ManyToOneAttribute);
    Assert.assertNotNull(one.getValue());
    AssociationValue v2 = ((ManyToOneAttribute) one).getValue();
    Attribute<?> oneInOne = v2.getAllAttributes().get("oneInOne");
    Assert.assertNotNull(oneInOne);
    Assert.assertTrue(oneInOne instanceof ManyToOneAttribute);
    Attribute<?> manyInOne = v2.getAllAttributes().get("manyInOne");
View Full Code Here

    Feature dto = new Feature(feature.getId());
    if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_ATTRIBUTES) != 0 && null != feature.getAttributes()) {
      // need to assure lazy attributes are converted to non-lazy attributes
      Map<String, Attribute> attributes = new HashMap<String, Attribute>();
      for (Map.Entry<String, Attribute> entry : feature.getAttributes().entrySet()) {
        Attribute value = entry.getValue();
        if (value instanceof LazyAttribute) {
          value = ((LazyAttribute) value).instantiate();
        }
        attributes.put(entry.getKey(), value);
      }
View Full Code Here

   * @param attributeName the name of the attribute
   * @return the value of the attribute or null if no such attribute exists
   * @since 1.9.0
   */
  public Object getAttributeValue(String attributeName) {
    Attribute attribute = getAllAttributes().get(attributeName);
    if (attribute != null) {
      return attribute.getValue();
    }
    return null;
  }
View Full Code Here

    layer.getFeatureModel().setAttributes(read, attribs);
    layer.saveOrUpdate(read);
    // retrieve feature again
    Object read2 = layer.getElements(filterService.createFidFilter(new String[] { id }), 0, 1).next();
    // check attributes
    Attribute stringAttr = layer.getFeatureModel().getAttribute(read2, "stringAttr");
    Assert.assertNotNull(stringAttr);
    Assert.assertTrue(stringAttr.isPrimitive());
    Assert.assertEquals("bean2", stringAttr.getValue());
    ManyToOneAttribute manyToOne3 = (ManyToOneAttribute) layer.getFeatureModel()
        .getAttribute(read, "manyToOneAttr");
    Assert.assertEquals("one2", manyToOne3.getValue().getAttributeValue("stringAttr"));

  }
View Full Code Here

  @Test
  public void testUpdateManyToOneWithExisting() throws LayerException {
    Object tranzient = createExistingManyToOne();
    Object persistent = layer.create(tranzient);
    Attribute stringAttr = layer.getFeatureModel().getAttribute(persistent, "manyToOneAttr.stringAttr");
    Assert.assertEquals("ManyToOne - 1", stringAttr.getValue());
  }
View Full Code Here

TOP

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

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.