Package org.geomajas.layer.entity

Examples of org.geomajas.layer.entity.Entity


      throw new LayerException(e, ExceptionCode.FEATURE_MODEL_PROBLEM);
    }
  }

  public Geometry getGeometry(Object feature) throws LayerException {
    Entity entity = entityMapper.asEntity(feature);
    Object geometry = entity.getAttribute(getGeometryAttributeName());
    if (!wkt || null == geometry) {
      log.debug("bean.getGeometry {}", geometry);
      return (Geometry) geometry;
    } else {
      try {
View Full Code Here


  public String getGeometryAttributeName() throws LayerException {
    return getFeatureInfo().getGeometryType().getName();
  }

  public String getId(Object feature) throws LayerException {
    Entity entity = entityMapper.asEntity(feature);
    Object id = entity.getId(getFeatureInfo().getIdentifier().getName());
    return id == null ? null : id.toString();
  }
View Full Code Here

        value = id;
        break;
      default:
        throw new IllegalStateException("BeanFeatureModel only accepts String and long ids.");
    }
    Entity entity = entityMapper.asEntity(instance);
    entity.setAttribute(getFeatureInfo().getIdentifier().getName(), value);
  }
View Full Code Here

  public void setAttributes(Object feature, Map<String, Attribute> attributes) throws LayerException {
    entityMappingService.setAttributes(feature, getFeatureInfo(), entityMapper, (Map) attributes);
  }

  public void setGeometry(Object feature, Geometry geometry) throws LayerException {
    Entity entity = entityMapper.asEntity(feature);
    if (wkt) {
      WKTWriter writer = new WKTWriter();
      String wktStr = null;
      if (null != geometry) {
        wktStr = writer.write(geometry);
      }
      entity.setAttribute(getGeometryAttributeName(), wktStr);
    } else {
      entity.setAttribute(getGeometryAttributeName(), geometry);
    }
  }
View Full Code Here

    } else {
      switch (associationAttributeInfo.getType()) {
        case MANY_TO_ONE:
          ManyToOneAttribute manyToOne = new ManyToOneAttribute();
          if (entity != null) {
            Entity oneEntity = entity.getChild(associationAttributeInfo.getName());
            AssociationValue value = getAssociationValue(oneEntity, associationAttributeInfo);
            manyToOne.setValue(value);
          }
          return manyToOne;
        case ONE_TO_MANY:
View Full Code Here

      }
    }

    public void addManyToOne(String name, AssociationAttributeInfo attributeInfo, ManyToOneAttribute association)
        throws LayerException {
      Entity existing = entity.getChild(name);
      AssociationValue value = association.getValue();
      if (value == null) {
        addChild(new DeleteManyToOneOperation(getMapper(), getEntity(), attributeInfo));
      } else if (existing == null) {
        addChild(new CreateManyToOneOperation(getMapper(), getEntity(), attributeInfo, association.getValue()));
      } else {
        Object id = existing.getId(attributeInfo.getFeature().getIdentifier().getName());
        if (value.getId() == null || value.getId().isEmpty() || !value.getId().getValue().equals(id)) {
          addChild(new CreateManyToOneOperation(getMapper(), getEntity(), attributeInfo,
              association.getValue()));
        } else {
          addChild(new UpdateManyToOneOperation(getMapper(), attributeInfo, existing, value));
View Full Code Here

    FeatureBean bean = new FeatureBean();
    bean.setId(3L);
    ManyToOneAttributeBean many = new ManyToOneAttributeBean();
    many.setId(4L);
    bean.setManyToOneAttr(many);
    Entity entity = mapper.asEntity(bean);
    Assert.assertEquals(new Long(3L), entity.getId("id"));
    Assert.assertEquals(new Long(4L), entity.getChild("manyToOneAttr").getId("id"));
  }
View Full Code Here

  }
 
  @Test
  public void testFindOrCreateEntity() throws LayerException {
    BeanEntityMapper mapper = new BeanEntityMapper();
    Entity entity = mapper.findOrCreateEntity("org.geomajas.layer.bean.FeatureBean", null);
    entity.setAttribute("longAttr", 6L);
    Object object = ((BeanEntity)entity).getBean();
    Assert.assertTrue(object instanceof FeatureBean);
    Assert.assertEquals(new Long(6L), ((FeatureBean)object).getLongAttr());
  }
View Full Code Here

      throw new LayerException(e, ExceptionCode.HIBERNATE_ATTRIBUTE_ALL_GET_FAILED, feature);
    }
  }

  public String getId(Object feature) throws LayerException {
    Entity entity = entityMapper.asEntity(feature);
    Object id = entity.getId(getFeatureInfo().getIdentifier().getName());
    return id == null ? null : id.toString();
  }
View Full Code Here

  public void setAttributes(Object feature, Map<String, Attribute> attributes) throws LayerException {
    entityMappingService.setAttributes(feature, getFeatureInfo(), entityMapper, (Map) attributes);
  }

  public void setGeometry(Object feature, Geometry geometry) throws LayerException {
    Entity entity = entityMapper.asEntity(feature);
    entity.setAttribute(getGeometryAttributeName(), geometry);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.entity.Entity

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.