コード例 #1
0
  private void setKeyProperties(DataObject data, final DataObject associatedObject)
      throws Exception {

    s_log.info("setting key properties");
    KeyGenerator.setKeyValues(data);

    final ObjectType type = data.getObjectType();
    PropertyManipulator.AttributeManipulator manip =
        new PropertyManipulator.AttributeManipulator() {
          public boolean obeys(Property p) {
            return super.obeys(p) && type.isKeyProperty(p) && p.getType().isCompound();
          }

          public void manipulate(Property p, DataObject dataInner) throws Exception {
            if (associatedObject != null && p.getType().equals(associatedObject.getObjectType())) {

              dataInner.set(p.getName(), associatedObject);
            } else {
              DataObject object =
                  SessionManager.getSession().create(p.getType().getQualifiedName());
              reportPropertyTypes(object);
              initializeObject(object, dataInner);
            }
          }
        };
    PropertyManipulator.manipulateProperties(data, manip);
  }
コード例 #2
0
  private void setDefaultProperties(DataObject data, DataObject associatedObject) throws Exception {

    final ObjectType type = data.getObjectType();
    s_log.info("");
    s_log.info("Making new object for: " + type.getQualifiedName());
    KeyGenerator.setKeyValues(data);

    ObjectType associated = (associatedObject == null) ? null : associatedObject.getObjectType();

    for (Iterator it = type.getKeyProperties(); it.hasNext(); ) {
      Property prop = (Property) it.next();
      if (prop.isAttribute()) {
        continue;
      }

      DataType propType = prop.getType();
      if (propType.equals(associated)) {
        data.set(prop.getName(), associatedObject);
      } else {
        makeChild(prop, data);
      }
    }

    PropertyManipulator.NonKeyManipulator manip =
        new PropertyManipulator.NonKeyManipulator(type) {
          public void manipulate(Property p, DataObject dataInner) throws Exception {
            m_manipulator.setDefaultProperty(p, dataInner);
          }
        };

    PropertyManipulator.manipulateProperties(data, manip);
    s_log.info("END new object.");
    s_log.info("");
    s_log.info("");
  }