IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 14, 2006, 7:00:28 PM (20 years ago)
Author:
jhoblitt
Message:

fix a problem with -pending not being properly constrained
switch to the new psDBGenerateWhereConditionSQL() prototype
renamed conditional search for modes that use the newpsDBGenerateWhereConditionSQL()
fix -tostack SQL
add the 'new' & simplified -processed mode

File:
1 edited

Legend:

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

    r8334 r8344  
    116116
    117117    if (config->where) {
    118         psString whereClaus = psDBGenerateWhereConditionSQL(config->where);
     118        psString whereClaus = psDBGenerateWhereConditionSQL(config->where, "rawDetrendExp");
    119119        psStringAppend(&query, " AND %s", whereClaus);
    120120        psFree(whereClaus);
     
    751751    // get det_id from detInputExp.det_id
    752752    // get det_type from detRun.position
     753    //
     754    // det_id is in detInputExp
     755    // exp_id is in detInputExp
    753756    // det_id is not in detProccessedImfile
    754757    // exp_id is not in detProccessedImfile
     
    763766                " AND rawImfile.exp_id = detProcessedImfile.exp_id"
    764767                " AND rawImfile.class_id = detProcessedImfile.class_id"
    765             " WHERE detProcessedImfile.det_id IS NULL AND"
    766             " detProcessedImfile.exp_id IS NULL AND"
    767             " detProcessedImfile.class_id IS NULL"
     768            " WHERE"
     769            " detInputExp.det_id IS NOT NULL"
     770            " AND detInputExp.exp_id IS NOT NULL"
     771            " AND detProcessedImfile.det_id IS NULL"
     772            " AND detProcessedImfile.exp_id IS NULL"
     773            " AND detProcessedImfile.class_id IS NULL"
    768774        );
    769775
    770     // XXX search criterian are disabled
    771 #if 0
    772776    if (config->where) {
    773         psString whereClaus = psDBGenerateWhereConditionSQL(config->where);
     777        psString whereClaus = psDBGenerateWhereConditionSQL(config->where, "rawImfile");
    774778        psStringAppend(&query, " AND %s", whereClaus);
    775779        psFree(whereClaus);
    776780    }
    777 #endif
    778781
    779782    if (!p_psDBRunQuery(config->dbh, query)) {
     
    986989{
    987990    PS_ASSERT_PTR_NON_NULL(config, false);
    988 
    989     /*
    990 which returns a list of stacks that are ready to be performed.  This
    991 list includes the detrend id, iteration, class id and detrend types
    992 (note that class id is unique per detrend id).  In terms of the
    993 database, the command returns the list where the detrend id, iteration
    994 and class id triplet do not have an entry in detStackedImfile; the
    995 results are masked by entries in detResidExpAnalysis
    996 */
    997 
    998 //select detProcessedImfile.det_id, detRun.iteration, detProcessedImfile.class_id from detProcessedImfile LEFT JOIN detRun ON detProcessedImfile.det_id = detRun.position LEFT JOIN rawImfile ON detprocessedImfile.exp_id
    999991
    1000992    // select detRun.iteration
     
    10211013        "    ON detRun.position = detInputExp.det_id"
    10221014        "    AND detRun.iteration = detInputExp.iteration"
    1023         " LEFT JOIN rawImfile"
    1024         "    ON detInputExp.exp_id = rawImfile.exp_id"
    10251015        " LEFT JOIN detProcessedImfile"
    10261016        "    ON detInputExp.det_id = detProcessedImfile.det_id"
     
    10301020        "    AND detInputExp.iteration = detStackedImfile.iteration"
    10311021        "    AND detProcessedImfile.class_id = detStackedImfile.class_id"
     1022        " LEFT JOIN rawImfile"
     1023        "    ON detInputExp.exp_id = rawImfile.exp_id"
     1024        "    AND detProcessedImfile.class_id = rawImfile.class_id"
    10321025        " WHERE"
    10331026        "    detStackedImfile.det_id IS NULL"
    10341027        "    AND detStackedImfile.iteration IS NULL"
    10351028        "    AND detStackedImfile.class_id IS NULL"
     1029        " GROUP BY"
     1030        "    detProcessedImfile.class_id,"
     1031        "    rawImfile.class_id"
    10361032        " HAVING"
    10371033        "    COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)"
    10381034        );
    10391035
    1040     // XXX search criterian are disabled
     1036    // XXX does it make sens to accept any search params?
    10411037#if 0
    10421038    if (config->where) {
     
    10861082{
    10871083    PS_ASSERT_PTR_NON_NULL(config, false);
     1084
     1085    // select detRun.det_type
     1086    // select detProcessedImfile
     1087    psString query = psStringCopy(
     1088        " SELECT"
     1089        "   detRun.det_type,"
     1090        "   detProcessedImfile.*"
     1091        " FROM detProcessedImfile"
     1092        " JOIN detRun"
     1093        " ON detProcessedImfile.det_id = detRun.position"
     1094        );
     1095
     1096    // XXX search criterian are disabled
     1097#if 1
     1098    if (config->where) {
     1099        psString whereClaus = psDBGenerateWhereConditionSQL(config->where, "detProcessedImfile");
     1100        psStringAppend(&query, " AND %s", whereClaus);
     1101        psFree(whereClaus);
     1102    }
     1103#endif
     1104
     1105    if (!p_psDBRunQuery(config->dbh, query)) {
     1106        psError(PS_ERR_UNKNOWN, false, "database error");
     1107        psFree(query);
     1108        return false;
     1109    }
     1110    psFree(query);
     1111
     1112    psArray *output = p_psDBFetchResult(config->dbh);
     1113    if (!output) {
     1114        // XXX check psError here
     1115        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     1116        return false;
     1117    }
     1118
     1119    bool simple = false;
     1120    {
     1121        bool status = false;
     1122        simple = psMetadataLookupBool(&status, config->args, "-simple");
     1123        if (!status) {
     1124            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     1125            return false;
     1126        }
     1127    }
     1128
     1129    // negative simple so the default is true
     1130    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     1131        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1132        psFree(output);
     1133        return false;
     1134    }
     1135
     1136    psFree(output);
    10881137   
     1138    return true;
     1139}
     1140
     1141#if 0
     1142{
    10891143    // find all matching detProcessedImfiles where query should be
    10901144    // pre-generated the entry for iteration must be pruned from the default
     
    13391393    return true;
    13401394}
     1395#endif
    13411396
    13421397static bool addstackedMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.