Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 37551)
+++ trunk/ippTools/src/addtool.c	(revision 37709)
@@ -373,9 +373,9 @@
       //needs to be checked HAF xxx
       if (strcmp(stage,"diff") == 0) {
-	psStringAppend(&query, " GROUP BY diff_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
+	psStringAppend(&query, " GROUP BY diff_id, diff_skyfile_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
       }
       //needs to be checked HAF xxx
       if (strcmp(stage,"fullforce") == 0) {
-	psStringAppend(&query, " GROUP BY ff_id, skycal_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
+	psStringAppend(&query, " GROUP BY ff_id, warp_id ");  //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there
       }
 
@@ -535,11 +535,12 @@
 
     if (strcmp(stage,"diff") == 0) {
+      
       for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
 
         diffRunRow *row = diffRunObjectFromMetadata(md);
-
+	
         if (!row) {
-	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
+	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
 	  psFree(output);
 	  return false;
@@ -568,5 +569,5 @@
 
         if (!row) {
-	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
+	  psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
 	  psFree(output);
 	  return false;
@@ -784,10 +785,18 @@
    
     if (strcmp(stage,"diff") == 0) {
+      
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *md = output->data[i];
 	psS64 stage_id =0; 
-	
-		  diffRunRow *row = diffRunObjectFromMetadata(md);
-	  stage_id = row->diff_id;
+	//	psS64 stage_extra1 = 0;
+	diffRunRow *row = diffRunObjectFromMetadata(md);
+	stage_id = row->diff_id;
+	bool status = false;
+	psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
+	  return false;
+	}
+
 	
         if (!row) {
@@ -796,10 +805,10 @@
             return false;
         }
-
+	
         // queue the exp
         if (!pxaddQueueByCamID(config,
 			       stage,
                                stage_id,
-			       0,
+			       stage_extra1,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
@@ -831,7 +840,13 @@
 	psS64 stage_id =0; 
 	
-		  fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
-	  stage_id = row->ff_id;
-	
+	fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
+	stage_id = row->ff_id;
+	bool status = false;
+	psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
+	if (!status) {
+	  psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
+	  return false;
+	}
+
         if (!row) {
             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
@@ -844,5 +859,5 @@
 			       stage,
                                stage_id,
-			       0,
+			       stage_extra1,
                                workdir     ? workdir   : row->workdir,
                                reduction   ? reduction : row->reduction,
