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("");
  }
  public void testGetObjectType() {

    DataCollection allItems = getDefaultCollection();
    int count = 0;
    while (allItems.next()) {
      ObjectType type = allItems.getObjectType();
      s_log.info("Type: " + type.getQualifiedName());
      assertEquals("Somehow failed to retrieve a Node?", "Node", type.getName());
      count++;
    }

    assertTrue("No data objects?", count > 0);
  }
Esempio n. 3
0
 public static final com.redhat.persistence.metadata.ObjectType type(Root root, ObjectType type) {
   return type(root, type.getQualifiedName());
 }
Esempio n. 4
0
 /** Serializes the OID. */
 public String toString() {
   String fullType = m_type.getQualifiedName();
   Object[] args = {fullType, getProperties().toString()};
   return m_format.format(args);
 }
  private void checkUpdates(DataObject data, final DataObject parent) throws Exception {

    final ObjectType type = data.getObjectType();

    try {
      PropertyManipulator.NonKeyManipulator manip =
          new PropertyManipulator.NonKeyManipulator(type) {

            public void manipulate(Property p, DataObject dataInner) throws Exception {
              m_manipulator.updateAllPropertyCombinations(p, dataInner);
            }
          };

      PropertyManipulator.manipulateProperties(data, manip);

      PropertyManipulator.PredicateManipulator childManip =
          new PropertyManipulator.ComponentManipulator() {
            public void manipulate(Property p, DataObject dataInner) throws Exception {

              if (p.isCollection()) {
                DataAssociation children = (DataAssociation) dataInner.get(p.getName());
                DataAssociationCursor cursor = children.cursor();
                while (cursor.next()) {
                  DataObject child = cursor.getDataObject();
                  s_log.debug("checkUpdates on child: " + child.getObjectType().getQualifiedName());
                  checkUpdates(child, dataInner);
                }
              } else {
                DataObject child = (DataObject) dataInner.get(p.getName());
                s_log.debug("checkUpdates on child: " + child.getObjectType().getQualifiedName());
                checkUpdates(child, dataInner);
              }
            }
          };

      PropertyManipulator.manipulateProperties(data, childManip);

      PropertyManipulator.AssociationManipulator assocManip =
          new PropertyManipulator.AssociationManipulator() {
            public void manipulate(Property p, DataObject dataInner) throws Exception {

              if (p.isCollection()) {
                DataAssociation associations = (DataAssociation) dataInner.get(p.getName());
                DataAssociationCursor cursor = associations.cursor();
                while (cursor.next()) {
                  DataObject assoc = cursor.getDataObject();
                  if (!assoc.equals(parent)) {
                    s_log.debug(
                        "checkUpdates on assoc: " + assoc.getObjectType().getQualifiedName());
                    checkUpdates(assoc, dataInner);
                  }
                }
              } else {
                DataObject assoc = (DataObject) dataInner.get(p.getName());
                if (null != assoc && !assoc.equals(parent)) {
                  s_log.debug("checkUpdates on assoc: " + assoc.getObjectType().getQualifiedName());
                  checkUpdates(assoc, dataInner);
                }
              }
            }
          };

      PropertyManipulator.manipulateProperties(data, assocManip);
    } catch (UndefinedEventException e) {
      s_log.info(
          "Update event undefined for type: "
              + type.getQualifiedName()
              + " Update tests cannot be performed.");
      s_log.info("UndefinedEventException: " + e.getMessage());
    }
  }