Package org.geomajas.layer.feature.attribute

Examples of org.geomajas.layer.feature.attribute.AssociationValue


    // TODO: check manyToOne value with an ID (so the corresponding object must be fetched from DB).

    final String newValue = "hello world";
    Map<String, PrimitiveAttribute<?>> mtoAttributes = new HashMap<String, PrimitiveAttribute<?>>();
    mtoAttributes.put(ManyToOneProperty.PARAM_TEXT_ATTR, new StringAttribute(newValue));
    AssociationValue assoValue = new AssociationValue(null, mtoAttributes);
    ManyToOneAttribute mtoAttribute = new ManyToOneAttribute(assoValue);

    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    attributes.put(MTO, mtoAttribute);
    featureModel.setAttributes(feature1, attributes);
View Full Code Here


  }

  public Object createNested() throws LayerException {
    Object o = layer.getFeatureModel().newInstance();
    OneToManyAttribute many = new OneToManyAttribute(new ArrayList<AssociationValue>());
    ManyToOneAttribute one = new ManyToOneAttribute(new AssociationValue(null, new HashMap<String, Attribute<?>>(),
        false));
    one.getValue().getAllAttributes().put("stringAttr", new StringAttribute("one"));

    // create 2 manyInMany
    OneToManyAttribute manyInMany = new OneToManyAttribute(new ArrayList<AssociationValue>());
    AssociationValue manyInMany1 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInMany1.getAllAttributes().put("stringAttr", new StringAttribute("manyInMany1"));
    manyInMany.getValue().add(manyInMany1);
    AssociationValue manyInMany2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInMany2.getAllAttributes().put("stringAttr", new StringAttribute("manyInMany2"));
    manyInMany.getValue().add(manyInMany2);

    // create oneInMany
    ManyToOneAttribute oneInMany = new ManyToOneAttribute();
    AssociationValue oneInManyValue = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    oneInManyValue.getAllAttributes().put("stringAttr", new StringAttribute("oneInMany"));
    oneInMany.setValue(oneInManyValue);

    // create 2 manyInOne
    OneToManyAttribute manyInOne = new OneToManyAttribute(new ArrayList<AssociationValue>());
    AssociationValue manyInOne1 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInOne1.getAllAttributes().put("stringAttr", new StringAttribute("manyInOne1"));
    manyInOne.getValue().add(manyInOne1);
    AssociationValue manyInOne2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInOne2.getAllAttributes().put("stringAttr", new StringAttribute("manyInOne2"));
    manyInOne.getValue().add(manyInOne2);

    // create oneInOne
    ManyToOneAttribute oneInOne = new ManyToOneAttribute();
    AssociationValue oneInOneValue = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    oneInOneValue.getAllAttributes().put("stringAttr", new StringAttribute("oneInOne"));
    oneInOne.setValue(oneInOneValue);

    // create 2 many
    AssociationValue many1 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    AssociationValue many2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    // add manyInMany to many1
    many1.getAllAttributes().put("oneToManyAttr", manyInMany);
    // add oneInMany to many2
    many2.getAllAttributes().put("manyToOneAttr", oneInMany);
    // add to many
    many.getValue().add(many1);
    many.getValue().add(many2);

    // add manyInOne to one
View Full Code Here

    return o;
  }

  public Object createExistingManyToOne() throws LayerException {
    Object o = layer.getFeatureModel().newInstance();
    ManyToOneAttribute one = new ManyToOneAttribute(new AssociationValue(new LongAttribute(1L),
        new HashMap<String, Attribute<?>>(), false));
    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    attributes.put("manyToOneAttr", one);
    layer.getFeatureModel().setAttributes(o, attributes);
    return o;
View Full Code Here

      date = format.parse("01/01/2009");
    } catch (ParseException e) {
      date = new Date();
    }
    attributes.put("dateAttr", new DateAttribute(date));
    return new ManyToOneAttribute(new AssociationValue(new LongAttribute(id), attributes));
  }
View Full Code Here

   *
   * @param attributeInfo
   * @return an empty value
   */
  public static AssociationValue createEmptyAssociationValue(AssociationAttributeInfo attributeInfo) {
    AssociationValue value = new AssociationValue();
    Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
    for (AttributeInfo attrInfo : attributeInfo.getFeature().getAttributes()) {
      attributes.put(attrInfo.getName(), createEmptyAttribute(attrInfo));
    }
    value.setAllAttributes(attributes);
    value.setId(createEmptyPrimitiveAttribute(attributeInfo.getFeature().getIdentifier()));
    return value;
  }
View Full Code Here

            break;

        }
      }
    }
    AssociationValue value = new AssociationValue();
    value.setAllAttributes(attributes);
    value.setId(createPrimitiveAttribute(featureInfo.getIdentifier()));
    return value;
  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.feature.attribute.AssociationValue

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.