Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 33259)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 33266)
@@ -50,4 +50,31 @@
 
     '''
+    Returns a list of batch IDs marked as 'purged' but not yet deleted
+    '''
+    def getPurgedButNotDeletedBatchIDs(self, batchType, epoch, dvoGpc1Label, column):
+
+        sql = "SELECT DISTINCT batch_id \
+               FROM batch \
+               WHERE timestamp > '" + epoch + "' \
+               AND batch_type = '" + batchType + "' \
+               AND dvo_db = '" + dvoGpc1Label + "' \
+               AND purged = 1 \
+               AND " + column + " = 0"
+
+        ids = []
+        try:
+            rs = self.executeQuery(sql)
+            while (rs.next()):
+                ids.append(rs.getInt(1))
+        except:
+            self.logger.exception("Can't query for merged batch ids in ipptopsps Db")
+
+        rs.close()
+
+        self.logger.debug("Found %d merged but un-deleted items" % len(ids))
+
+        return ids
+
+    '''
     Returns a list of processed batch IDs that have been loaded to the ODM but not yet deleted
     '''
@@ -99,4 +126,16 @@
     def getLoadedToODMButNotDeletedFromDXLayer(self, batchType, epoch, dvoGpc1Label):
         return self.getLoadedToODMButNotDeletedBatchIDs(batchType, epoch, dvoGpc1Label, "deleted_dxlayer")
+
+    '''
+    Returns a list of purged  batch IDs that not deleted from local disk
+    '''
+    def getPurgedButNotDeletedFromLocalDisk(self, batchType, epoch, dvoGpc1Label):
+        return self.getPurgedButNotDeletedBatchIDs(batchType, epoch, dvoGpc1Label, "deleted_local")
+
+    '''
+    Returns a list of purged batch IDs that are not deleted from datastore
+    '''
+    def getPurgedButNotDeletedFromDatastore(self, batchType, epoch, dvoGpc1Label):
+        return self.getPurgedButNotDeletedBatchIDs(batchType, epoch, dvoGpc1Label, "deleted_datastore")
 
 
@@ -454,8 +493,6 @@
     def updateOdmStatus(self, batchID, odmStatus):
 
-        if odmStatus['LOADFAILED'] == 1: loadedToODM = -1
-        else: loadedToODM = odmStatus['LOADEDTOODM']
         sql = "UPDATE batch \
-               SET loaded_to_ODM = " + str(loadedToODM) + ", \
+               SET loaded_to_ODM = " + str(odmStatus['LOADEDTOODM']) + ", \
                merge_worthy = " + str(odmStatus['MERGEWORTHY']) + ", \
                merged = " + str(odmStatus['MERGED']) + " \
