IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42618


Ignore:
Timestamp:
Feb 8, 2024, 11:32:49 AM (2 years ago)
Author:
eugene
Message:

trying to add xcff to addtool, cleaning up the code some

Location:
branches/eam_branches/ippTools-20240208
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ippTools-20240208/src/addtool.c

    r41213 r42618  
    119119    //  pxcamGetSearchArgs (config, where);
    120120    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
    121     PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
    122     PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
    123     PXOPT_COPY_S64(config->args, where,  "-skycal_id",  "skycalRun.skycal_id", "==");
    124     PXOPT_COPY_S64(config->args, where,  "-diff_id",  "diffRun.diff_id", "==");
    125     PXOPT_COPY_S64(config->args, where,  "-ff_id",  "fullForceRun.ff_id", "==");
     121    PXOPT_COPY_S64(config->args, where,  "-stack_id",  "stackRun.stack_id", "=="); // XXX drop
     122    PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "=="); // XXX drop
     123    PXOPT_COPY_S64(config->args, where,  "-skycal_id", "skycalRun.skycal_id", "==");
     124    PXOPT_COPY_S64(config->args, where,  "-diff_id",   "diffRun.diff_id", "==");
     125    PXOPT_COPY_S64(config->args, where,  "-ff_id",     "fullForceRun.ff_id", "==");
     126    PXOPT_COPY_S64(config->args, where,  "-xcff_id",   "xcForceRun.ff_id", "==");
    126127       
    127     // PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    128     PXOPT_LOOKUP_STR(workdir,     config->args, "-set_workdir", false, false);
    129     PXOPT_LOOKUP_STR(dvodb,       config->args, "-set_dvodb", false, false);
    130     PXOPT_LOOKUP_STR(label,       config->args, "-set_label", false, false);
    131     PXOPT_LOOKUP_STR(data_group,  config->args, "-set_data_group", false, false);
    132     PXOPT_LOOKUP_STR(reduction,   config->args, "-set_reduction", false, false);
    133     PXOPT_LOOKUP_STR(note,        config->args, "-set_note", false, false);
     128    PXOPT_LOOKUP_STR(workdir,         config->args, "-set_workdir", false, false);
     129    PXOPT_LOOKUP_STR(dvodb,           config->args, "-set_dvodb", false, false);
     130    PXOPT_LOOKUP_STR(label,           config->args, "-set_label", false, false);
     131    PXOPT_LOOKUP_STR(data_group,      config->args, "-set_data_group", false, false);
     132    PXOPT_LOOKUP_STR(reduction,       config->args, "-set_reduction", false, false);
     133    PXOPT_LOOKUP_STR(note,            config->args, "-set_note", false, false);
    134134    PXOPT_LOOKUP_STR(minidvodb_name,  config->args, "-set_minidvodb_name", false, false);
    135135    PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false);
    136136    PXOPT_LOOKUP_STR(minidvodb_host,  config->args, "-set_minidvodb_host",  false, false);
    137     PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false);
    138     PXOPT_LOOKUP_BOOL(minidvodb,  config->args, "-set_minidvodb", false);
    139     PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);
    140     PXOPT_LOOKUP_BOOL(uncensored, config->args, "-uncensored", false);
    141     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    142 
    143     PXOPT_LOOKUP_BOOL(pretend,    config->args, "-pretend", false);
    144     PXOPT_LOOKUP_BOOL(simple,     config->args, "-simple", false);
     137    PXOPT_LOOKUP_BOOL(image_only,     config->args, "-image_only", false);
     138    PXOPT_LOOKUP_BOOL(minidvodb,      config->args, "-set_minidvodb", false);
     139
     140    PXOPT_LOOKUP_U64(limit,           config->args, "-limit", false, false);
     141    PXOPT_LOOKUP_BOOL(pretend,        config->args, "-pretend", false);
     142    PXOPT_LOOKUP_BOOL(simple,         config->args, "-simple", false);
    145143   
    146     PXOPT_LOOKUP_F32(minra,     config->args, "-set_minra", false, false);
    147     PXOPT_LOOKUP_F32(maxra,     config->args, "-set_maxra", false, false);
    148     PXOPT_LOOKUP_F32(mindec,     config->args, "-set_mindec", false, false);
    149     PXOPT_LOOKUP_F32(maxdec,     config->args, "-set_maxdec", false, false);
     144    PXOPT_LOOKUP_F32(minra,           config->args, "-set_minra", false, false);
     145    PXOPT_LOOKUP_F32(maxra,           config->args, "-set_maxra", false, false);
     146    PXOPT_LOOKUP_F32(mindec,          config->args, "-set_mindec", false, false);
     147    PXOPT_LOOKUP_F32(maxdec,          config->args, "-set_maxdec", false, false);
    150148
    151149    // Handle stages
    152     PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
     150    PXOPT_LOOKUP_STR(stage,           config->args, "-stage", false, false);
     151
     152    bool validStage = false;
    153153    if (strcmp(stage, "cam") == 0) {
    154       pxcamGetSearchArgs (config, where);
    155       pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
    156       pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    157       pxAddLabelSearchArgs (config, where,     "-filter",   "rawExp.filter", "LIKE"); // define using camRun label
    158       PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    159     }
    160     else if (strcmp(stage, "stack") == 0) {
    161       pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
    162       pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
    163       PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
    164       pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
    165     }
    166     else if (strcmp(stage, "staticsky") == 0) {
    167       pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
    168       pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
    169       PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyRun.reduction", "==");
    170       //no filter here
    171     }
    172     else if (strcmp(stage, "skycal") == 0) {
    173       pxAddLabelSearchArgs (config, where, "-label",     "skycalRun.label", "=="); //define using skycalRun label
    174       pxAddLabelSearchArgs (config, where, "-data_group","skycalRun.data_group", "==");
    175       PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction",  "==");
    176     }
    177     else if (strcmp(stage, "diff") == 0) {
    178       pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "=="); //define using diffRun label
    179       pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "==");
    180       PXOPT_COPY_STR(config->args, where,  "-reduction", "diffRun.reduction",  "==");
    181     }
    182     else if (strcmp(stage, "fullforce") == 0) {
    183       pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "=="); //define using fullForceRun label
    184       pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
    185       PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
    186     }
    187     else if (strcmp(stage, "fullforce_summary")==0) {
    188       //should be nearly identical to fullforce (uses the same tables)
    189       pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "==");
    190       pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
    191       PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
    192     }
    193  
     154        pxcamGetSearchArgs (config, where);
     155        pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     156        pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
     157        pxAddLabelSearchArgs (config, where, "-filter",   "rawExp.filter", "LIKE"); // define using camRun label
     158        PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
     159        validStage = true;
     160    }
     161    if (strcmp(stage, "skycal") == 0) {
     162        pxAddLabelSearchArgs (config, where, "-label",     "skycalRun.label", "=="); //define using skycalRun label
     163        pxAddLabelSearchArgs (config, where, "-data_group","skycalRun.data_group", "==");
     164        PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction",  "==");
     165        validStage = true;
     166    }
     167    if (strcmp(stage, "diff") == 0) {
     168        pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "=="); //define using diffRun label
     169        pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "==");
     170        PXOPT_COPY_STR(config->args, where,  "-reduction", "diffRun.reduction",  "==");
     171        validStage = true;
     172    }
     173    if (strcmp(stage, "fullforce") == 0) {
     174        pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "=="); //define using fullForceRun label
     175        pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
     176        PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
     177        validStage = true;
     178    }
     179    if (strcmp(stage, "fullforce_summary")==0) {
     180        //should be nearly identical to fullforce (uses the same tables)
     181        pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "==");
     182        pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
     183        PXOPT_COPY_STR(config->args, where,  "-reduction", "fullForceRun.reduction",  "==");
     184        validStage = true;
     185    }
     186    if (strcmp(stage, "xcff") == 0) {
     187        pxAddLabelSearchArgs (config, where, "-label",     "xcForceRun.label", "=="); //define using fullForceRun label
     188        pxAddLabelSearchArgs (config, where, "-data_group","xcForceRun.data_group", "==");
     189        PXOPT_COPY_STR(config->args, where,  "-reduction", "xcForceRun.reduction",  "==");
     190        validStage = true;
     191    }
     192    if (strcmp(stage, "xcff_summary")==0) {
     193        //should be nearly identical to fullforce (uses the same tables)
     194        pxAddLabelSearchArgs (config, where, "-label",     "xcForceRun.label", "==");
     195        pxAddLabelSearchArgs (config, where, "-data_group","xcForceRun.data_group", "==");
     196        PXOPT_COPY_STR(config->args, where,  "-reduction", "xcForceRun.reduction",  "==");
     197        validStage = true;
     198    }
     199    if (!validStage) {
     200        psFree(where);
     201        psError(PXTOOLS_ERR_CONFIG, false, "invalid stage specified");
     202        return false;
     203    }
     204
     205# if (0)
     206    if (strcmp(stage, "stack") == 0) {
     207        pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
     208        pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
     209        PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
     210        pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     211    }
     212    if (strcmp(stage, "staticsky") == 0) {
     213        pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
     214        pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     215        PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyRun.reduction", "==");
     216        //no filter here
     217    }
     218# endif
     219
    194220    if (!psListLength(where->list)) {
    195221        psFree(where);
     
    198224    }
    199225   
    200     // Select either destreaked or uncensored data.  CZW: Should this be defaulted to uncensored?
    201     if (!(destreaked && uncensored) && (destreaked || uncensored)) {
    202       //if one of destreaked and uncensored is true, but not both
    203       if (destreaked) {
    204         psTrace("addtool.c", PS_LOG_INFO, "using -destreaked\n");
    205       } else {
    206         psTrace("addtool.c", PS_LOG_INFO, "using -unscensored\n");
    207       }
    208     } else {
    209       if (destreaked && uncensored) {
    210         psError(PS_ERR_UNKNOWN, false, "Both -destreaked and -uncensored are selected. Please use one or the other, not both, \n");
    211         return false;
    212       }
    213       if (!destreaked && !uncensored) {
    214         psError(PS_ERR_UNKNOWN, false, "Neither -destreaked or -uncensored are selected. Please use one.\n");
    215         return false;
    216       }
    217     }
    218     if ((strcmp(stage,"diff") == 0) ||
    219         (strcmp(stage,"fullforce") == 0) ||
    220         (strcmp(stage,"fullforce_summary") == 0)) {
    221       if (! (dvodb)) {
    222         psError(PS_ERR_UNKNOWN, false, "The SQL is not correctly written to handle this case (-set_dvodb not specified), so stopping here.");
     226    // only cam stage can inherit dvodb from the camRun, for all others it must be supplied
     227    if (strcmp(stage, "cam") && !dvodb) {
     228        psError(PS_ERR_UNKNOWN, false, "the dvodb must be supplied for stage %s", stage);
    223229        return(false);
    224       }
    225     }
    226    
     230    }
    227231   
    228232    // prevent queueing an addRun if a given exposure has already been added to
     
    231235    psString bare_query = NULL;
    232236   
     237    // camRun can be supplied with a dvodb, in which case we can default to that
    233238    if (strcmp(stage,"cam") == 0 ) {
    234       if (dvodb) {
    235         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);
    236         // find the cam_id of all the exposures that we want to queue up.
    237         bare_query = pxDataGet("addtool_find_cam_id_dvo.sql");
     239        if (dvodb) {
     240            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);
     241            // find the cam_id of all the exposures that we want to queue up.
     242            bare_query = pxDataGet("addtool_find_cam_id_dvo.sql");
     243            // user supplied dvodb
     244            psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     245        } else {
     246            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);
     247            // find the cam_id of all the exposures that we want to queue up.
     248            bare_query = pxDataGet("addtool_find_cam_id.sql");
     249            // inherit dvodb from camRun, avoid matching NULL
     250            psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)");
     251        }
     252    }
     253    if (strcmp(stage,"skycal") == 0) {
     254        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_skycal_id_dvo.sql\n%s\n", dvodb,stage);
     255        // find the skycal_id of all the exposures that we want to queue up.
     256        bare_query = pxDataGet("addtool_find_skycal_id_dvo.sql");
    238257        // user supplied dvodb
    239258        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    240       } else {
    241         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);
    242         // find the cam_id of all the exposures that we want to queue up.
    243         bare_query = pxDataGet("addtool_find_cam_id.sql");
    244         // inherit dvodb from camRun, avoid matching NULL
    245         psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)");
    246       }
    247     }
    248 
    249     else if (strcmp(stage,"stack") == 0) {
    250       if (dvodb) {
    251         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);
    252         // find the cam_id of all the exposures that we want to queue up.
    253         bare_query = pxDataGet("addtool_find_stack_id_dvo.sql");
    254         // user supplied dvodb
    255         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    256       } else {
    257         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);
    258         // find the cam_id of all the exposures that we want to queue up.
    259         bare_query = pxDataGet("addtool_find_stack_id.sql");
    260         // inherit dvodb from camRun, avoid matching NULL
    261         psStringAppend(&dvodb_string, "(stackRun.dvodb IS NOT NULL AND previous_dvodb = stackRun.dvodb)");
    262       }
    263     }
    264 
    265     else if (strcmp(stage,"staticsky") == 0) {
    266       if (dvodb ) {
    267         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
    268         // find the cam_id of all the exposures that we want to queue up.
    269         bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
    270         // user supplied dvodb
    271         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    272       } else {
    273         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
    274         // find the cam_id of all the exposures that we want to queue up.
    275         bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
    276         // inherit dvodb from camRun, avoid matching NULL
    277         psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
    278       }
    279     }
    280 
    281     else if (strcmp(stage,"skycal") == 0) {
    282       if (dvodb) {
    283         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_skycal_id_dvo.sql\n%s\n", dvodb,stage);
    284         // find the skycal_id of all the exposures that we want to queue up.
    285         bare_query = pxDataGet("addtool_find_skycal_id_dvo.sql");
    286         // user supplied dvodb
    287         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    288       } else {
    289         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_skycal_id.sql\n%s\n",stage);
    290         // find the skycal_id of all the exposures that we want to queue up.
    291         bare_query = pxDataGet("addtool_find_skycal_id.sql");
    292         // inherit dvodb from skycalRun, avoid matching NULL
    293         psStringAppend(&dvodb_string, "(skycalRun.dvodb IS NOT NULL AND previous_dvodb = skycalRun.dvodb)");
    294         // this is silly, there is no dvodb in skycalRun...?
    295       }
    296     }
    297 
    298     else if (strcmp(stage,"diff") == 0) {
    299       if (dvodb) {
     259    }
     260
     261    if (strcmp(stage,"diff") == 0) {
    300262        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_diff_id_dvo.sql\n%s\n", dvodb,stage);
    301263        // find the skycal_id of all the exposures that we want to queue up.
     
    303265        // user supplied dvodb
    304266        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    305       } else {
    306         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_diff_id.sql\n%s\n",stage);
    307         // find the skycal_id of all the exposures that we want to queue up.
    308         bare_query = pxDataGet("addtool_find_diff_id.sql");
    309         // inherit dvodb from skycalRun, avoid matching NULL
    310         psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)");
    311         // this is silly, there is no dvodb in skycalRun...?
    312       }
    313     }
    314 
    315     else if (strcmp(stage,"fullforce") == 0) {
    316       if (dvodb) {
     267    }
     268    if (strcmp(stage,"fullforce") == 0) {
    317269        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ff_id_dvo.sql\n%s\n", dvodb,stage);
    318270        // find the skycal_id of all the exposures that we want to queue up.
     
    320272        // user supplied dvodb
    321273        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    322       } else {
    323         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ff_id.sql\n%s\n",stage);
    324         // find the skycal_id of all the exposures that we want to queue up.
    325         bare_query = pxDataGet("addtool_find_ff_id.sql");
    326         // inherit dvodb from skycalRun, avoid matching NULL
    327         psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
    328         // this is silly, there is no dvodb in skycalRun...?
    329       }
    330     }
    331     else if (strcmp(stage,"fullforce_summary") == 0) {
    332       if (dvodb) {
     274    }
     275    if (strcmp(stage,"fullforce_summary") == 0) {
    333276        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_ffsummary_id_dvo.sql\n%s\n", dvodb,stage);
    334277        // find the skycal_id of all the exposures that we want to queue up.
     
    336279        // user supplied dvodb
    337280        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    338       } else {
    339         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_ffsummary_id.sql\n%s\n",stage);
     281    }
     282    if (strcmp(stage,"xcff") == 0) {
     283        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_xcff_id_dvo.sql\n%s\n", dvodb,stage);
    340284        // find the skycal_id of all the exposures that we want to queue up.
    341         bare_query = pxDataGet("addtool_find_ffsummary_id.sql");
    342         // inherit dvodb from skycalRun, avoid matching NULL
    343         psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
    344         // this is silly, there is no dvodb in skycalRun...?
    345       }
    346     }
    347    
     285        bare_query = pxDataGet("addtool_find_xcff_id_dvo.sql");
     286        // user supplied dvodb
     287        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     288    }
     289    if (strcmp(stage,"xcff_summary") == 0) {
     290        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_xcffsummary_id_dvo.sql\n%s\n", dvodb,stage);
     291        // find the skycal_id of all the exposures that we want to queue up.
     292        bare_query = pxDataGet("addtool_find_xcffsummary_id_dvo.sql");
     293        // user supplied dvodb
     294        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     295    }
     296
     297// XXX EAM 20240204 : stack and staticsky are deprecated
     298# if (0)
     299    if (strcmp(stage,"stack") == 0) {
     300        if (dvodb) {
     301            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);
     302            // find the stack_id of all the exposures that we want to queue up.
     303            bare_query = pxDataGet("addtool_find_stack_id_dvo.sql");
     304            // user supplied dvodb
     305            psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     306        } else {
     307            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);
     308            // find the stack_id of all the exposures that we want to queue up.
     309            bare_query = pxDataGet("addtool_find_stack_id.sql");
     310            // inherit dvodb from camRun, avoid matching NULL
     311            psStringAppend(&dvodb_string, "(stackRun.dvodb IS NOT NULL AND previous_dvodb = stackRun.dvodb)");
     312        }
     313    }
     314    if (strcmp(stage,"staticsky") == 0) {
     315        if (dvodb ) {
     316            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
     317            // find the cam_id of all the exposures that we want to queue up.
     318            bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
     319            // user supplied dvodb
     320            psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     321        } else {
     322            psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
     323            // find the cam_id of all the exposures that we want to queue up.
     324            bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
     325            // inherit dvodb from camRun, avoid matching NULL
     326            psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)");
     327        }
     328    }
     329# endif
     330
    348331    if (!bare_query) {
    349332        psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     
    363346        psStringAppend(&query, " AND %s", whereClause);
    364347
    365         if ((strcmp(stage,"diff") == 0)||
    366             (strcmp(stage,"fullforce") == 0)||
    367             (strcmp(stage,"fullforce_summary") == 0)) {
    368           //diff needs the ra /deg stuff
    369           //ff needs the ra /deg stuff
    370           //ff summary needs the ra /deg stuff
    371           psStringAppend(&query, " AND radeg >= %f", minra);
    372           psStringAppend(&query, " AND radeg <= %f", maxra);
    373           psStringAppend(&query, " AND decdeg >= %f", mindec);
    374           psStringAppend(&query, " AND decdeg <= %f", maxdec);
    375         }
    376 
    377         psFree(whereClause);
     348        // diff, ff, ff_summary, xcff, xcff_summary all need the RA,DEC range restricted
     349        // (to avoid excessively long query times)
     350
     351        if (!strcmp(stage,"diff") ||
     352            !strcmp(stage,"fullforce") ||
     353            !strcmp(stage,"fullforce_summary") ||
     354            !strcmp(stage,"xcff") ||
     355            !strcmp(stage,"xcff_summary")) {
     356            if (!isfinite(minra) || !isfinite(maxra) || !isfinite(mindec) || !isfinite(maxra)) {
     357                psError(PS_ERR_UNKNOWN, true, "invalid or missing RA,DEC search parameters");
     358                return false;
     359            }
     360            psStringAppend(&query, " AND radeg >= %f", minra);
     361            psStringAppend(&query, " AND radeg <= %f", maxra);
     362            psStringAppend(&query, " AND decdeg >= %f", mindec);
     363            psStringAppend(&query, " AND decdeg <= %f", maxdec);
     364        }
     365        psFree(whereClause);
    378366    } else {
    379         psError(PS_ERR_UNKNOWN, true, "search parameters are required");
    380         return false;
     367        psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     368        return false;
    381369    }
    382370    psFree(where);
    383371
    384     if (destreaked) {
    385       //This picks the magicked/censored ones
    386       if ((strcmp(stage,"cam") == 0)||
    387           (strcmp(stage,"stack") == 0)) {
    388         psStringAppend(&query, " AND (camRun.magicked > 0)");
    389       }
    390       // staticSky/skycal have no magicked column.
    391     } else {
    392       //This picks only the unmagicked/uncensored ones
    393       //if (strcmp(stage,"cam") == 0) {
    394         //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored.
    395         //psStringAppend(&query, " AND (camRun.magicked = 0)");
    396         //}
    397       if (strcmp(stage,"stack") == 0) {
    398         psStringAppend(&query, " AND (stackRun.magicked = 0)");
    399       }
    400     }
    401 
    402372    // if we grab a group of camRun/stackRuns that have multiple camRun/stackRun pointing to the same exp_id/stack_id, and that exp_id/stack_id has never before been added to addRun, we need to group by exp_id/stack_id to ensure that only 1 of the camRun/stackRun for that exp_id is added to the addRun stage.
     373
     374    // XXX EAM 20240204 : this code is bad because it allows the definebyquery to select a set of exposures that have been
     375    // processed multiple times.  the GROUP BY selects an entry without any guarantee this selection is the one
     376    // which is desired.
    403377   
    404378    if (strcmp(stage,"cam") == 0) {
    405       psStringAppend(&query, " GROUP BY exp_id");
     379        psStringAppend(&query, " GROUP BY exp_id");
    406380    }
    407381    else if (strcmp(stage,"stack") == 0) {
    408       psStringAppend(&query, " GROUP BY stack_id");
     382        psStringAppend(&query, " GROUP BY stack_id");
    409383    }
    410384    else if (strcmp(stage,"staticsky") == 0) {
    411       psStringAppend(&query, " GROUP BY sky_id, stack_id");  //some reason it needs this
     385        psStringAppend(&query, " GROUP BY sky_id, stack_id");  //some reason it needs this
    412386    }
    413387    else if (strcmp(stage,"skycal") == 0) {
    414       psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_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
     388        psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_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
    415389    }
    416390    //needs to be checked HAF xxx
    417391    else if (strcmp(stage,"diff") == 0) {
    418       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
     392        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
    419393    }
    420394    //needs to be checked HAF xxx
    421395    else if (strcmp(stage,"fullforce") == 0) {
    422       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
     396        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
    423397    }
    424398    else if (strcmp(stage,"fullforce_summary") == 0) {
    425       psStringAppend(&query, " GROUP BY ff_id ");  //needs to be checked, but should be fine: want 1 ff summary cmf.
     399        psStringAppend(&query, " GROUP BY ff_id ");  //needs to be checked, but should be fine: want 1 ff summary cmf.
     400    }
     401    else if (strcmp(stage,"xcff") == 0) {
     402        psStringAppend(&query, " GROUP BY xcff_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
     403    }
     404    else if (strcmp(stage,"xcff_summary") == 0) {
     405        psStringAppend(&query, " GROUP BY xcff_id ");  //needs to be checked, but should be fine: want 1 ff summary cmf.
    426406    }
    427407
     
    438418
    439419    if (!p_psDBRunQuery(config->dbh, query)) {
    440       psError(PS_ERR_UNKNOWN, false, "database error, \n%s\n", query);
    441       psFree(query);
    442       return false;
     420        psError(PS_ERR_UNKNOWN, false, "database error, \n%s\n", query);
     421        psFree(query);
     422        return false;
    443423    }
    444424    psFree(query);
     
    446426    psArray *output = p_psDBFetchResult(config->dbh);
    447427    if (!output) {
    448       psError(PS_ERR_UNKNOWN, false, "database error");
    449       return false;
     428        psError(PS_ERR_UNKNOWN, false, "database error");
     429        return false;
    450430    }
    451431    if (!psArrayLength(output)) {
    452       psTrace("addtool", PS_LOG_INFO, "no rows found");
    453       psFree(output);
    454       return true;
     432        psTrace("addtool", PS_LOG_INFO, "no rows found");
     433        psFree(output);
     434        return true;
    455435    }
    456436   
    457437    if (pretend) {
    458       // negative simple so the default is true
    459       if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
    460         psError(PS_ERR_UNKNOWN, false, "failed to print array");
     438        // negative simple so the default is true
     439        if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
     440            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     441            psFree(output);
     442            return false;
     443        }
    461444        psFree(output);
    462         return false;
    463       }
    464       psFree(output);
    465       return true;
     445        return true;
    466446    }
    467447   
    468448    // loop over our list of camRun rows to check the supplied and selected dvodb and workdir values:
    469449    if (strcmp(stage,"cam") == 0) {
    470       for (long i = 0; i < psArrayLength(output); i++) {
    471         psMetadata *md = output->data[i];
    472        
    473         camRunRow *row = camRunObjectFromMetadata(md);
    474        
    475         if (!row) {
    476           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    477           psFree(output);
    478           return false;
    479         }
    480        
    481         if (!dvodb && !row->dvodb) {
    482           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);
    483           psFree(output);
    484           return false;
    485         }
    486         if (!workdir && !row->workdir) {
    487           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);
    488           psFree(output);
    489           return false;
    490         }
    491        
    492         psFree(row);
    493       }
     450        for (long i = 0; i < psArrayLength(output); i++) {
     451            psMetadata *md = output->data[i];
     452       
     453            camRunRow *row = camRunObjectFromMetadata(md);
     454       
     455            if (!row) {
     456                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     457                psFree(output);
     458                return false;
     459            }
     460       
     461            if (!dvodb && !row->dvodb) {
     462                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);
     463                psFree(output);
     464                return false;
     465            }
     466            if (!workdir && !row->workdir) {
     467                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);
     468                psFree(output);
     469                return false;
     470            }
     471       
     472            psFree(row);
     473        }
    494474    }
    495475    else if (strcmp(stage,"stack") == 0) {
    496       for (long i = 0; i < psArrayLength(output); i++) {
    497         psMetadata *md = output->data[i];
    498        
    499         stackRunRow *row = stackRunObjectFromMetadata(md);
    500        
    501         if (!row) {
    502           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    503           psFree(output);
    504           return false;
    505         }
    506        
    507         if (!dvodb && !row->dvodb) {
    508           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);
    509           psFree(output);
    510           return false;
    511         }
    512         if (!workdir && !row->workdir) {
    513           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);
    514           psFree(output);
    515           return false;
    516         }
    517        
    518         psFree(row);
    519       }
     476        for (long i = 0; i < psArrayLength(output); i++) {
     477            psMetadata *md = output->data[i];
     478       
     479            stackRunRow *row = stackRunObjectFromMetadata(md);
     480       
     481            if (!row) {
     482                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     483                psFree(output);
     484                return false;
     485            }
     486       
     487            if (!dvodb && !row->dvodb) {
     488                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     489                psFree(output);
     490                return false;
     491            }
     492            if (!workdir && !row->workdir) {
     493                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     494                psFree(output);
     495                return false;
     496            }
     497       
     498            psFree(row);
     499        }
    520500    }
    521501    else if (strcmp(stage,"staticsky") == 0) {
    522       for (long i = 0; i < psArrayLength(output); i++) {
    523         psMetadata *md = output->data[i];
    524         bool status = false;
    525         psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
    526         if (!status) {
    527           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
    528           return false;
    529         }
    530         if (num_inputs < 0) {
    531           psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
    532           return false;
    533         }
    534        
    535         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    536        
    537         if (!row) {
    538           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    539           psFree(output);
    540           return false;
    541         }
    542        
    543         if (!dvodb) {  //there's no staticsky.dvodb
    544           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    545           psFree(output);
    546           return false;
    547         }
    548         if (!workdir && !row->workdir) {
    549           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    550           psFree(output);
    551           return false;
    552         }
    553        
    554         psFree(row);
    555       }
     502        for (long i = 0; i < psArrayLength(output); i++) {
     503            psMetadata *md = output->data[i];
     504            bool status = false;
     505            psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     506            if (!status) {
     507                psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     508                return false;
     509            }
     510            if (num_inputs < 0) {
     511                psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
     512                return false;
     513            }
     514       
     515            staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     516       
     517            if (!row) {
     518                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     519                psFree(output);
     520                return false;
     521            }
     522       
     523            if (!dvodb) {  //there's no staticsky.dvodb
     524                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     525                psFree(output);
     526                return false;
     527            }
     528            if (!workdir && !row->workdir) {
     529                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     530                psFree(output);
     531                return false;
     532            }
     533       
     534            psFree(row);
     535        }
    556536    }
    557537    else if (strcmp(stage,"skycal") == 0) {
    558       for (long i = 0; i < psArrayLength(output); i++) {
    559         psMetadata *md = output->data[i];
    560        
    561         skycalRunRow *row = skycalRunObjectFromMetadata(md);
    562 
    563         if (!row) {
    564           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    565           psFree(output);
    566           return false;
    567         }
    568        
    569         if (!dvodb) {  // there's no skycalRun.dvodb
    570           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
    571           psFree(output);
    572           return false;
    573         }
    574         if (!workdir && !row->workdir) {
    575           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
    576           psFree(output);
    577           return false;
    578         }
    579        
    580         psFree(row);
    581       }
     538        for (long i = 0; i < psArrayLength(output); i++) {
     539            psMetadata *md = output->data[i];
     540       
     541            skycalRunRow *row = skycalRunObjectFromMetadata(md);
     542
     543            if (!row) {
     544                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     545                psFree(output);
     546                return false;
     547            }
     548       
     549            if (!dvodb) {  // there's no skycalRun.dvodb
     550                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     551                psFree(output);
     552                return false;
     553            }
     554            if (!workdir && !row->workdir) {
     555                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     556                psFree(output);
     557                return false;
     558            }
     559       
     560            psFree(row);
     561        }
    582562    }
    583563    else if (strcmp(stage,"diff") == 0) {
    584       for (long i = 0; i < psArrayLength(output); i++) {
    585         psMetadata *md = output->data[i];
    586        
    587         diffRunRow *row = diffRunObjectFromMetadata(md);
    588        
    589         if (!row) {
    590           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
    591           psFree(output);
    592           return false;
    593         }
    594        
    595         if (!dvodb) {  // there's no skycalRun.dvodb
    596           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
    597           psFree(output);
    598           return false;
    599         }
    600         if (!workdir && !row->workdir) {
    601           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
    602           psFree(output);
    603           return false;
    604         }
    605        
    606         psFree(row);
    607       }
     564        for (long i = 0; i < psArrayLength(output); i++) {
     565            psMetadata *md = output->data[i];
     566       
     567            diffRunRow *row = diffRunObjectFromMetadata(md);
     568       
     569            if (!row) {
     570                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
     571                psFree(output);
     572                return false;
     573            }
     574       
     575            if (!dvodb) {  // there's no skycalRun.dvodb
     576                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     577                psFree(output);
     578                return false;
     579            }
     580            if (!workdir && !row->workdir) {
     581                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     582                psFree(output);
     583                return false;
     584            }
     585       
     586            psFree(row);
     587        }
    608588    }
    609589    else if (strcmp(stage,"fullforce") == 0) {
    610       for (long i = 0; i < psArrayLength(output); i++) {
    611         psMetadata *md = output->data[i];
    612        
    613         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    614        
    615         if (!row) {
    616           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    617           psFree(output);
    618           return false;
    619         }
    620 
    621         if (!dvodb) {  // there's no skycalRun.dvodb
    622           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    623           psFree(output);
    624           return false;
    625         }
    626         if (!workdir && !row->workdir) {
    627           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    628           psFree(output);
    629           return false;
    630         }
    631        
    632         psFree(row);
    633       }
     590        for (long i = 0; i < psArrayLength(output); i++) {
     591            psMetadata *md = output->data[i];
     592       
     593            fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     594       
     595            if (!row) {
     596                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     597                psFree(output);
     598                return false;
     599            }
     600
     601            if (!dvodb) {  // there's no skycalRun.dvodb
     602                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     603                psFree(output);
     604                return false;
     605            }
     606            if (!workdir && !row->workdir) {
     607                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     608                psFree(output);
     609                return false;
     610            }
     611       
     612            psFree(row);
     613        }
    634614    }
    635615    else if (strcmp(stage,"fullforce_summary") == 0) {
    636       for (long i = 0; i < psArrayLength(output); i++) {
    637         psMetadata *md = output->data[i];
    638         //i believe this is correct for ff_summary as well:
    639         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    640        
    641         if (!row) {
    642           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    643           psFree(output);
    644           return false;
    645         }
    646        
    647         if (!dvodb) {  // there's no skycalRun.dvodb
    648           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    649           psFree(output);
    650           return false;
    651         }
    652         if (!workdir && !row->workdir) {
    653           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    654           psFree(output);
    655           return false;
    656         }
    657        
    658         psFree(row);
    659       }
     616        for (long i = 0; i < psArrayLength(output); i++) {
     617            psMetadata *md = output->data[i];
     618            //i believe this is correct for ff_summary as well:
     619            fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     620       
     621            if (!row) {
     622                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     623                psFree(output);
     624                return false;
     625            }
     626       
     627            if (!dvodb) {  // there's no skycalRun.dvodb
     628                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     629                psFree(output);
     630                return false;
     631            }
     632            if (!workdir && !row->workdir) {
     633                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     634                psFree(output);
     635                return false;
     636            }
     637       
     638            psFree(row);
     639        }
     640    }
     641    else if (strcmp(stage,"xcff") == 0) {
     642        for (long i = 0; i < psArrayLength(output); i++) {
     643            psMetadata *md = output->data[i];
     644       
     645            xcForceRunRow *row = xcForceRunObjectFromMetadata(md);
     646       
     647            if (!row) {
     648                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into xcforceRun");
     649                psFree(output);
     650                return false;
     651            }
     652
     653            if (!dvodb) {  // there's no skycalRun.dvodb
     654                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, xcff_id %" PRId64, row->label, row->xcff_id);
     655                psFree(output);
     656                return false;
     657            }
     658            if (!workdir && !row->workdir) {
     659                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, xcff_id %" PRId64, row->label, row->xcff_id);
     660                psFree(output);
     661                return false;
     662            }
     663       
     664            psFree(row);
     665        }
     666    }
     667    else if (strcmp(stage,"xcff_summary") == 0) {
     668        for (long i = 0; i < psArrayLength(output); i++) {
     669            psMetadata *md = output->data[i];
     670            //i believe this is correct for ff_summary as well:
     671            xcForceRunRow *row = xcForceRunObjectFromMetadata(md);
     672       
     673            if (!row) {
     674                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     675                psFree(output);
     676                return false;
     677            }
     678       
     679            if (!dvodb) {
     680                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->xcff_id);
     681                psFree(output);
     682                return false;
     683            }
     684            if (!workdir && !row->workdir) {
     685                psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->xcff_id);
     686                psFree(output);
     687                return false;
     688            }
     689       
     690            psFree(row);
     691        }
    660692    }
    661693   
     
    676708   
    677709    if (strcmp(stage,"cam") == 0) {
    678       // loop over our list of camRun rows
    679       for (long i = 0; i < psArrayLength(output); i++) {
    680         psMetadata *md = output->data[i];
    681         psS64 stage_id =0;
    682        
    683         camRunRow *row = camRunObjectFromMetadata(md);
    684         stage_id = row->cam_id;
    685        
    686         if (!row) {
    687           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    688           psFree(output);
    689           return false;
    690         }
    691        
    692         // queue the exp
    693         if (!pxaddQueueByCamID(config,
    694                                stage,
    695                                stage_id,
    696                                0,
    697                                workdir     ? workdir   : row->workdir,
    698                                reduction   ? reduction : row->reduction,
    699                                label       ? label     : row->label,
    700                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    701                                dvodb       ? dvodb     : row->dvodb,
    702                                note        ? note      : NULL,
    703                                image_only,
    704                                minidvodb,
    705                                minidvodb_group,
    706                                minidvodb_name,
    707                                minidvodb_host
    708                                )) {
    709           if (!psDBRollback(config->dbh)) {
    710             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    711           }
    712           psError(PS_ERR_UNKNOWN, false,
    713                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    714           psFree(row);
    715           psFree(output);
    716           return false;
    717         }
    718         psFree(row);
    719       }
     710        // loop over our list of camRun rows
     711        for (long i = 0; i < psArrayLength(output); i++) {
     712            psMetadata *md = output->data[i];
     713            psS64 stage_id =0;
     714       
     715            camRunRow *row = camRunObjectFromMetadata(md);
     716            stage_id = row->cam_id;
     717       
     718            if (!row) {
     719                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     720                psFree(output);
     721                return false;
     722            }
     723       
     724            // queue the exp
     725            if (!pxaddQueueByCamID(config,
     726                                   stage,
     727                                   stage_id,
     728                                   0,
     729                                   workdir     ? workdir   : row->workdir,
     730                                   reduction   ? reduction : row->reduction,
     731                                   label       ? label     : row->label,
     732                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     733                                   dvodb       ? dvodb     : row->dvodb,
     734                                   note        ? note      : NULL,
     735                                   image_only,
     736                                   minidvodb,
     737                                   minidvodb_group,
     738                                   minidvodb_name,
     739                                   minidvodb_host
     740                    )) {
     741                if (!psDBRollback(config->dbh)) {
     742                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     743                }
     744                psError(PS_ERR_UNKNOWN, false,
     745                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     746                psFree(row);
     747                psFree(output);
     748                return false;
     749            }
     750            psFree(row);
     751        }
    720752    }
    721753    else if (strcmp(stage,"stack") == 0) {
    722       for (long i = 0; i < psArrayLength(output); i++) {
    723         psMetadata *md = output->data[i];
    724         psS64 stage_id =0;
    725        
    726         stackRunRow *row = stackRunObjectFromMetadata(md);
    727         stage_id = row->stack_id;
    728        
    729         if (!row) {
    730           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    731           psFree(output);
    732           return false;
    733         }
    734        
    735         // queue the exp
    736         if (!pxaddQueueByCamID(config,
    737                                stage,
    738                                stage_id,
    739                                0,
    740                                workdir     ? workdir   : row->workdir,
    741                                reduction   ? reduction : row->reduction,
    742                                label       ? label     : row->label,
    743                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    744                                dvodb       ? dvodb     : row->dvodb,
    745                                note        ? note      : NULL,
    746                                image_only,
    747                                minidvodb,
    748                                minidvodb_group,
    749                                minidvodb_name,
    750                                minidvodb_host
    751                                )) {
    752           if (!psDBRollback(config->dbh)) {
    753             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    754           }
    755           psError(PS_ERR_UNKNOWN, false,
    756                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    757           psFree(row);
    758           psFree(output);
    759           return false;
    760         }
    761         psFree(row);
    762       }
     754        for (long i = 0; i < psArrayLength(output); i++) {
     755            psMetadata *md = output->data[i];
     756            psS64 stage_id =0;
     757       
     758            stackRunRow *row = stackRunObjectFromMetadata(md);
     759            stage_id = row->stack_id;
     760       
     761            if (!row) {
     762                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     763                psFree(output);
     764                return false;
     765            }
     766       
     767            // queue the exp
     768            if (!pxaddQueueByCamID(config,
     769                                   stage,
     770                                   stage_id,
     771                                   0,
     772                                   workdir     ? workdir   : row->workdir,
     773                                   reduction   ? reduction : row->reduction,
     774                                   label       ? label     : row->label,
     775                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     776                                   dvodb       ? dvodb     : row->dvodb,
     777                                   note        ? note      : NULL,
     778                                   image_only,
     779                                   minidvodb,
     780                                   minidvodb_group,
     781                                   minidvodb_name,
     782                                   minidvodb_host
     783                    )) {
     784                if (!psDBRollback(config->dbh)) {
     785                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     786                }
     787                psError(PS_ERR_UNKNOWN, false,
     788                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     789                psFree(row);
     790                psFree(output);
     791                return false;
     792            }
     793            psFree(row);
     794        }
    763795    }
    764796    else if (strcmp(stage,"staticsky") == 0) {
    765       for (long i = 0; i < psArrayLength(output); i++) {
    766         psMetadata *md = output->data[i];
    767         psS64 stage_id =0;
    768         bool status = false;
    769         //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
    770         psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");
    771        
    772         if (!status) {
    773           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");
    774           return false;
    775         }
    776         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    777         stage_id = row->sky_id;
    778        
    779         if (!row) {
    780           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    781           psFree(output);
    782           return false;
    783         }
    784         // queue the exp
    785         //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
    786         if (!pxaddQueueByCamID(config,
    787                                stage,
    788                                stage_id,
    789                                stack_id,
    790                                workdir     ? workdir   : row->workdir,
    791                                reduction   ? reduction : row->reduction,
    792                                label       ? label     : row->label,
    793                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    794                                dvodb       ? dvodb     : NULL,
    795                                note        ? note      : NULL,
    796                                image_only,
    797                                minidvodb,
    798                                minidvodb_group,
    799                                minidvodb_name,
    800                                minidvodb_host
    801                                )) {
    802           if (!psDBRollback(config->dbh)) {
    803             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    804           }
    805           psError(PS_ERR_UNKNOWN, false,
    806                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    807           psFree(row);
    808           psFree(output);
    809           return false;
    810         }
    811         //}
    812         psFree(row);
    813       }
     797        for (long i = 0; i < psArrayLength(output); i++) {
     798            psMetadata *md = output->data[i];
     799            psS64 stage_id =0;
     800            bool status = false;
     801            //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     802            psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");
     803       
     804            if (!status) {
     805                psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");
     806                return false;
     807            }
     808            staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     809            stage_id = row->sky_id;
     810       
     811            if (!row) {
     812                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     813                psFree(output);
     814                return false;
     815            }
     816            // queue the exp
     817            //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
     818            if (!pxaddQueueByCamID(config,
     819                                   stage,
     820                                   stage_id,
     821                                   stack_id,
     822                                   workdir     ? workdir   : row->workdir,
     823                                   reduction   ? reduction : row->reduction,
     824                                   label       ? label     : row->label,
     825                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     826                                   dvodb       ? dvodb     : NULL,
     827                                   note        ? note      : NULL,
     828                                   image_only,
     829                                   minidvodb,
     830                                   minidvodb_group,
     831                                   minidvodb_name,
     832                                   minidvodb_host
     833                    )) {
     834                if (!psDBRollback(config->dbh)) {
     835                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     836                }
     837                psError(PS_ERR_UNKNOWN, false,
     838                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     839                psFree(row);
     840                psFree(output);
     841                return false;
     842            }
     843            //}
     844            psFree(row);
     845        }
    814846    }
    815847    else if (strcmp(stage,"skycal") == 0) {
    816       for (long i = 0; i < psArrayLength(output); i++) {
    817         psMetadata *md = output->data[i];
    818         psS64 stage_id =0;
    819        
    820         skycalRunRow *row = skycalRunObjectFromMetadata(md);
    821         stage_id = row->skycal_id;
    822        
    823         if (!row) {
    824           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    825           psFree(output);
    826           return false;
    827         }
    828        
    829         // queue the exp
    830         if (!pxaddQueueByCamID(config,
    831                                stage,
    832                                stage_id,
    833                                0,
    834                                workdir     ? workdir   : row->workdir,
    835                                reduction   ? reduction : row->reduction,
    836                                label       ? label     : row->label,
    837                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    838                                dvodb       ? dvodb     : NULL,
    839                                note        ? note      : NULL,
    840                                image_only,
    841                                minidvodb,
    842                                minidvodb_group,
    843                                minidvodb_name,
    844                                minidvodb_host
    845                                )) {
    846           if (!psDBRollback(config->dbh)) {
    847             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    848           }
    849           psError(PS_ERR_UNKNOWN, false,
    850                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    851           psFree(row);
    852           psFree(output);
    853           return false;
    854         }
    855         psFree(row);
    856       }
     848        for (long i = 0; i < psArrayLength(output); i++) {
     849            psMetadata *md = output->data[i];
     850            psS64 stage_id =0;
     851       
     852            skycalRunRow *row = skycalRunObjectFromMetadata(md);
     853            stage_id = row->skycal_id;
     854       
     855            if (!row) {
     856                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     857                psFree(output);
     858                return false;
     859            }
     860       
     861            // queue the exp
     862            if (!pxaddQueueByCamID(config,
     863                                   stage,
     864                                   stage_id,
     865                                   0,
     866                                   workdir     ? workdir   : row->workdir,
     867                                   reduction   ? reduction : row->reduction,
     868                                   label       ? label     : row->label,
     869                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     870                                   dvodb       ? dvodb     : NULL,
     871                                   note        ? note      : NULL,
     872                                   image_only,
     873                                   minidvodb,
     874                                   minidvodb_group,
     875                                   minidvodb_name,
     876                                   minidvodb_host
     877                    )) {
     878                if (!psDBRollback(config->dbh)) {
     879                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     880                }
     881                psError(PS_ERR_UNKNOWN, false,
     882                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     883                psFree(row);
     884                psFree(output);
     885                return false;
     886            }
     887            psFree(row);
     888        }
    857889    }
    858890    else if (strcmp(stage,"diff") == 0) {
    859       for (long i = 0; i < psArrayLength(output); i++) {
    860         psMetadata *md = output->data[i];
    861         psS64 stage_id =0;
    862         //      psS64 stage_extra1 = 0;
    863         diffRunRow *row = diffRunObjectFromMetadata(md);
    864         stage_id = row->diff_id;
    865         bool status = false;
    866         psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
    867         if (!status) {
    868           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
    869           return false;
    870         }
    871        
    872         if (!row) {
    873           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    874           psFree(output);
    875           return false;
    876         }
    877        
    878         // queue the exp
    879         if (!pxaddQueueByCamID(config,
    880                                stage,
    881                                stage_id,
    882                                stage_extra1,
    883                                workdir     ? workdir   : row->workdir,
    884                                reduction   ? reduction : row->reduction,
    885                                label       ? label     : row->label,
    886                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    887                                dvodb       ? dvodb     : NULL,
    888                                note        ? note      : NULL,
    889                                image_only,
    890                                minidvodb,
    891                                minidvodb_group,
    892                                minidvodb_name,
    893                                minidvodb_host
    894                                )) {
    895           if (!psDBRollback(config->dbh)) {
    896             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    897           }
    898           psError(PS_ERR_UNKNOWN, false,
    899                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    900           psFree(row);
    901           psFree(output);
    902           return false;
    903         }
    904         psFree(row);
    905       }
     891        for (long i = 0; i < psArrayLength(output); i++) {
     892            psMetadata *md = output->data[i];
     893            psS64 stage_id =0;
     894            //  psS64 stage_extra1 = 0;
     895            diffRunRow *row = diffRunObjectFromMetadata(md);
     896            stage_id = row->diff_id;
     897            bool status = false;
     898            psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
     899            if (!status) {
     900                psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
     901                return false;
     902            }
     903       
     904            if (!row) {
     905                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     906                psFree(output);
     907                return false;
     908            }
     909       
     910            // queue the exp
     911            if (!pxaddQueueByCamID(config,
     912                                   stage,
     913                                   stage_id,
     914                                   stage_extra1,
     915                                   workdir     ? workdir   : row->workdir,
     916                                   reduction   ? reduction : row->reduction,
     917                                   label       ? label     : row->label,
     918                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     919                                   dvodb       ? dvodb     : NULL,
     920                                   note        ? note      : NULL,
     921                                   image_only,
     922                                   minidvodb,
     923                                   minidvodb_group,
     924                                   minidvodb_name,
     925                                   minidvodb_host
     926                    )) {
     927                if (!psDBRollback(config->dbh)) {
     928                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     929                }
     930                psError(PS_ERR_UNKNOWN, false,
     931                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     932                psFree(row);
     933                psFree(output);
     934                return false;
     935            }
     936            psFree(row);
     937        }
    906938    }
    907939    else if (strcmp(stage,"fullforce") == 0) {
    908       for (long i = 0; i < psArrayLength(output); i++) {
    909         psMetadata *md = output->data[i];
    910         psS64 stage_id =0;
    911        
    912         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    913         stage_id = row->ff_id;
    914         bool status = false;
    915         psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
    916         if (!status) {
    917           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
    918           return false;
    919         }
    920        
    921         if (!row) {
    922           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    923           psFree(output);
    924           return false;
    925         }
    926        
    927         // queue the exp
    928         if (!pxaddQueueByCamID(config,
    929                                stage,
    930                                stage_id,
    931                                stage_extra1,
    932                                workdir     ? workdir   : row->workdir,
    933                                reduction   ? reduction : row->reduction,
    934                                label       ? label     : row->label,
    935                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    936                                dvodb       ? dvodb     : NULL,
    937                                note        ? note      : NULL,
    938                                image_only,
    939                                minidvodb,
    940                                minidvodb_group,
    941                                minidvodb_name,
    942                                minidvodb_host
    943                                )) {
    944           if (!psDBRollback(config->dbh)) {
    945             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    946           }
    947           psError(PS_ERR_UNKNOWN, false,
    948                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    949           psFree(row);
    950           psFree(output);
    951           return false;
    952         }
    953         psFree(row);
    954       }
     940        for (long i = 0; i < psArrayLength(output); i++) {
     941            psMetadata *md = output->data[i];
     942            psS64 stage_id =0;
     943       
     944            fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     945            stage_id = row->ff_id;
     946            bool status = false;
     947            psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
     948            if (!status) {
     949                psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
     950                return false;
     951            }
     952       
     953            if (!row) {
     954                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     955                psFree(output);
     956                return false;
     957            }
     958       
     959            // queue the exp
     960            if (!pxaddQueueByCamID(config,
     961                                   stage,
     962                                   stage_id,
     963                                   stage_extra1,
     964                                   workdir     ? workdir   : row->workdir,
     965                                   reduction   ? reduction : row->reduction,
     966                                   label       ? label     : row->label,
     967                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     968                                   dvodb       ? dvodb     : NULL,
     969                                   note        ? note      : NULL,
     970                                   image_only,
     971                                   minidvodb,
     972                                   minidvodb_group,
     973                                   minidvodb_name,
     974                                   minidvodb_host
     975                    )) {
     976                if (!psDBRollback(config->dbh)) {
     977                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     978                }
     979                psError(PS_ERR_UNKNOWN, false,
     980                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     981                psFree(row);
     982                psFree(output);
     983                return false;
     984            }
     985            psFree(row);
     986        }
    955987    }
    956988    else if (strcmp(stage,"fullforce_summary") == 0) {
    957       for (long i = 0; i < psArrayLength(output); i++) {
    958         psMetadata *md = output->data[i];
    959         psS64 stage_id =0;
    960        
    961         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    962         stage_id = row->ff_id;
    963        
    964         if (!row) {
    965           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    966           psFree(output);
    967           return false;
    968         }
    969        
    970         // queue the exp
    971         if (!pxaddQueueByCamID(config,
    972                                stage,
    973                                stage_id,
    974                                0,
    975                                workdir     ? workdir   : row->workdir,
    976                                reduction   ? reduction : row->reduction,
    977                                label       ? label     : row->label,
    978                                data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
    979                                dvodb       ? dvodb     : NULL,
    980                                note        ? note      : NULL,
    981                                image_only,
    982                                minidvodb,
    983                                minidvodb_group,
    984                                minidvodb_name,
    985                                minidvodb_host
    986                                )) {
    987           if (!psDBRollback(config->dbh)) {
    988             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    989           }
    990           psError(PS_ERR_UNKNOWN, false,
    991                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    992           psFree(row);
    993           psFree(output);
    994           return false;
    995         }
    996         psFree(row);
    997       }
     989        for (long i = 0; i < psArrayLength(output); i++) {
     990            psMetadata *md = output->data[i];
     991            psS64 stage_id =0;
     992       
     993            fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     994            stage_id = row->ff_id;
     995       
     996            if (!row) {
     997                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     998                psFree(output);
     999                return false;
     1000            }
     1001       
     1002            // queue the exp
     1003            if (!pxaddQueueByCamID(config,
     1004                                   stage,
     1005                                   stage_id,
     1006                                   0,
     1007                                   workdir     ? workdir   : row->workdir,
     1008                                   reduction   ? reduction : row->reduction,
     1009                                   label       ? label     : row->label,
     1010                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     1011                                   dvodb       ? dvodb     : NULL,
     1012                                   note        ? note      : NULL,
     1013                                   image_only,
     1014                                   minidvodb,
     1015                                   minidvodb_group,
     1016                                   minidvodb_name,
     1017                                   minidvodb_host
     1018                    )) {
     1019                if (!psDBRollback(config->dbh)) {
     1020                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     1021                }
     1022                psError(PS_ERR_UNKNOWN, false,
     1023                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     1024                psFree(row);
     1025                psFree(output);
     1026                return false;
     1027            }
     1028            psFree(row);
     1029        }
     1030    }
     1031    else if (strcmp(stage,"xcff") == 0) {
     1032        for (long i = 0; i < psArrayLength(output); i++) {
     1033            psMetadata *md = output->data[i];
     1034            psS64 stage_id =0;
     1035       
     1036            xcForceRunRow *row = xcForceRunObjectFromMetadata(md);
     1037            stage_id = row->xcff_id;
     1038            bool status = false;
     1039            psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
     1040            if (!status) {
     1041                psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
     1042                return false;
     1043            }
     1044       
     1045            if (!row) {
     1046                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     1047                psFree(output);
     1048                return false;
     1049            }
     1050       
     1051            // queue the exp
     1052            if (!pxaddQueueByCamID(config,
     1053                                   stage,
     1054                                   stage_id,
     1055                                   stage_extra1,
     1056                                   workdir     ? workdir   : row->workdir,
     1057                                   reduction   ? reduction : row->reduction,
     1058                                   label       ? label     : row->label,
     1059                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     1060                                   dvodb       ? dvodb     : NULL,
     1061                                   note        ? note      : NULL,
     1062                                   image_only,
     1063                                   minidvodb,
     1064                                   minidvodb_group,
     1065                                   minidvodb_name,
     1066                                   minidvodb_host
     1067                    )) {
     1068                if (!psDBRollback(config->dbh)) {
     1069                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     1070                }
     1071                psError(PS_ERR_UNKNOWN, false,
     1072                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     1073                psFree(row);
     1074                psFree(output);
     1075                return false;
     1076            }
     1077            psFree(row);
     1078        }
     1079    }
     1080    else if (strcmp(stage,"xcff_summary") == 0) {
     1081        for (long i = 0; i < psArrayLength(output); i++) {
     1082            psMetadata *md = output->data[i];
     1083            psS64 stage_id =0;
     1084       
     1085            xcForceRunRow *row = xcForceRunObjectFromMetadata(md);
     1086            stage_id = row->xcff_id;
     1087       
     1088            if (!row) {
     1089                psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     1090                psFree(output);
     1091                return false;
     1092            }
     1093       
     1094            // queue the exp
     1095            if (!pxaddQueueByCamID(config,
     1096                                   stage,
     1097                                   stage_id,
     1098                                   0,
     1099                                   workdir     ? workdir   : row->workdir,
     1100                                   reduction   ? reduction : row->reduction,
     1101                                   label       ? label     : row->label,
     1102                                   data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     1103                                   dvodb       ? dvodb     : NULL,
     1104                                   note        ? note      : NULL,
     1105                                   image_only,
     1106                                   minidvodb,
     1107                                   minidvodb_group,
     1108                                   minidvodb_name,
     1109                                   minidvodb_host
     1110                    )) {
     1111                if (!psDBRollback(config->dbh)) {
     1112                    psError(PS_ERR_UNKNOWN, false, "database error sfg");
     1113                }
     1114                psError(PS_ERR_UNKNOWN, false,
     1115                        "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     1116                psFree(row);
     1117                psFree(output);
     1118                return false;
     1119            }
     1120            psFree(row);
     1121        }
    9981122    }
    9991123    psFree(output);
  • branches/eam_branches/ippTools-20240208/src/addtoolConfig.c

    r41654 r42618  
    280280    PXOPT_ADD_MODE("-revertminidvodbprocessed","revert processed minidvobs",        ADDTOOL_MODE_REVERTMINIDVODBPROCESSED,     revertminidvodbprocessedArgs);
    281281    PXOPT_ADD_MODE("-updateminidvodbprocessed","change processed minidvodb properties",ADDTOOL_MODE_UPDATEMINIDVODBPROCESSED,  updateminidvodbprocessedArgs);
    282  
    283  
    284 
    285282
    286283    if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note: See TracChangeset for help on using the changeset viewer.