manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1205073 - /incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
Date Tue, 22 Nov 2011 16:43:34 GMT
Author: kwright
Date: Tue Nov 22 16:43:33 2011
New Revision: 1205073

URL: http://svn.apache.org/viewvc?rev=1205073&view=rev
Log:
Bring jobs manager into the modern conjunction-clause world

Modified:
    incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java

Modified: incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java?rev=1205073&r1=1205072&r2=1205073&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java (original)
+++ incubator/lcf/branches/CONNECTORS-290/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/Jobs.java Tue Nov 22 16:43:33 2011
@@ -61,29 +61,48 @@ public class Jobs extends org.apache.man
   public static final String _rcsid = "@(#)$Id: Jobs.java 991295 2010-08-31 19:12:14Z kwright $";
 
   // Status field values
+  //
+  // There are some themes in this state diagram.  For instance, for all active states there's a corresponding "active seeding" state, which
+  // indicates that automatic seeding is taking place at that time.  Also, the "pause a job" sequence goes from "pausing" to "paused",  while
+  // "resuming a job" goes from "resuming" to "active".  This is complicated by the fact that entering the "activewait" state is very similar
+  // to entering the "paused" state, in that the job must go first to the "active waiting" state and then to the "active wait" state, but it
+  // is completely orthogonal to the "paused" state, because one is triggered automatically and the other by human control.  Similarly,
+  // resuming from an "active wait" state must transition through another state to return to the "active" state.
+  // 
+  // However, it is only certain transitions that require special states.  For example, leaving a waited/paused state and returning to "active"
+  // does something, as does entering either active wait or paused.  Also transitions between these states do NOT require intermediates.
+  // The state diagram reflects that.  But it also has to reflect that during the "pausing" stage, "activewait" may occur, and visa versa.
   public static final int STATUS_INACTIVE = 0;                            // Not running
   public static final int STATUS_ACTIVE = 1;                              // Active, within a valid window
-  public static final int STATUS_PAUSED = 2;                             // Paused, but within a valid window
-  public static final int STATUS_SHUTTINGDOWN = 3;                  // Done, except for process cleanup
-  public static final int STATUS_ACTIVEWAIT = 4;                        // Active, but paused due to window expiration
-  public static final int STATUS_PAUSEDWAIT = 5;                        // Paused, and outside of window expiration
-  public static final int STATUS_ABORTING = 6;                          // Aborting (not yet aborted because documents still being processed)
-  public static final int STATUS_STARTINGUP = 7;                        // Loading the queue (will go into ACTIVE if successful, or INACTIVE if not)
-  public static final int STATUS_ABORTINGSTARTINGUP = 8;        // Will abort once the queue loading is complete
-  public static final int STATUS_READYFORSTARTUP = 9;             // Job is marked for startup; startup thread has not taken it yet.
-  public static final int STATUS_READYFORDELETE = 10;             // Job is marked for delete; delete thread has not taken it yet.
-  public static final int STATUS_ACTIVESEEDING = 11;              // Same as active, but seeding process is currently active also.
-  public static final int STATUS_ABORTINGSEEDING = 12;            // Same as aborting, but seeding process is currently active also.
-  public static final int STATUS_PAUSEDSEEDING = 13;              // Same as paused, but seeding process is currently active also.
-  public static final int STATUS_ACTIVEWAITSEEDING = 14;        // Same as active wait, but seeding process is currently active also.
-  public static final int STATUS_PAUSEDWAITSEEDING = 15;        // Same as paused wait, but seeding process is currently active also.
-  public static final int STATUS_ABORTINGFORRESTART = 16;       // Same as aborting, except after abort is complete startup will happen.
-  public static final int STATUS_ABORTINGFORRESTARTSEEDING = 17;  // Seeding version of aborting for restart
-  public static final int STATUS_ABORTINGSTARTINGUPFORRESTART = 18; // Starting up version of aborting for restart
-  public static final int STATUS_READYFORNOTIFY = 19;                   // Job is ready to be notified of completion
-  public static final int STATUS_NOTIFYINGOFCOMPLETION = 20;    // Notifying connector of terminating job (either aborted, or finished)
-  public static final int STATUS_DELETING = 21;                         // The job is deleting.
-  public static final int STATUS_DELETESTARTINGUP = 22;         // The delete is starting up.
+  public static final int STATUS_ACTIVESEEDING = 2;               // Same as active, but seeding process is currently active also.
+  public static final int STATUS_ACTIVEWAITING = 3;                 // In the process of waiting due to window expiration; will enter STATUS_ACTIVEWAIT when done.
+  public static final int STATUS_ACTIVEWAITINGSEEDING = 4;    // In the process of waiting due to window exp, also seeding; will enter STATUS_ACTIVEWAITSEEDING when done.
+  public static final int STATUS_ACTIVEWAIT = 5;                     // Active, but paused due to window expiration
+  public static final int STATUS_ACTIVEWAITSEEDING = 6;        // Same as active wait, but seeding process is currently active also.
+  public static final int STATUS_PAUSING = 7;                            // In the process of pausing a job; will enter STATUS_PAUSED when done.
+  public static final int STATUS_PAUSINGSEEDING = 8;                 // In the process of pausing a job, but seeding also; will enter STATUS_PAUSEDSEEDING when done.
+  public static final int STATUS_PAUSINGWAIT = 9;                    // In the process of pausing a job; will enter STATUS_PAUSEDWAIT when done.
+  public static final int STATUS_PAUSINGWAITSEEDING = 10;        // In the process of pausing a job, but seeding also; will enter STATUS_PAUSEDWAITSEEDING when done.
+  public static final int STATUS_PAUSED = 11;                             // Paused, but within a valid window
+  public static final int STATUS_PAUSEDSEEDING = 12;              // Same as paused, but seeding process is currently active also.
+  public static final int STATUS_PAUSEDWAIT = 13;                        // Paused, and outside of window expiration
+  public static final int STATUS_PAUSEDWAITSEEDING = 14;        // Same as paused wait, but seeding process is currently active also.
+  public static final int STATUS_SHUTTINGDOWN = 15;                  // Done, except for process cleanup
+  public static final int STATUS_RESUMING = 16;                          // In the process of resuming a paused or waited job; will enter STATUS_ACTIVE when done
+  public static final int STATUS_RESUMINGSEEDING = 17;               // In the process of resuming a paused or waited job, seeding process active too; will enter STATUS_ACTIVESEEDING when done.
+  public static final int STATUS_ABORTING = 18;                          // Aborting (not yet aborted because documents still being processed)
+  public static final int STATUS_STARTINGUP = 19;                        // Loading the queue (will go into ACTIVE if successful, or INACTIVE if not)
+  public static final int STATUS_ABORTINGSTARTINGUP = 20;        // Will abort once the queue loading is complete
+  public static final int STATUS_READYFORSTARTUP = 21;             // Job is marked for startup; startup thread has not taken it yet.
+  public static final int STATUS_READYFORDELETE = 22;             // Job is marked for delete; delete thread has not taken it yet.
+  public static final int STATUS_ABORTINGSEEDING = 23;            // Same as aborting, but seeding process is currently active also.
+  public static final int STATUS_ABORTINGFORRESTART = 24;       // Same as aborting, except after abort is complete startup will happen.
+  public static final int STATUS_ABORTINGFORRESTARTSEEDING = 25;  // Seeding version of aborting for restart
+  public static final int STATUS_ABORTINGSTARTINGUPFORRESTART = 26; // Starting up version of aborting for restart
+  public static final int STATUS_READYFORNOTIFY = 27;                   // Job is ready to be notified of completion
+  public static final int STATUS_NOTIFYINGOFCOMPLETION = 28;    // Notifying connector of terminating job (either aborted, or finished)
+  public static final int STATUS_DELETING = 29;                         // The job is deleting.
+  public static final int STATUS_DELETESTARTINGUP = 30;         // The delete is starting up.
   
   // These statuses have to do with whether a job has an installed underlying connector or not.
   // There are two reasons to have a special state here: (1) if the behavior of the crawler differs, or (2) if the
@@ -94,13 +113,13 @@ public class Jobs extends org.apache.man
   // But, since there is no indication in the jobs table of an uninstalled connector for such jobs, the code which starts
   // jobs up (or otherwise would enter any state that has a corresponding special state) must check to see if the underlying
   // connector exists before deciding what state to put the job into.
-  public static final int STATUS_ACTIVE_UNINSTALLED = 23;               // Active, but repository connector not installed
-  public static final int STATUS_ACTIVESEEDING_UNINSTALLED = 24;   // Active and seeding, but repository connector not installed
-  public static final int STATUS_ACTIVE_NOOUTPUT = 25;                  // Active, but output connector not installed
-  public static final int STATUS_ACTIVESEEDING_NOOUTPUT = 26;       // Active and seeding, but output connector not installed
-  public static final int STATUS_ACTIVE_NEITHER = 27;                     // Active, but neither repository connector nor output connector installed
-  public static final int STATUS_ACTIVESEEDING_NEITHER = 28;          // Active and seeding, but neither repository connector nor output connector installed
-  public static final int STATUS_DELETING_NOOUTPUT = 29;                // Job is being deleted but there's no output connector installed
+  public static final int STATUS_ACTIVE_UNINSTALLED = 31;               // Active, but repository connector not installed
+  public static final int STATUS_ACTIVESEEDING_UNINSTALLED = 32;   // Active and seeding, but repository connector not installed
+  public static final int STATUS_ACTIVE_NOOUTPUT = 33;                  // Active, but output connector not installed
+  public static final int STATUS_ACTIVESEEDING_NOOUTPUT = 34;       // Active and seeding, but output connector not installed
+  public static final int STATUS_ACTIVE_NEITHER = 35;                     // Active, but neither repository connector nor output connector installed
+  public static final int STATUS_ACTIVESEEDING_NEITHER = 36;          // Active and seeding, but neither repository connector nor output connector installed
+  public static final int STATUS_DELETING_NOOUTPUT = 37;                // Job is being deleted but there's no output connector installed
 
   // Type field values
   public static final int TYPE_CONTINUOUS = IJobDescription.TYPE_CONTINUOUS;
@@ -190,6 +209,15 @@ public class Jobs extends org.apache.man
     statusMap.put("z",new Integer(STATUS_PAUSEDWAITSEEDING));
     statusMap.put("y",new Integer(STATUS_ABORTINGFORRESTARTSEEDING));
 
+    statusMap.put("H",new Integer(STATUS_ACTIVEWAITING));
+    statusMap.put("h",new Integer(STATUS_ACTIVEWAITINGSEEDING));
+    statusMap.put("F",new Integer(STATUS_PAUSING));
+    statusMap.put("f",new Integer(STATUS_PAUSINGSEEDING));
+    statusMap.put("G",new Integer(STATUS_PAUSINGWAIT));
+    statusMap.put("g",new Integer(STATUS_PAUSINGWAITSEEDING));
+    statusMap.put("I",new Integer(STATUS_RESUMING));
+    statusMap.put("i",new Integer(STATUS_RESUMINGSEEDING));
+
     // These are the uninstalled states.  The values, I'm afraid, are pretty random.
     statusMap.put("R",new Integer(STATUS_ACTIVE_UNINSTALLED));
     statusMap.put("r",new Integer(STATUS_ACTIVESEEDING_UNINSTALLED));
@@ -501,10 +529,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_ACTIVE));
-    list.add(statusToString(STATUS_ACTIVESEEDING));
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new MultiClause(statusField,new Object[]{
+        statusToString(STATUS_ACTIVE),
+        statusToString(STATUS_ACTIVESEEDING)})});
     return performQuery("SELECT "+idField+" AS jobid,"+connectionNameField+" AS connectionname FROM "+getTableName()+" WHERE "+
-      statusField+" IN (?,?)",list,null,null);
+      query,list,null,null);
   }
 
   /** Get unique connection names for all active jobs.
@@ -514,10 +544,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_ACTIVE));
-    list.add(statusToString(STATUS_ACTIVESEEDING));
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new MultiClause(statusField,new Object[]{
+        statusToString(STATUS_ACTIVE),
+        statusToString(STATUS_ACTIVESEEDING)})});
     IResultSet set = performQuery("SELECT DISTINCT "+connectionNameField+" FROM "+getTableName()+" WHERE "+
-      statusField+" IN (?,?)",list,null,null);
+      query,list,null,null);
     String[] rval = new String[set.getRowCount()];
     int i = 0;
     while (i < set.getRowCount())
@@ -534,11 +566,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_ACTIVE));
-    list.add(statusToString(STATUS_ACTIVESEEDING));
-    IResultSet set = performQuery("SELECT * FROM "+getTableName()+" WHERE "+priorityField+"="+Integer.toString(priority)+
-      " AND "+
-      statusField+" IN (?,?) "+constructOffsetLimitClause(0,1),list,null,null,1);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new MultiClause(statusField,new Object[]{
+        statusToString(STATUS_ACTIVE),
+        statusToString(STATUS_ACTIVESEEDING)})});
+    IResultSet set = performQuery("SELECT * FROM "+getTableName()+" WHERE "+query+" AND "+priorityField+"="+Integer.toString(priority)+
+      " "+constructOffsetLimitClause(0,1),list,null,null,1);
     return set.getRowCount() > 0;
   }
 
@@ -570,8 +603,9 @@ public class Jobs extends org.apache.man
       scheduleManager.deleteRows(id);
       hopFilterManager.deleteRows(id);
       ArrayList params = new ArrayList();
-      params.add(id);
-      performDelete("WHERE "+idField+"=?",params,cacheKeys);
+      String query = buildConjunctionClause(params,new ClauseDescription[]{
+        new UnitaryClause(idField,id)});
+      performDelete("WHERE "+query,params,cacheKeys);
     }
     catch (ManifoldCFException e)
     {
@@ -647,9 +681,11 @@ public class Jobs extends org.apache.man
         performLock();
         // See whether the instance exists
         ArrayList params = new ArrayList();
+        String query = buildConjunctionClause(params,new ClauseDescription[]{
+          new UnitaryClause(idField,id)});
         params.add(id);
         IResultSet set = performQuery("SELECT * FROM "+getTableName()+" WHERE "+
-          idField+"=? FOR UPDATE",params,null,null);
+          query+" FOR UPDATE",params,null,null);
         HashMap values = new HashMap();
         values.put(descriptionField,jobDescription.getDescription());
         values.put(outputNameField,jobDescription.getOutputConnectionName());
@@ -698,8 +734,9 @@ public class Jobs extends org.apache.man
             values.put(lastCheckTimeField,null);
 
           params.clear();
-          params.add(id);
-          performUpdate(values," WHERE "+idField+"=?",params,null);
+          query = buildConjunctionClause(params,new ClauseDescription[]{
+            new UnitaryClause(idField,id)});
+          performUpdate(values," WHERE "+query,params,null);
           scheduleManager.deleteRows(id);
           hopFilterManager.deleteRows(id);
         }
@@ -753,69 +790,84 @@ public class Jobs extends org.apache.man
     {
       StringSet invKey = new StringSet(getJobStatusKey());
       ArrayList list = new ArrayList();
-
-      // Starting up delete goes back to just being ready for delete
-      list.add(statusToString(STATUS_DELETESTARTINGUP));
       HashMap map = new HashMap();
+      String query;
+      
+      // Starting up delete goes back to just being ready for delete
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_DELETESTARTINGUP))});
       map.put(statusField,statusToString(STATUS_READYFORDELETE));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
       // Notifying of completion goes back to just being ready for notify
       list.clear();
-      list.add(statusToString(STATUS_NOTIFYINGOFCOMPLETION));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_NOTIFYINGOFCOMPLETION))});
       map.put(statusField,statusToString(STATUS_READYFORNOTIFY));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
       // Starting up or aborting starting up goes back to just being ready
       list.clear();
-      list.add(statusToString(STATUS_STARTINGUP));
-      list.add(statusToString(STATUS_ABORTINGSTARTINGUP));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new MultiClause(statusField,new Object[]{
+          statusToString(STATUS_STARTINGUP),
+          statusToString(STATUS_ABORTINGSTARTINGUP)})});
       map.put(statusField,statusToString(STATUS_READYFORSTARTUP));
-      performUpdate(map,"WHERE "+statusField+" IN (?,?)",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
       // Aborting starting up for restart state goes to ABORTINGFORRESTART
       list.clear();
-      list.add(statusToString(STATUS_ABORTINGSTARTINGUPFORRESTART));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSTARTINGUPFORRESTART))});
       map.put(statusField,statusToString(STATUS_ABORTINGFORRESTART));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
       // All seeding values return to pre-seeding values
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING))});
       map.put(statusField,statusToString(STATUS_ACTIVE));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ABORTINGSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTING));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ABORTINGFORRESTARTSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ABORTINGFORRESTARTSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTINGFORRESTART));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_PAUSEDSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSEDSEEDING))});
       map.put(statusField,statusToString(STATUS_PAUSED));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVEWAITSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVEWAITSEEDING))});
       map.put(statusField,statusToString(STATUS_ACTIVEWAIT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_PAUSEDWAITSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSEDWAITSEEDING))});
       map.put(statusField,statusToString(STATUS_PAUSEDWAIT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_UNINSTALLED));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_UNINSTALLED))});
       map.put(statusField,statusToString(STATUS_ACTIVE_UNINSTALLED));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_NOOUTPUT));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_NOOUTPUT))});
       map.put(statusField,statusToString(STATUS_ACTIVE_NOOUTPUT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_NEITHER));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_NEITHER))});
       map.put(statusField,statusToString(STATUS_ACTIVE_NEITHER));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
       // No need to do anything to the queue; it looks like it can take care of
       // itself.
@@ -879,8 +931,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(statusField,statusToString(newStatusValue));
     ArrayList list = new ArrayList();
-    list.add(jobID);
-    performUpdate(newValues,"WHERE "+idField+"=?",list,invKey);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
+    performUpdate(newValues,"WHERE "+query,list,invKey);
   }
 
   /** Signal to a job that its underlying output connector has returned.
@@ -922,8 +975,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(statusField,statusToString(newStatusValue));
     ArrayList list = new ArrayList();
-    list.add(jobID);
-    performUpdate(newValues,"WHERE "+idField+"=?",list,invKey);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
+    performUpdate(newValues,"WHERE "+query,list,invKey);
   }
 
   /** Signal to a job that its underlying connector has gone away.
@@ -966,8 +1020,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(statusField,statusToString(newStatusValue));
     ArrayList list = new ArrayList();
-    list.add(jobID);
-    performUpdate(newValues,"WHERE "+idField+"=?",list,invKey);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
+    performUpdate(newValues,"WHERE "+query,list,invKey);
   }
 
   /** Signal to a job that its underlying connector has returned.
@@ -1006,8 +1061,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(statusField,statusToString(newStatusValue));
     ArrayList list = new ArrayList();
-    list.add(jobID);
-    performUpdate(newValues,"WHERE "+idField+"=?",list,invKey);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
+    performUpdate(newValues,"WHERE "+query,list,invKey);
   }
 
   /** Note a change in connection configuration.
@@ -1021,8 +1077,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(lastCheckTimeField,null);
     ArrayList list = new ArrayList();
-    list.add(connectionName);
-    performUpdate(newValues,"WHERE "+connectionNameField+"=?",list,null);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(connectionNameField,connectionName)});
+    performUpdate(newValues,"WHERE "+query,list,null);
   }
 
   /** Note a change in output connection configuration.
@@ -1036,8 +1093,9 @@ public class Jobs extends org.apache.man
     HashMap newValues = new HashMap();
     newValues.put(lastCheckTimeField,null);
     ArrayList list = new ArrayList();
-    list.add(connectionName);
-    performUpdate(newValues,"WHERE "+outputNameField+"=?",list,null);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(outputNameField,connectionName)});
+    performUpdate(newValues,"WHERE "+query,list,null);
   }
   
   /** Check whether a job's status indicates that it is in ACTIVE or ACTIVESEEDING state.
@@ -1047,9 +1105,10 @@ public class Jobs extends org.apache.man
   {
     StringSet cacheKeys = new StringSet(getJobStatusKey());
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     IResultSet set = performQuery("SELECT "+statusField+" FROM "+
-      getTableName()+" WHERE "+idField+"=?",list,cacheKeys,null);
+      getTableName()+" WHERE "+query,list,cacheKeys,null);
     if (set.getRowCount() == 0)
       return false;
     IResultRow row = set.getRow(0);
@@ -1067,10 +1126,11 @@ public class Jobs extends org.apache.man
     // This handles everything that the delete startup thread would resolve.
 
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_DELETESTARTINGUP));
     HashMap map = new HashMap();
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_DELETESTARTINGUP))});
     map.put(statusField,statusToString(STATUS_READYFORDELETE));
-    performUpdate(map,"WHERE "+statusField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
 
   }
   
@@ -1082,10 +1142,11 @@ public class Jobs extends org.apache.man
     // This resets everything that the job notification thread would resolve.
 
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_NOTIFYINGOFCOMPLETION));
     HashMap map = new HashMap();
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_NOTIFYINGOFCOMPLETION))});
     map.put(statusField,statusToString(STATUS_READYFORNOTIFY));
-    performUpdate(map,"WHERE "+statusField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
 
   }
   
@@ -1097,20 +1158,25 @@ public class Jobs extends org.apache.man
     // We have to handle all states that the startup thread would resolve, and change them to something appropriate.
 
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_STARTINGUP));
     HashMap map = new HashMap();
+    String query;
+
+    query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_STARTINGUP))});
     map.put(statusField,statusToString(STATUS_READYFORSTARTUP));
-    performUpdate(map,"WHERE "+statusField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
 
     list.clear();
-    list.add(statusToString(STATUS_ABORTINGSTARTINGUP));
+    query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSTARTINGUP))});
     map.put(statusField,statusToString(STATUS_ABORTING));
-    performUpdate(map,"WHERE "+statusField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
 
     list.clear();
-    list.add(statusToString(STATUS_ABORTINGSTARTINGUPFORRESTART));
+    query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSTARTINGUPFORRESTART))});
     map.put(statusField,statusToString(STATUS_ABORTINGFORRESTART));
-    performUpdate(map,"WHERE "+statusField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
 
   }
 
@@ -1125,43 +1191,53 @@ public class Jobs extends org.apache.man
       StringSet invKey = new StringSet(getJobStatusKey());
       ArrayList list = new ArrayList();
       HashMap map = new HashMap();
+      String query;
       // All seeding values return to pre-seeding values
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING))});
       map.put(statusField,statusToString(STATUS_ACTIVE));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ABORTINGSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ABORTINGSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTING));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ABORTINGFORRESTARTSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ABORTINGFORRESTARTSEEDING))});
       map.put(statusField,statusToString(STATUS_ABORTINGFORRESTART));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_PAUSEDSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSEDSEEDING))});
       map.put(statusField,statusToString(STATUS_PAUSED));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVEWAITSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVEWAITSEEDING))});
       map.put(statusField,statusToString(STATUS_ACTIVEWAIT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_PAUSEDWAITSEEDING));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_PAUSEDWAITSEEDING))});
       map.put(statusField,statusToString(STATUS_PAUSEDWAIT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_UNINSTALLED));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_UNINSTALLED))});
       map.put(statusField,statusToString(STATUS_ACTIVE_UNINSTALLED));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_NOOUTPUT));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_NOOUTPUT))});
       map.put(statusField,statusToString(STATUS_ACTIVE_NOOUTPUT));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
       list.clear();
-      list.add(statusToString(STATUS_ACTIVESEEDING_NEITHER));
+      query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(statusField,statusToString(STATUS_ACTIVESEEDING_NEITHER))});
       map.put(statusField,statusToString(STATUS_ACTIVE_NEITHER));
-      performUpdate(map,"WHERE "+statusField+"=?",list,invKey);
+      performUpdate(map,"WHERE "+query,list,invKey);
 
     }
     catch (ManifoldCFException e)
@@ -1190,14 +1266,15 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(STATUS_READYFORSTARTUP));
     map.put(endTimeField,null);
     // Make sure error is removed (from last time)
     map.put(errorField,null);
     map.put(windowEndField,windowEnd);
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Put job back into active state, from the shutting-down state.
@@ -1210,9 +1287,10 @@ public class Jobs extends org.apache.man
     try
     {
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+","+connectionNameField+","+outputNameField+" FROM "+getTableName()+" WHERE "+
-        idField+"=? FOR UPDATE",list,null,null);
+        query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Can't find job "+jobID.toString());
       IResultRow row = set.getRow(0);
@@ -1243,7 +1321,7 @@ public class Jobs extends org.apache.man
 
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1272,9 +1350,10 @@ public class Jobs extends org.apache.man
     try
     {
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+","+connectionNameField+","+outputNameField+" FROM "+getTableName()+" WHERE "+
-        idField+"=? FOR UPDATE",list,null,null);
+        query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Can't find job "+jobID.toString());
       IResultRow row = set.getRow(0);
@@ -1300,7 +1379,7 @@ public class Jobs extends org.apache.man
         map.put(startTimeField,new Long(startTime));
       }
       map.put(lastCheckTimeField,new Long(startTime));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1329,9 +1408,10 @@ public class Jobs extends org.apache.man
     try
     {
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+","+connectionNameField+","+outputNameField+" FROM "+getTableName()+" WHERE "+
-        idField+"=? FOR UPDATE",list,null,null);
+        query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Can't find job "+jobID.toString());
       IResultRow row = set.getRow(0);
@@ -1372,7 +1452,7 @@ public class Jobs extends org.apache.man
       {
         map.put(startTimeField,new Long(startTime));
       }
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1402,9 +1482,10 @@ public class Jobs extends org.apache.man
     try
     {
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+" FROM "+getTableName()+" WHERE "+
-        idField+"=? FOR UPDATE",list,null,null);
+        query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Can't find job "+jobID.toString());
       IResultRow row = set.getRow(0);
@@ -1445,7 +1526,7 @@ public class Jobs extends org.apache.man
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
       map.put(lastCheckTimeField,new Long(seedTime));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (Error e)
     {
@@ -1473,11 +1554,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(newStatus));
     map.put(windowEndField,windowEnd);
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Cause job that is in active or paused state to become waited.
@@ -1489,11 +1571,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(newStatus));
     map.put(windowEndField,null);
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Abort a job.
@@ -1509,9 +1592,10 @@ public class Jobs extends org.apache.man
     {
       // Get the current job status
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+" FROM "+getTableName()+
-        " WHERE "+idField+"=? FOR UPDATE",list,null,null);
+        " WHERE "+query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Job does not exist: "+jobID);
       IResultRow row = set.getRow(0);
@@ -1553,7 +1637,7 @@ public class Jobs extends org.apache.man
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
       map.put(errorField,errorText);
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
       return true;
     }
     catch (ManifoldCFException e)
@@ -1583,9 +1667,10 @@ public class Jobs extends org.apache.man
     {
       // Get the current job status
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+" FROM "+getTableName()+
-        " WHERE "+idField+"=? FOR UPDATE",list,null,null);
+        " WHERE "+query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Job does not exist: "+jobID);
       IResultRow row = set.getRow(0);
@@ -1623,7 +1708,7 @@ public class Jobs extends org.apache.man
       // reset the job
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1652,9 +1737,10 @@ public class Jobs extends org.apache.man
     {
       // Get the current job status
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+" FROM "+getTableName()+
-        " WHERE "+idField+"=? FOR UPDATE",list,null,null);
+        " WHERE "+query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Job does not exist: "+jobID);
       IResultRow row = set.getRow(0);
@@ -1686,7 +1772,7 @@ public class Jobs extends org.apache.man
       // Pause the job
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1715,9 +1801,10 @@ public class Jobs extends org.apache.man
     {
       // Get the current job status
       ArrayList list = new ArrayList();
-      list.add(jobID);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(idField,jobID)});
       IResultSet set = performQuery("SELECT "+statusField+","+connectionNameField+","+outputNameField+" FROM "+getTableName()+
-        " WHERE "+idField+"=? FOR UPDATE",list,null,null);
+        " WHERE "+query+" FOR UPDATE",list,null,null);
       if (set.getRowCount() == 0)
         throw new ManifoldCFException("Job does not exist: "+jobID);
       IResultRow row = set.getRow(0);
@@ -1771,7 +1858,7 @@ public class Jobs extends org.apache.man
       // Pause the job
       HashMap map = new HashMap();
       map.put(statusField,statusToString(newStatus));
-      performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+      performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
     }
     catch (ManifoldCFException e)
     {
@@ -1798,11 +1885,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(status));
     map.put(reseedTimeField,reseedTime);
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Update a job's status.
@@ -1813,10 +1901,11 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(status));
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Update a job's last-time field.
@@ -1827,10 +1916,11 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(lastTimeField,new Long(currentTime));
-    performUpdate(map,"WHERE "+idField+"=?",list,null);
+    performUpdate(map,"WHERE "+query,list,null);
   }
 
   /** Finish a job.
@@ -1842,7 +1932,8 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(STATUS_READYFORNOTIFY));
     map.put(errorField,null);
@@ -1850,7 +1941,7 @@ public class Jobs extends org.apache.man
     map.put(lastTimeField,new Long(finishTime));
     map.put(windowEndField,null);
     map.put(reseedTimeField,null);
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Finish a job (abort).
@@ -1861,7 +1952,8 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(STATUS_READYFORNOTIFY));
     map.put(endTimeField,null);
@@ -1869,7 +1961,7 @@ public class Jobs extends org.apache.man
     map.put(windowEndField,null);
     map.put(reseedTimeField,null);
     // Leave the error text around from the abort!
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
 
   /** Mark job as having properly notified the output connector of completion.
@@ -1879,11 +1971,12 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(jobID);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(idField,jobID)});
     HashMap map = new HashMap();
     map.put(statusField,statusToString(STATUS_INACTIVE));
     // Leave everything else around from the abort/finish.
-    performUpdate(map,"WHERE "+idField+"=?",list,new StringSet(getJobStatusKey()));
+    performUpdate(map,"WHERE "+query,list,new StringSet(getJobStatusKey()));
   }
   
   /** See if there's a reference to a connection name.
@@ -1894,9 +1987,10 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(connectionName);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(connectionNameField,connectionName)});
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+
-      " WHERE "+connectionNameField+"=?",list,new StringSet(getJobsKey()),null);
+      " WHERE "+query,list,new StringSet(getJobsKey()),null);
     return set.getRowCount() > 0;
   }
 
@@ -1908,9 +2002,10 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(connectionName);
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(outputNameField,connectionName)});
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+
-      " WHERE "+outputNameField+"=?",list,new StringSet(getJobsKey()),null);
+      " WHERE "+query,list,new StringSet(getJobsKey()),null);
     return set.getRowCount() > 0;
   }
 
@@ -1930,10 +2025,11 @@ public class Jobs extends org.apache.man
       ssb.add(getJobsKey());
       StringSet cacheKeys = new StringSet(ssb);
       ArrayList list = new ArrayList();
-      list.add(connectionName);
+      String query = buildConjunctionClause(list,new ClauseDescription[]{
+        new UnitaryClause(connectionNameField,connectionName)});
 
       IResultSet set = performQuery("SELECT "+idField+","+descriptionField+" FROM "+
-        getTableName()+" WHERE "+connectionNameField+"=?"+
+        getTableName()+" WHERE "+query+
         " ORDER BY "+descriptionField+" ASC",list,cacheKeys,null);
 
       // Convert to an array of id's, and then load them
@@ -1974,9 +2070,10 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_DELETING));
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_DELETING))});
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+" WHERE "+
-      statusField+"=? "+constructOffsetLimitClause(0,1),
+      query+" "+constructOffsetLimitClause(0,1),
       list,new StringSet(getJobStatusKey()),null,1);
     return set.getRowCount() > 0;
   }
@@ -1990,9 +2087,10 @@ public class Jobs extends org.apache.man
     throws ManifoldCFException
   {
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_SHUTTINGDOWN));
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new UnitaryClause(statusField,statusToString(STATUS_SHUTTINGDOWN))});
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+" WHERE "+
-      statusField+"=? "+constructOffsetLimitClause(0,1),
+      query+" "+constructOffsetLimitClause(0,1),
       list,new StringSet(getJobStatusKey()),null,1);
     return set.getRowCount() > 0;
   }
@@ -2008,10 +2106,12 @@ public class Jobs extends org.apache.man
     // To improve the postgres CPU usage of the system at rest, we do a *fast* check to be
     // sure there are ANY jobs in an active state.
     ArrayList list = new ArrayList();
-    list.add(statusToString(STATUS_ACTIVE));
-    list.add(statusToString(STATUS_ACTIVESEEDING));
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new MultiClause(statusField,new Object[]{
+        statusToString(STATUS_ACTIVE),
+        statusToString(STATUS_ACTIVESEEDING)})});
     IResultSet set = performQuery("SELECT "+idField+" FROM "+getTableName()+" WHERE "+
-      statusField+" IN (?,?) "+constructOffsetLimitClause(0,1),list,new StringSet(getJobStatusKey()),null,1);
+      query+" "+constructOffsetLimitClause(0,1),list,new StringSet(getJobStatusKey()),null,1);
     return set.getRowCount() > 0;
   }
 
@@ -2099,6 +2199,23 @@ public class Jobs extends org.apache.man
       return "u";
     case STATUS_DELETING_NOOUTPUT:
       return "D";
+    
+    case STATUS_ACTIVEWAITING:
+      return "H";
+    case STATUS_ACTIVEWAITINGSEEDING:
+      return "h";
+    case STATUS_PAUSING:
+      return "F";
+    case STATUS_PAUSINGSEEDING:
+      return "f";
+    case STATUS_PAUSINGWAIT:
+      return "G";
+    case STATUS_PAUSINGWAITSEEDING:
+      return "g";
+    case STATUS_RESUMING:
+      return "I";
+    case STATUS_RESUMINGSEEDING:
+      return "i";
 
     default:
       throw new ManifoldCFException("Bad status value: "+Integer.toString(status));



Mime
View raw message