Bug 1077744 - statement timeout during drift purge job

Changed the query WHERE clause: don't use NOT IN because NOT IN(NULL) will always return false.
See http://stackoverflow.com/questions/17150208/sql-query-with-not-in-returning-no-rows

In other words, if any row in RHQ_DRIFT as a NULL value in OLD_DRIFT_FILE or NEW_DRIFT_FILE columns, we'll never purge anything.

Besides, the NOT EXISTS variant has a better execution plan.

Use PurgeTemplate to delete rows in batches and select the keys of the rows to delete without locking the drift files table.

Also, some code cleanup.

(cherry picked from commit 3251090d63f58f0da3d604f30cc8f819533e0fcc)
Signed-off-by: Libor Zoubek <lzoubek@redhat.com>