Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 7149)
+++ trunk/ippTools/src/dettool.c	(revision 7158)
@@ -173,4 +173,6 @@
     psArray *rawImfiles = searchRawImfiles(config, NULL);
 
+    // XXX remove detProcessedImfiles
+
     // print imfile list
     psMetadata *output = psMetadataAlloc();
@@ -580,5 +582,83 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-
-    return true;
-}
+ 
+    // det_id, class_id, uri, stats, & recipe are required
+    bool status = false;
+    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
+        return false;
+    }
+    psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id");
+        return false;
+    }
+    psString uri    = psMetadataLookupStr(&status, config->args, "-uri");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
+        return false;
+    }
+    psString recipe = psMetadataLookupStr(&status, config->args, "-recipe");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recipe");
+        return false;
+    }
+    psString stats = psMetadataLookupStr(&status, config->args, "-stats");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");
+        return false;
+    }
+
+    // correlate the class_id against the det_id's detStackedImfiles
+
+    // we have to generate our own where claus as we want to search only by the
+    // det_id & class_id
+    psMetadata *where = psMetadataAlloc();
+    if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
+            (psS32)atoi(det_id))) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+        psFree(where);
+        return false;
+    }
+    if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
+        psFree(where);
+        return false;
+    }
+
+    psArray *stackedImfiles = detStackedImfileSelectRowObjects(
+                                config->dbh, where, 0);
+
+    bool valid_class_id = false;
+    if (stackedImfiles) {
+        for (long i = 0; i < psArrayLength(stackedImfiles); i++) {
+            if (strcmp(class_id, 
+                ((detStackedImfileRow *)stackedImfiles->data[i])->class_id)
+            == 0) {
+                valid_class_id = true;
+                break;
+            }
+        }
+        psFree(stackedImfiles);
+    } 
+
+    if (!valid_class_id) {
+        psError(PS_ERR_UNKNOWN, true, 
+        "class_id can not be correlated with a detStackedImfile");
+        return false;
+    }
+
+    // create a new detMasterImfile object
+    detMasterImfileRow *masterImfile = detMasterImfileRowAlloc(
+        (psS32)atol(det_id), class_id, uri, stats, recipe
+    );   
+
+    // insert the new row into the detProcessedImfile table
+    if (!detMasterImfileInsertObject(config->dbh, masterImfile)) {
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false; 
+    }
+
+    return true;
+}
