r7002 - in dumbhippo/trunk/server/src/com/dumbhippo/dm: fetch schema
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7002 - in dumbhippo/trunk/server/src/com/dumbhippo/dm: fetch schema
- Date: Mon, 10 Dec 2007 12:10:42 -0600 (CST)
Author: otaylor
Date: 2007-12-10 12:10:42 -0600 (Mon, 10 Dec 2007)
New Revision: 7002
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/dm/fetch/PropertyFetchNode.java
dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java
Log:
DMClassHolder: Add getDerivedClasses()
PropertyFetchNode: When binding, bind against derived classes as
well as against the type itself
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/fetch/PropertyFetchNode.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/fetch/PropertyFetchNode.java 2007-12-10 17:52:23 UTC (rev 7001)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/fetch/PropertyFetchNode.java 2007-12-10 18:10:42 UTC (rev 7002)
@@ -66,13 +66,25 @@
if (!maybeSkip)
resultList.add(new PropertyFetch(propertyHolder, null, notify, max));
}
+
+ public void bindToClass(DMClassHolder<?,?> classHolder, boolean skipDefault, List<PropertyFetch> resultList, int max, boolean notify) {
+ int propertyIndex = classHolder.getPropertyIndex(property);
+ if (propertyIndex >= 0) {
+ DMPropertyHolder<?,?,?> propertyHolder = classHolder.getProperty(propertyIndex);
+ boolean maybeSkip = skipDefault && propertyHolder.getDefaultInclude();
+
+ if (propertyHolder instanceof ResourcePropertyHolder) {
+ bindResourceProperty(propertyHolder.asResourcePropertyHolder(propertyHolder.getKeyClass()), resultList, maybeSkip, notify, max);
+ } else {
+ bindPlainProperty(propertyHolder, resultList, maybeSkip, notify, max);
+ }
+ }
+ }
/**
* Finds all properties in the given class and in *subclasses* of the given class
* that match this node, bind them and return the result.
*
- * TODO: Implement the subclass part
- *
* @param classHolder
* @param whether to skip properties that are marked as defaultInclude
* (the property will still not be skipped if the children overridden)
@@ -102,17 +114,9 @@
}
}
- int propertyIndex = classHolder.getPropertyIndex(property);
- if (propertyIndex >= 0) {
- DMPropertyHolder<?,?,?> propertyHolder = classHolder.getProperty(propertyIndex);
- boolean maybeSkip = skipDefault && propertyHolder.getDefaultInclude();
-
- if (propertyHolder instanceof ResourcePropertyHolder) {
- bindResourceProperty(propertyHolder.asResourcePropertyHolder(propertyHolder.getKeyClass()), resultList, maybeSkip, notify, max);
- } else {
- bindPlainProperty(propertyHolder, resultList, maybeSkip, notify, max);
- }
- }
+ bindToClass(classHolder, skipDefault, resultList, max, notify);
+ for (DMClassHolder<?,?> subclassHolder : classHolder.getDerivedClasses())
+ bindToClass(subclassHolder, skipDefault, resultList, max, notify);
}
@Override
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java 2007-12-10 17:52:23 UTC (rev 7001)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/schema/DMClassHolder.java 2007-12-10 18:10:42 UTC (rev 7002)
@@ -58,7 +58,7 @@
private DataModel model;
private Class<T> dmoClass;
DMClassHolder<K,? extends DMObject<K>> baseClassHolder;
- private boolean subclassed = false;
+ private List<DMClassHolder<?, ?>> derivedClasses = new ArrayList<DMClassHolder<?,?>>();
private Class<K> keyClass;
private Constructor<K> keyStringConstructor;
private Method metaConstructor;
@@ -118,8 +118,8 @@
}
@SuppressWarnings("unchecked")
DMClassHolder<K,T> tmpHolder = (DMClassHolder<K,T>)classHolder;
+ tmpHolder.derivedClasses.add(this);
baseClassHolder = tmpHolder;
- baseClassHolder.subclassed = true;
}
parentClass = parentClass.getSuperclass();
@@ -198,6 +198,14 @@
return dmoClass;
}
+ /**
+ * @return a list of classholders for all DMO classes derived directly or indirectly
+ * from this DMO class.
+ */
+ public List<DMClassHolder<?,?>> getDerivedClasses() {
+ return derivedClasses;
+ }
+
public int getPropertyIndex(String name) {
Integer index = propertiesMap.get(name);
if (index == null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]