Examples of OneToManyAttribute


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

    this.name = attribute;
  }

  @SuppressWarnings("unchecked")
  public Attribute<List<AssociationValue>> instantiate() {
    return new OneToManyAttribute(getValue());
  }
View Full Code Here

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

            AssociationValue value = getAssociationValue(oneEntity, associationAttributeInfo);
            manyToOne.setValue(value);
          }
          return manyToOne;
        case ONE_TO_MANY:
          OneToManyAttribute oneToMany = new OneToManyAttribute();
          if (entity != null) {
            EntityCollection children = entity.getChildCollection(associationAttributeInfo.getName());
            List<AssociationValue> values = new ArrayList<AssociationValue>();
            for (Entity manyEntity : children) {
              values.add(getAssociationValue(manyEntity, associationAttributeInfo));
            }
            oneToMany.setValue(values);
          }
          return oneToMany;
      }
      return null;
    }
View Full Code Here

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

  }

  @Test
  public void testCreate() throws LayerException {
    Object o = featureModel.newInstance();
    OneToManyAttribute many = new OneToManyAttribute(new ArrayList<AssociationValue>());
    ManyToOneAttribute one = new ManyToOneAttribute(new AssociationValue(null, new HashMap<String, Attribute<?>>(),
        false));

    // create 2 manyInMany
    OneToManyAttribute manyInMany = new OneToManyAttribute(new ArrayList<AssociationValue>());
    AssociationValue manyInMany1 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInMany1.getAllAttributes().put("textAttr", new StringAttribute("manyInMany1"));
    manyInMany.getValue().add(manyInMany1);
    AssociationValue manyInMany2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInMany2.getAllAttributes().put("textAttr", 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("textAttr", 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("textAttr", new StringAttribute("manyInOne1"));
    manyInOne.getValue().add(manyInOne1);
    AssociationValue manyInOne2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    manyInOne2.getAllAttributes().put("textAttr", 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("textAttr", new StringAttribute("oneInOne"));
View Full Code Here

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

    factory.getCurrentSession().flush();
   
    Object o = featureModel.newInstance();
    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    // create many attribute
    OneToManyAttribute many = new OneToManyAttribute(new ArrayList<AssociationValue>());
    // create empty and add
    AssociationValue many1 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    many.getValue().add(many1);
    // create an existing one-in-many and add
    ManyToOneAttribute oneInMany2 = new ManyToOneAttribute();
    AssociationValue oneInManyValue = new AssociationValue(new LongAttribute(oneInMany1.getId()), new HashMap<String, Attribute<?>>(), false);
    oneInMany2.setValue(oneInManyValue);
    AssociationValue many2 = new AssociationValue(null, new HashMap<String, Attribute<?>>(), false);
    many2.getAllAttributes().put("oneInMany", oneInMany2);
    many.getValue().add(many2);
    // add many
    attributes.put("many", many);
    featureModel.setAttributes(o, attributes);
   
    // check text attr
    Object feature = layer.create(o);
    OneToManyAttribute attr = (OneToManyAttribute)featureModel.getAttribute(feature, "many");
    AssociationValue val = attr.getValue().get(1);
    ManyToOneAttribute one = (ManyToOneAttribute)val.getAllAttributes().get("oneInMany");
    Assert.assertEquals("existing1", one.getValue().getAttributeValue("textAttr"));

  }
View Full Code Here

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

              association = (association == null ? new ManyToOneAttribute() : association);
              addManyToOne(entry.getKey(), associationMap.get(entry.getKey()),
                  (ManyToOneAttribute) association);
              break;
            case ONE_TO_MANY:
              association = (association == null ? new OneToManyAttribute() : association);
              addOneToMany(entry.getKey(), associationMap.get(entry.getKey()),
                  (OneToManyAttribute) association);
              break;
          }
        }
View Full Code Here

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

        Object[] array = (Object[]) value;
        for (Object bean : array) {
          associationValues.add(createAssociationValue(bean, associationAttributeInfo));
        }
      }
      return new OneToManyAttribute(associationValues);
    }
    return null;
  }
View Full Code Here

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

    Map<String, Attribute> attributes = new HashMap<String, Attribute>();
    attributes.put(MTO, null);
    attributes.put(OTM, null);
    featureModel.setAttributes(feature1, attributes);
    Assert.assertNull(featureModel.getAttribute(feature1, MTO).getValue());
    OneToManyAttribute attribute = (OneToManyAttribute) featureModel.getAttribute(feature1, OTM);
    Assert.assertNotNull(attribute.getValue());
    Assert.assertEquals(0, attribute.getValue().size());
  }
View Full Code Here

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

  }

  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"));
View Full Code Here

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

    Attribute attribute = getAttributes().get(name);
    if (!(attribute instanceof OneToManyAttribute)) {
      throw new IllegalStateException("Cannot set oneToMany value on attribute with different type, " +
          attribute.getClass().getName() + " setting value " + value);
    }
    OneToManyAttribute oneToMany = (OneToManyAttribute) attribute;
    if (oneToMany.getValue() == null) {
      oneToMany.setValue(new ArrayList<AssociationValue>());
    }
    oneToMany.getValue().add(value);
  }
View Full Code Here

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

    switch (info.getType()) {
      case MANY_TO_ONE:
        association = new ManyToOneAttribute();
        break;
      case ONE_TO_MANY:
        association = new OneToManyAttribute();
    }
    association.setEditable(info.isEditable());
    return association;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.