Index: /trunk/ippToPsps/perl/checkOdmStatus.pl
===================================================================
--- /trunk/ippToPsps/perl/checkOdmStatus.pl	(revision 29093)
+++ /trunk/ippToPsps/perl/checkOdmStatus.pl	(revision 29094)
@@ -5,6 +5,4 @@
 
 use LWP::UserAgent;
-use IPC::Cmd 0.36 qw( can_run run );
-use IPC::Cmd 0.36 qw( can_run run );
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use XML::LibXML;
@@ -12,4 +10,5 @@
 use ippToPsps::IppToPspsDb;
 use ippToPsps::Datastore;
+use ippToPsps::BatchManager;
 
 my $singleBatch = undef;
@@ -61,4 +60,5 @@
 my $datastore = new ippToPsps::Datastore($product, 0, 0);
 my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
+my $batchManager = new ippToPsps::BatchManager($ippToPspsDb, $filePath, $verbose, $save_temps);
 my $odmUrl = "http://web01.psps.ifa.hawaii.edu/a01/OdmWebService/OdmWebService.asmx/GetBatchStatus";
 my $ua = LWP::UserAgent->new;
@@ -102,5 +102,5 @@
         $numBatchesToCheck++;
 
-        my $batchName = getBatchName($batchId);
+        my $batchName = $batchManager->getBatchName($batchId);
 
         # if not merged then update by polling ODM for status
@@ -119,13 +119,8 @@
             }
         }
-
         # if merged and already removed from datastore then delete files
         if (defined $filePath && $merged && $deleted) {
 
-            print "$command\n";
-            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-                run(command => $command, verbose => $verbose);
-            if (!$success) {print "* Unable to run: $command\n";}
-            else {$numDeleted++;}
+            if($batchManager->deleteBatch($batchId)) {$numDeleted++;}
         }
 
@@ -152,15 +147,4 @@
 ########################################################################################
 # 
-# Returns batch name from batch_id TODO needs to be a batch class
-# 
-########################################################################################
-sub getBatchName {
-    my ($batchId) = @_;
-
-    return sprintf("B%08d", $batchId);
-}
-
-########################################################################################
-# 
 # Check a single batch
 # 
Index: /trunk/ippToPsps/perl/ippToPsps/BatchManager.pm
===================================================================
--- /trunk/ippToPsps/perl/ippToPsps/BatchManager.pm	(revision 29094)
+++ /trunk/ippToPsps/perl/ippToPsps/BatchManager.pm	(revision 29094)
@@ -0,0 +1,95 @@
+#!/usr/bin/perl -w
+
+package ippToPsps::BatchManager;
+
+use warnings;
+use strict;
+
+use IPC::Cmd 0.36 qw( can_run run );
+
+###########################################################################
+#
+# Constructor
+#
+###########################################################################
+sub new {
+
+    my $class = shift;
+    my $self = {
+        _ippToPspsDb => shift,
+        _path => shift,
+        _verbose => shift,
+        _save_temps => shift,
+    };
+
+    bless $self, $class;
+    return $self;
+}
+
+########################################################################################
+# 
+# Returns batch name from batch_id
+# 
+########################################################################################
+sub getBatchName {
+    my ($self, $batchId) = @_;
+
+    return sprintf("B%08d", $batchId);
+}
+
+########################################################################################
+# 
+# Returns name of tarred and zipped batch file
+# 
+########################################################################################
+sub getBatchFileName {
+    my ($self, $batchId) = @_;
+
+    my $batchName = $self->getBatchName($batchId);
+    return "$batchName.tar.gz";
+}
+
+########################################################################################
+# 
+# Returns full path of batch 
+# 
+########################################################################################
+sub getFullBatchPath {
+    my ($self, $batchId) = @_;
+
+    my $batches;
+    my $numOfBatches = $self->{_ippToPspsDb}->getBatch($batchId, \$batches);
+    if ($numOfBatches < 1) {return "unknown";}
+
+    my $batch;
+    my ($timestamp, $expId, $batchIdi, $surveyType, $deleted, $dvoDb, $processed, $onDatastore, $loadedToOdm, $mergeWorthy, $merged);
+    foreach $batch ( @{$batches} ) {
+        ($timestamp, $expId, $batchIdi, $surveyType, $deleted, $dvoDb, $processed, $onDatastore, $loadedToOdm, $mergeWorthy, $merged) =  @{$batch};
+
+
+    }
+
+    my $batchFile = $self->getBatchFileName($batchId);
+    return "$self->{_path}/$dvoDb/$batchFile";
+}
+
+########################################################################################
+# 
+# Deletes a batch 
+# 
+########################################################################################
+sub deleteBatch {
+    my ($self, $batchId) = @_;
+
+    my $command = "rm " . $self->getFullBatchPath($batchId);
+    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
+        run(command => $command, verbose => $self->{_verbose});
+    if (!$success) {
+        print "* Unable to run: $command\n";
+        return 0;
+    }
+
+    return 1;
+}
+
+1;
