Example #1
0
  public static final PropertyMap pmap(Root root, OID oid) {
    com.redhat.persistence.metadata.ObjectType type = type(root, oid.getObjectType());
    PropertyMap result = new PropertyMap(type);
    for (Iterator it = oid.getProperties().entrySet().iterator(); it.hasNext(); ) {
      Map.Entry me = (Map.Entry) it.next();
      result.put(type.getProperty((String) me.getKey()), me.getValue());
    }

    return result;
  }
Example #2
0
  /**
   * Returns a collection of ObjectTypes that this Model contains
   *
   * @return a collection of ObjectTypes that this Model contains
   */
  public Collection getObjectTypes() {
    ArrayList result = new ArrayList();

    for (Iterator it = m_root.getObjectTypes().iterator(); it.hasNext(); ) {
      com.redhat.persistence.metadata.ObjectType ot =
          (com.redhat.persistence.metadata.ObjectType) it.next();
      if (ot.getModel().equals(m_model)) {
        result.add(ot);
      }
    }

    return ObjectType.wrap(result);
  }
  private void addDefaultProperties(Path path) {
    ObjectType type = getType(path);
    addFetchedPaths(path, type);

    if (!isSource(path)) {
      Root root = type.getRoot();
      Property prop = getProperty(path);
      // assume that path.getParent() is keyed
      ObjectMap container = root.getObjectMap(prop.getContainer());
      if (container != null) {
        makePathLoadable(path.getParent(), container.getDeclaredFetchedPaths());
      }
    }
  }
  /** Add all leaves of key property hierarchy */
  private void addPathImmediates(Path path) {
    ObjectType type = getType(path);
    Collection props = type.getImmediateProperties();
    // all props for unkeyed, immediate only for keyed

    if (props.size() == 0) {
      if (!m_paths.contains(path)) {
        m_paths.add(path);
      }
    } else {
      for (Iterator it = props.iterator(); it.hasNext(); ) {
        Property prop = (Property) it.next();
        addPathImmediates(Path.add(path, prop.getName()));
      }
    }
  }
 private void addFetchedPaths(Path path, ObjectType type) {
   Root root = type.getRoot();
   if (root == null) {
     return;
   }
   ObjectMap om = root.getObjectMap(type);
   makePathLoadable(path, om.getFetchedPaths());
 }
  public Collection getReachablePropertyEvents(Object obj) {
    ArrayList result = new ArrayList();

    ObjectType ot = m_ssn.getObjectType(obj);
    for (Iterator it = ot.getProperties().iterator(); it.hasNext(); ) {
      Property prop = (Property) it.next();
      if (prop.isCollection()) {
        result.addAll(getCurrentEvents(obj, prop));
      } else {
        Event e = getLastEvent(obj, prop);
        if (e != null) {
          result.add(e);
        }
      }
    }

    return result;
  }
Example #7
0
 public static final ObjectType fromType(
     MetadataRoot root, com.redhat.persistence.metadata.ObjectType type) {
   return root.getObjectType(type.getQualifiedName());
 }