IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19618


Ignore:
Timestamp:
Sep 19, 2008, 12:39:17 PM (18 years ago)
Author:
eugene
Message:

do not require master and run for processedimfile query

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080918/ippTools/src/dettool_processedimfile.c

    r19092 r19618  
    165165    PS_ASSERT_PTR_NON_NULL(config, false);
    166166
    167     char *value = NULL;
     167    bool hasWhere = false;
    168168
    169169    PXOPT_LOOKUP_BOOL(included, config->args, "-included", false);
     
    173173
    174174    psMetadata *where = psMetadataAlloc();
    175     PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "==");
    176     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
    177     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
     175    PXOPT_COPY_S64(config->args, where, "-det_id", "detProcessedImfile.det_id", "==");
     176    PXOPT_COPY_S64(config->args, where, "-exp_id", "detProcessedImfile.exp_id", "==");
     177    PXOPT_COPY_STR(config->args, where, "-class_id", "detProcessedImfile.class_id", "==");
     178    PXOPT_COPY_STR(config->args, where, "-select_state", "detRun.state", "==");
     179    PXOPT_COPY_STR(config->args, where, "-select_mode", "detRun.mode", "==");
    178180
    179181    psString query = pxDataGet("dettool_processedimfile.sql");
     
    184186    }
    185187
    186     // add the two required restrictions: detRun.state and detRun.mode
    187     // NOTE the above query requires one of the following two WHERE statements
    188     {
    189         bool status;
    190         if ((value = psMetadataLookupStr(&status, config->args, "-select_state"))) {
    191             psStringAppend(&query, " WHERE detRun.state = '%s'", value);
    192         } else {
    193             psStringAppend(&query, " WHERE detRun.state = 'run'");
    194         }
    195         if ((value = psMetadataLookupStr(&status, config->args, "-select_mode"))) {
    196             psStringAppend(&query, " AND detRun.mode = '%s'", value);
    197         } else {
    198             psStringAppend(&query, " AND detRun.mode = 'master'");
    199         }
    200     }
    201 
    202188    if (psListLength(where->list)) {
    203         psString whereClause = psDBGenerateWhereConditionSQL(where, "detProcessedImfile");
    204         psStringAppend(&query, " AND %s", whereClause);
     189        psString whereClause = psDBGenerateWhereSQL(where, NULL);
     190        psStringAppend(&query, " %s", whereClause);
    205191        psFree(whereClause);
     192        hasWhere = true;
    206193    }
    207194    psFree (where);
     
    209196    // restrict search to included imfiles
    210197    if (included) {
    211         psStringAppend(&query, " AND detInputExp.include = 1");
     198        if (hasWhere) {
     199            psStringAppend(&query, " AND detInputExp.include = 1");
     200        } else {
     201            psStringAppend(&query, " WHERE detInputExp.include = 1");
     202        }
     203        hasWhere = true;
     204    }
     205
     206    if (hasWhere) {
     207        psStringAppend(&query, " AND");
     208    } else {
     209        psStringAppend(&query, " WHERE");
    212210    }
    213211
    214212    if (faulted) {
    215         // list only faulted rows
    216         psStringAppend(&query, " %s", "AND detProcessedImfile.fault != 0");
     213        psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
    217214    } else {
    218215        // don't list faulted rows
    219         psStringAppend(&query, " %s", "AND detProcessedImfile.fault = 0");
     216        psStringAppend(&query, " %s", " detProcessedImfile.fault = 0");
    220217    }
    221218
Note: See TracChangeset for help on using the changeset viewer.