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() + "\""); } }
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; }
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; }
public void removeChildObject(WDBObject child) throws Exception { this.children.remove(child.getClassName()); }
public void removeParentObject(WDBObject parent) throws Exception { this.parents.remove(parent.getClassName()); }
public void addParentObject(WDBObject parent) throws Exception { this.parents.put(parent.getClassName(), parent.getUid()); }