Ejemplo n.º 1
0
 public void addChildObject(WDBObject child) throws Exception {
   if (!children.containsKey(child.getClassName())) {
     this.children.put(child.getClassName(), child.getUid());
   } else {
     throw new ClassCastException(
         "This entity of class \""
             + this.classDefName
             + "\" has alreadly been extended to class \""
             + child.getClassName()
             + "\"");
   }
 }
Ejemplo n.º 2
0
  public WDBObject newInstance(WDBObject baseParent, Adapter scda) throws Exception {
    Integer newUid = new Integer(Math.abs((new UID()).hashCode()));
    WDBObject newObject =
        new WDBObject(
            new Hashtable<String, Integer>(),
            new Hashtable<String, Integer>(),
            new Hashtable<String, Object>(),
            new Hashtable<String, Object>(),
            this.name,
            newUid);

    for (int i = 0; i < this.superClasses.size(); i++) {
      ClassDef superClass = scda.getClass((String) this.superClasses.get(i));
      WDBObject parent;
      if (baseParent == null || !superClass.name.equals(baseParent.getClassName())) {
        if (superClass.getClass() == SubclassDef.class) {
          // If this super class is another subclass, then create a new instance of one of those
          // with this object as the child and the parent we want to attach to
          parent = superClass.newInstance(baseParent, scda);
        } else {
          // If this super class is a base class, then create a new isntance but don't pass the
          // parent we want to attach since its a base class
          parent = superClass.newInstance(null, scda);
        }
      } else {
        // The base parent is my immediate parent
        parent = baseParent;
      }

      WDBObject childObject = parent.getChildObject(this.name, scda);

      if (childObject != null) {
        // Parent alreadly extended to this class, just return the child instance
        return childObject;
      }

      parent.addChildObject(newObject);
      parent.commit(scda);
      newObject.addParentObject(parent);
    }

    this.addInstance(newUid);
    this.commit(scda);

    return newObject;
  }
Ejemplo n.º 3
0
 public WDBObject newInstance(WDBObject parent) throws Exception {
   if (parent != null) {
     throw new IllegalArgumentException(
         "Failed to add parent object of class \""
             + parent.getClassName()
             + "\" to base class "
             + this.name);
   }
   Integer newUid = new Integer(Math.abs((new UID()).hashCode()));
   WDBObject newObject =
       new WDBObject(
           new Hashtable<String, Integer>(),
           new Hashtable<String, Integer>(),
           new Hashtable<String, Object>(),
           new Hashtable<String, Object>(),
           this.name,
           newUid);
   this.addInstance(newUid);
   return newObject;
 }
Ejemplo n.º 4
0
 public void removeChildObject(WDBObject child) throws Exception {
   this.children.remove(child.getClassName());
 }
Ejemplo n.º 5
0
 public void removeParentObject(WDBObject parent) throws Exception {
   this.parents.remove(parent.getClassName());
 }
Ejemplo n.º 6
0
 public void addParentObject(WDBObject parent) throws Exception {
   this.parents.put(parent.getClassName(), parent.getUid());
 }