o_store fixx
authorrk <rk>
Thu, 27 Nov 2003 20:45:02 +0000 (20:45 +0000)
committerrk <rk>
Thu, 27 Nov 2003 20:45:02 +0000 (20:45 +0000)
source/mir/storage/Database.java
source/mir/storage/store/StoreUtil.java

index 1b06341..50b9081 100755 (executable)
@@ -75,7 +75,7 @@ import com.codestudio.util.SQLManager;
  * Treiber, Host, User und Passwort, ueber den der Zugriff auf die
  * Datenbank erfolgt.
  *
- * @version $Id: Database.java,v 1.44.2.16 2003/11/27 14:50:57 rk Exp $
+ * @version $Id: Database.java,v 1.44.2.17 2003/11/27 20:45:03 rk Exp $
  * @author rk
  *
  */
@@ -401,7 +401,7 @@ public class Database implements StorageObject {
     }
 
     // ask object store for object
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
       String uniqueId = id;
 
       if (theEntityClass.equals(StorableObjectEntity.class)) {
@@ -603,18 +603,16 @@ public class Database implements StorageObject {
     // check o_store for entitylist
     // only if no relational select
     if (extraTables==null) {
-      if (StoreUtil.implementsStorableObject(theEntityClass)) {
-        StoreIdentifier search_sid =
-            new StoreIdentifier(
-              theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST,
-              StoreUtil.getEntityListUniqueIdentifierFor(useTable, aWhereClause, anOrderByClause, offset, limit));
-        EntityList hit = (EntityList) o_store.use(search_sid);
-  
-        if (hit != null) {
-          logger.debug("CACHE (hit): " + search_sid.toString());
-  
-          return hit;
-        }
+      if (StoreUtil.extendsStorableEntity(theEntityClass)) {
+         StoreIdentifier searchSid = new StoreIdentifier(theEntityClass,
+               StoreContainerType.STOC_TYPE_ENTITYLIST,
+               StoreUtil.getEntityListUniqueIdentifierFor(theTable, 
+                aWhereClause, anOrderByClause, offset, limit));
+         EntityList hit = (EntityList) o_store.use(searchSid);
+
+         if (hit != null) {
+            return hit;
+         }
       }
     }
 
@@ -722,7 +720,7 @@ public class Database implements StorageObject {
           theReturnList.setNextBatch(offset + limit);
         }
 
-        if (extraTables==null && StoreUtil.implementsStorableObject(theEntityClass)) {
+        if (extraTables==null && StoreUtil.extendsStorableEntity(theEntityClass)) {
           StoreIdentifier sid = theReturnList.getStoreIdentifier();
           logger.debug("CACHE (add): " + sid.toString());
           o_store.add(sid);
@@ -834,7 +832,7 @@ public class Database implements StorageObject {
     invalidatePopupCache();
 
     // invalidating all EntityLists corresponding with theEntityClass
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
       StoreContainerType stoc_type =
         StoreContainerType.valueOf(theEntityClass,
           StoreContainerType.STOC_TYPE_ENTITYLIST);
@@ -964,7 +962,7 @@ public class Database implements StorageObject {
     /** @todo extension: check if Entity did change, otherwise we don't need
      *  the roundtrip to the database */
     /** invalidating corresponding entitylists in o_store*/
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
       StoreContainerType stoc_type =
         StoreContainerType.valueOf(theEntityClass,
           StoreContainerType.STOC_TYPE_ENTITYLIST);
@@ -1085,7 +1083,7 @@ public class Database implements StorageObject {
     invalidatePopupCache();
 
     // ostore send notification
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
       String uniqueId = id;
 
       if (theEntityClass.equals(StorableObjectEntity.class)) {
@@ -1130,7 +1128,7 @@ public class Database implements StorageObject {
    */
   public int deleteByWhereClause(String aWhereClause) throws StorageObjectFailure {
     invalidatePopupCache();
-    if (StoreUtil.implementsStorableObject(theEntityClass)) {
+    if (StoreUtil.extendsStorableEntity(theEntityClass)) {
       StoreContainerType stoc_type = StoreContainerType.valueOf(theEntityClass, StoreContainerType.STOC_TYPE_ENTITYLIST);
       o_store.invalidate(stoc_type);
     }
index efd8148..d9b4d72 100755 (executable)
@@ -29,6 +29,8 @@
  */
 package mir.storage.store;
 
+import mir.entity.StorableObjectEntity;
+
 /**
  * Title:
  * Description:
@@ -67,25 +69,29 @@ public final class StoreUtil {
     return sb.toString();
   }
 
-       /**
-        *  Method:       implementsStorableObject
-        *  Description:  internall helper method to find out if a class implements
-        *                interface StorableObject.
-        *
-        *  @return       true if yes, otherwise no.
-        */
-       public final static boolean implementsStorableObject(Class aClass) {
-               if (aClass!=null) {
-                       Class[] interfaces = aClass.getInterfaces();
-                       if (interfaces.length>0) {
-                               for (int i=0;i<interfaces.length;i++) {
-                                       if (interfaces[i]==storableObjectInterface) return true;
-                               }
-                       }
-               }
-               return false;
-       }
+  /**
+   * Description:  internall helper method to find out if a class extends
+   * class StorableEntity.
+   *
+   * @param aClass DOCUMENT ME!
+   *
+   * @return true if yes, otherwise no.
+   */
+  public static final boolean extendsStorableEntity(Class aClass) {
+     if (aClass != null) {
+        Class superclass = aClass.getSuperclass();
+
+        if (superclass != null) {
+           if (superclass == StorableObjectEntity.class) {
+              return true;
+           } else {
+              return extendsStorableEntity(superclass);
+           }
+        }
+     }
 
+     return false;
+  }
 
 
 }
\ No newline at end of file