IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 11, 2010, 3:01:34 PM (16 years ago)
Author:
bills
Message:

In addtool -definebyquery prevent queuing a new addRun if one already exists
for the given exposure in the target dvo database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/addtool.c

    r26911 r26915  
    9999    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
    100100    pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     101    pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    101102    PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    102103
     
    119120
    120121    // find the cam_id of all the exposures that we want to queue up.
    121     psString query = pxDataGet("addtool_find_cam_id.sql");
    122     if (!query) {
     122    psString bare_query = pxDataGet("addtool_find_cam_id.sql");
     123    if (!bare_query) {
    123124        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    124125        psFree(where);
    125126        return false;
    126127    }
     128
     129    // prevent queueing an addRun if a given exposure has already been added to
     130    // the given dvo database
     131    psString dvodb_string = NULL;
     132    if (dvodb) {
     133        // user supplied dvodb
     134        psStringAppend(&dvodb_string, "(previous_dvodb = '%s')", dvodb);
     135    } else {
     136        // inherit dvodb from camRun, avoid matching NULL
     137        psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)");
     138    }
     139    // Take the bare query and add the dvodb selector
     140    psString query = NULL;
     141    psStringAppend(&query, bare_query, dvodb_string);
     142    psFree(dvodb_string);
     143    psFree(bare_query);
    127144
    128145    // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE
     
    131148        psStringAppend(&query, " AND %s", whereClause);
    132149        psFree(whereClause);
     150    } else {
     151        psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     152        return false;
    133153    }
    134154    psFree(where);
Note: See TracChangeset for help on using the changeset viewer.