Package org.geomajas.configuration

Examples of org.geomajas.configuration.PrimitiveAttributeInfo


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

  public void setId(Object instance, String id) throws LayerException {
    PrimitiveAttributeInfo pai = vectorLayerInfo.getFeatureInfo().getIdentifier();
    Object value;
    switch (pai.getType()) {
      case LONG:
        value = Long.parseLong(id);
        break;
      case STRING:
        value = id;
View Full Code Here


    classloader.getResource(SHAPE_FILE);

    FeatureInfo ft = new FeatureInfo();
    ft.setDataSourceName("filtertest");

    PrimitiveAttributeInfo ia = new PrimitiveAttributeInfo();
    ia.setLabel("id");
    ia.setName("Id");
    ia.setType(PrimitiveType.STRING);
    ft.setIdentifier(ia);

    GeometryAttributeInfo ga = new GeometryAttributeInfo();
    ga.setName("the_geom");
    ga.setEditable(false);
    ft.setGeometryType(ga);

    List<AttributeInfo> attr = new ArrayList<AttributeInfo>();
    PrimitiveAttributeInfo pa = new PrimitiveAttributeInfo();
    pa.setLabel("textAttr");
    pa.setName("textAttr");
    pa.setEditable(false);
    pa.setIdentifying(true);
    pa.setType(PrimitiveType.STRING);

    attr.add(pa);

    PrimitiveAttributeInfo pa2 = new PrimitiveAttributeInfo();
    pa2.setLabel("numberAttr");
    pa2.setName("numberAttr");
    pa2.setEditable(false);
    pa2.setIdentifying(true);
    pa2.setType(PrimitiveType.INTEGER);

    attr.add(pa2);
    ft.setAttributes(attr);

    VectorLayerInfo layerInfo = new VectorLayerInfo();
View Full Code Here

    layer = (GeoToolsLayer) applicationContext.getBean("test", VectorLayer.class);

    FeatureInfo ft = new FeatureInfo();
    ft.setDataSourceName(LAYER_NAME);

    PrimitiveAttributeInfo ia = new PrimitiveAttributeInfo();
    ia.setLabel("id");
    ia.setName("Id");
    ia.setType(PrimitiveType.STRING);
    ft.setIdentifier(ia);

    GeometryAttributeInfo ga = new GeometryAttributeInfo();
    ga.setName("the_geom");
    ga.setEditable(false);
    ft.setGeometryType(ga);

    List<AttributeInfo> attr = new ArrayList<AttributeInfo>();
    PrimitiveAttributeInfo pa = new PrimitiveAttributeInfo();
    pa.setLabel("Name");
    pa.setName("NAME");
    pa.setEditable(false);
    pa.setIdentifying(true);
    pa.setType(PrimitiveType.STRING);

    attr.add(pa);
    ft.setAttributes(attr);

    VectorLayerInfo layerInfo = new VectorLayerInfo();
View Full Code Here

    VectorLayerInfo info = layer.getLayerInfo();
    builder.setName(info.getFeatureInfo().getDataSourceName());
    builder.setCRS(mapCrs);
    for (AttributeInfo attrInfo : info.getFeatureInfo().getAttributes()) {
      if (attrInfo instanceof PrimitiveAttributeInfo) {
        PrimitiveAttributeInfo prim = (PrimitiveAttributeInfo) attrInfo;
        switch (prim.getType()) {
          case BOOLEAN:
            builder.add(prim.getName(), Boolean.class);
            break;
          case CURRENCY:
            builder.add(prim.getName(), BigDecimal.class);
            break;
          case DATE:
            builder.add(prim.getName(), Date.class);
            break;
          case DOUBLE:
            builder.add(prim.getName(), Double.class);
            break;
          case FLOAT:
            builder.add(prim.getName(), Float.class);
            break;
          case INTEGER:
            builder.add(prim.getName(), Integer.class);
            break;
          case LONG:
            builder.add(prim.getName(), Long.class);
            break;
          case SHORT:
            builder.add(prim.getName(), Short.class);
            break;
          case STRING:
          case URL:
          case IMGURL:
            builder.add(prim.getName(), String.class);
            break;
          default:
            throw new IllegalStateException("Unknown primitive attribute type " + prim.getType());
        }
      } else if (attrInfo instanceof AssociationAttributeInfo) {
        AssociationAttributeInfo ass = (AssociationAttributeInfo) attrInfo;
        switch (ass.getType()) {
          case MANY_TO_ONE:
View Full Code Here

    // now list 'm up
    for (String name : attributeNames) {
      if (attrs.containsKey(name)) {
        AttributeInfo a = attrs.get(name);
        if (a instanceof PrimitiveAttributeInfo) {
          PrimitiveAttributeInfo attr = (PrimitiveAttributeInfo) a;
          switch (attr.getType()) {
            case BOOLEAN:
              builder.add(attr.getName(), Boolean.class);
              break;
            case SHORT:
              builder.add(attr.getName(), Short.class);
              break;
            case INTEGER:
              builder.add(attr.getName(), Integer.class);
              break;
            case LONG:
              builder.add(attr.getName(), Long.class);
              break;
            case FLOAT:
              builder.add(attr.getName(), Float.class);
              break;
            case DOUBLE:
              builder.add(attr.getName(), Double.class);
              break;
            case CURRENCY:
            case STRING:
            case URL:
            case IMGURL:
              builder.add(attr.getName(), String.class);
              break;
            case DATE:
              builder.add(attr.getName(), Date.class);
              break;
            default:
              log.error("Don't know how to convert attribute of type " + attr.getType() + ", skipped, " +
                  attr);
              break;
          }
        }
      }
View Full Code Here

      if (valueString == null || valueString.length() == 0) {
        return null;
      }

      if (selectedAttribute instanceof PrimitiveAttributeInfo) {
        PrimitiveAttributeInfo attr = (PrimitiveAttributeInfo) selectedAttribute;

//        if (attr.getType().equals(PrimitiveType.STRING) || attr.getType().equals(PrimitiveType.IMGURL)
//            || attr.getType().equals(PrimitiveType.URL)) {
//          // In case of a string, add quotes:
//          valueString = "'" + valueString + "'";
//      } else if (attr.getType().equals(PrimitiveType.DATE)) {

        if (attr.getType().equals(PrimitiveType.DATE)) {
          if (value instanceof Date) {
            // In case of a date, parse correctly for CQL: 2006-11-30T01:30:00Z
            DateTimeFormat format = DateTimeFormat.getFormat(CQL_TIME_FORMAT);

            if ("=".equals(operatorString)) {
View Full Code Here

   * @param attributeInfo
   *            The attribute definition for which to return possible operators.
   */
  public static String[] getOperatorsForAttributeType(AttributeInfo attributeInfo) {
    if (attributeInfo != null && attributeInfo instanceof PrimitiveAttributeInfo) {
      PrimitiveAttributeInfo primitive = (PrimitiveAttributeInfo) attributeInfo;
      switch (primitive.getType()) {
        case SHORT:
        case INTEGER:
        case LONG:
        case FLOAT:
        case DOUBLE:
View Full Code Here

      if (attributeInfo.getName().equals(name)) {
        if (attributeInfo instanceof AssociationAttributeInfo) {
          associationAttributeInfo = (AssociationAttributeInfo) attributeInfo;
        } else if (attributeInfo instanceof PrimitiveAttributeInfo) {
          // primitive, return the attribute
          PrimitiveAttributeInfo primitiveAttributeInfo = (PrimitiveAttributeInfo) attributeInfo;
          try {
            return dtoConverterService.toDto(entity == null ? null : entity.getAttribute(name),
                primitiveAttributeInfo);
          } catch (GeomajasException e) {
            throw new LayerException(e, ExceptionCode.CONVERSION_PROBLEM);
View Full Code Here

  private AssociationValue getAssociationValue(Entity entity, AssociationAttributeInfo associationAttributeInfo)
      throws LayerException {
    if (entity == null) {
      return null;
    }
    PrimitiveAttributeInfo idInfo = associationAttributeInfo.getFeature().getIdentifier();
    FeatureInfo childInfo = associationAttributeInfo.getFeature();
    PrimitiveAttribute<?> id;
    try {
      id = (PrimitiveAttribute) dtoConverterService.toDto(entity.getId(idInfo.getName()), idInfo);
    } catch (GeomajasException e) {
      throw new LayerException(e, ExceptionCode.CONVERSION_PROBLEM);
    }
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    for (AttributeInfo attributeInfo : childInfo.getAttributes()) {
View Full Code Here

    Assert.assertTrue((Boolean) converter.toInternal(attribute));
  }

  @Test
  public void testBooleanToDto() throws Exception {
    PrimitiveAttributeInfo attributeInfo = new PrimitiveAttributeInfo();
    attributeInfo.setType(PrimitiveType.BOOLEAN);
    Assert.assertTrue(converter.toDto(Boolean.TRUE, attributeInfo) instanceof BooleanAttribute);
    Assert.assertTrue(((BooleanAttribute) converter.toDto(Boolean.TRUE, attributeInfo)).getValue());
    Assert.assertFalse(((BooleanAttribute) converter.toDto(Boolean.FALSE, attributeInfo)).getValue());
  }
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.PrimitiveAttributeInfo

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.