IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

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

    r18336 r18561  
    104104
    105105    // default
     106    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    106107    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    107     PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    108108
    109109    diffRunRow *run = diffRunRowAlloc(
     
    282282    PS_ASSERT_PTR_NON_NULL(config, false);
    283283
     284    psMetadata *where = psMetadataAlloc();
     285
     286    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diff_id", "==");
     287    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     288    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     289    PXOPT_COPY_STR(config->args, where,  "-tess_id", "tess_id", "==");
     290    PXOPT_COPY_STR(config->args, where,  "-kind", "kind", "==");
     291
    284292    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    285293    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     294    PXOPT_LOOKUP_BOOL(template, config->args, "-template", false);
    286295
    287296    // find all rawImfiles matching the default query
     
    292301    }
    293302
    294     if (config->where) {
    295         psString whereClause = psDBGenerateWhereSQL(config->where, NULL);
    296         psStringAppend(&query, " %s", whereClause);
     303    if (template) {
     304        // list only faulted rows
     305        psStringAppend(&query, " %s", "WHERE diffInputSkyfile.template != 0");
     306    } else {
     307        // don't list faulted rows
     308        psStringAppend(&query, " %s", "WHERE diffInputSkyfile.template = 0");
     309    }
     310
     311    if (psListLength(where->list)) {
     312        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     313        psStringAppend(&query, " AND %s", whereClause);
    297314        psFree(whereClause);
    298315    }
     316    psFree(where);
    299317
    300318    // treat limit == 0 as "no limit"
     
    351369    PS_ASSERT_PTR_NON_NULL(config, false);
    352370
     371    psMetadata *where = psMetadataAlloc();
     372    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diff_id", "==");
     373
    353374    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    354375    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    360381    }
    361382
    362     if (config->where) {
    363         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
     383    if (psListLength(where->list)) {
     384        psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile");
    364385        psStringAppend(&query, " AND %s", whereClause);
    365386        psFree(whereClause);
    366387    }
     388    psFree(where);
    367389
    368390    // treat limit == 0 as "no limit"
     
    418440{
    419441    PS_ASSERT_PTR_NON_NULL(config, false);
    420 
    421     // required
    422     PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);
    423 
    424     // default to 0
     442   
     443    PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); // required
    425444    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    426 
    427     PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
    428     if (code == 0 && !uri) {
    429         psError(PS_ERR_UNKNOWN, true, "-uri is required");
    430         return false;
    431     }
    432 
    433     PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
    434     if (code == 0 && !path_base) {
    435         psError(PS_ERR_UNKNOWN, true, "-path_base is required");
    436         return false;
    437     }
     445    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false);
     446    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", (code == 0), false);
    438447
    439448    // optional
     
    441450    PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
    442451    PXOPT_LOOKUP_F32(dtime_diff, config->args, "-dtime_diff", false, false);
    443     PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
    444     PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false);
    445452    PXOPT_LOOKUP_S32(stamps_num, config->args, "-stamps_num", false, false);
    446453    PXOPT_LOOKUP_F32(stamps_rms, config->args, "-stamps_rms", false, false);
    447454    PXOPT_LOOKUP_S32(sources, config->args, "-sources", false, false);
     455    PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
     456    PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false);
    448457
    449458    if (!psDBTransaction(config->dbh)) {
     
    495504    PS_ASSERT_PTR_NON_NULL(config, false);
    496505
     506    psMetadata *where = psMetadataAlloc();
     507    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diff_id", "==");
     508    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     509    PXOPT_COPY_STR(config->args, where, "-tess_id", "tess_id", "==");
     510
    497511    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    498512    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    504518    }
    505519
    506     if (config->where) {
    507         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
     520    if (psListLength(where->list)) {
     521        psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile");
    508522        psStringAppend(&query, " AND %s", whereClause);
    509523        psFree(whereClause);
    510524    }
     525    psFree(where);
    511526
    512527    // treat limit == 0 as "no limit"
     
    563578    PS_ASSERT_PTR_NON_NULL(config, false);
    564579
     580    psMetadata *where = psMetadataAlloc();
     581    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diff_id", "==");
     582    PXOPT_COPY_S16(config->args, where, "-code",     "fault", "==");
     583
    565584    psString query = pxDataGet("difftool_revertdiffskyfile.sql");
    566585    if (!query) {
     
    569588    }
    570589
    571     if (config->where) {
    572         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "diffSkyfile");
     590    if (psListLength(where->list)) {
     591        psString whereClause = psDBGenerateWhereConditionSQL(where, "diffSkyfile");
    573592        psStringAppend(&query, " AND %s", whereClause);
    574593        psFree(whereClause);
    575594    }
     595    psFree(where);
    576596
    577597    if (!p_psDBRunQuery(config->dbh, query)) {
     
    741761    PS_ASSERT_PTR_NON_NULL(config, false);
    742762
    743     // required options
    744     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
    745     PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
    746     PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false);
    747 
    748     // optional
     763    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options
     764    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); // required options
     765    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); // required options
     766    PXOPT_LOOKUP_S64(template_warp_id, config->args, "-template_warp_id", false, false);
    749767    PXOPT_LOOKUP_S64(template_stack_id, config->args, "-template_stack_id", false, false);
    750     PXOPT_LOOKUP_S64(template_warp_id, config->args, "-template_warp_id", false, false);
     768    PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false);
     769    PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false);
    751770
    752771    if (template_stack_id && template_warp_id) {
     
    760779    }
    761780
    762     PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false);
    763     PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false);
    764781    if (input_stack_id && input_warp_id) {
    765782        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Only one input can be defined.");
     
    787804    PS_ASSERT_PTR_NON_NULL(config, false);
    788805
    789     // required options
    790     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
    791 
    792     // default
     806    psMetadata *where = psMetadataAlloc();
     807
     808    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diff_id", "==");
     809    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     810    PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     811    PXOPT_COPY_STR(config->args, where,  "-tess_id", "tess_id", "==");
     812    PXOPT_COPY_STR(config->args, where,  "-kind", "kind", "==");
     813    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options
     814    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
     815    PXOPT_LOOKUP_BOOL(template, config->args, "-template", false);
    793816    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    794     PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    795817
    796818    // find all things to queue
     
    801823    }
    802824
    803     if (config->where) {
    804         psString whereClause = psDBGenerateWhereSQL(config->where, NULL);
    805         psStringAppend(&query, " %s", whereClause);
     825    if (template) {
     826        // list only faulted rows
     827        psStringAppend(&query, " %s", "WHERE diffInputSkyfile.template != 0");
     828    } else {
     829        // don't list faulted rows
     830        psStringAppend(&query, " %s", "WHERE diffInputSkyfile.template = 0");
     831    }
     832
     833    if (psListLength(where->list)) {
     834        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     835        psStringAppend(&query, " AND %s", whereClause);
    806836        psFree(whereClause);
    807837    }
     838    psFree(where);
    808839
    809840    if (!p_psDBRunQuery(config->dbh, query)) {
Note: See TracChangeset for help on using the changeset viewer.