IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2007, 12:11:08 PM (19 years ago)
Author:
jhoblitt
Message:

rework fault handling:

remove p2PendingImfile.fault
add p2ProcessedImfile.fault
remove -pendingimfile -fault
add -addprocessedimfile -code
add -processedimfile mode
rename -faultimfile -> -updatedprocessedimfile

File:
1 edited

Legend:

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

    r11024 r11033  
    3333static bool pendingimfileMode(pxConfig *config);
    3434static bool addprocessedimfileMode(pxConfig *config);
    35 static bool faultimfileMode(pxConfig *config);
     35static bool processedimfileMode(pxConfig *config);
     36static bool updateprocessedimfileMode(pxConfig *config);
    3637static bool blockMode(pxConfig *config);
    3738static bool maskedMode(pxConfig *config);
    3839static bool unblockMode(pxConfig *config);
     40
    3941static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile);
    4042static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp);
     
    5961        MODECASE(P2TOOL_MODE_PENDINGIMFILE,         pendingimfileMode);
    6062        MODECASE(P2TOOL_MODE_ADDPROCESSEDIMFILE,    addprocessedimfileMode);
    61         MODECASE(P2TOOL_MODE_FAULTIMFILE,           faultimfileMode);
     63        MODECASE(P2TOOL_MODE_PROCESSEDIMFILE,       processedimfileMode);
     64        MODECASE(P2TOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode);
    6265        MODECASE(P2TOOL_MODE_BLOCK,                 blockMode);
    6366        MODECASE(P2TOOL_MODE_MASKED,                maskedMode);
     
    183186    }
    184187
    185     bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
    186     if (!status) {
    187         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
    188         return false;
    189     }
    190 
    191188    // XXX does this need to be constrained so that it won't return any results
    192189    // if a match p2PendingExp hasn't been registered?
     
    212209    }
    213210
    214     if (faulted) {
    215         // list only faulted rows
    216         psStringAppend(&query, " %s", "AND p2PendingImfile.fault != 0");
    217     } else {
    218         // don't list faulted rows
    219         psStringAppend(&query, " %s", "AND p2PendingImfile.fault = 0");
    220     }
    221 
    222211    // treat limit == 0 as "no limit"
    223212    if (limit) {
     
    433422
    434423
    435 static bool faultimfileMode(pxConfig *config)
     424static bool processedimfileMode(pxConfig *config)
     425{
     426    PS_ASSERT_PTR_NON_NULL(config, NULL);
     427
     428    bool status = false;
     429    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     430    if (!status) {
     431        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit");
     432        return false;
     433    }
     434
     435    bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");
     436    if (!status) {
     437        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted");
     438        return false;
     439    }
     440
     441    // XXX does this need to be constrained so that it won't return any results
     442    // if a match p2PendingExp hasn't been registered?
     443    psString query = psStringCopy(
     444            "SELECT"
     445            "   p2ProcessedImfile.*,"
     446            "   rawScienceExp.camera"
     447            " FROM p2ProcessedImfile"
     448            " JOIN rawScienceExp"
     449            "   USING(exp_tag)"
     450            " WHERE "
     451            "   p2ProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too
     452        );
     453
     454    if (config->where) {
     455        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2ProcessedImfile");
     456        psStringAppend(&query, " AND %s", whereClause);
     457        psFree(whereClause);
     458    }
     459
     460    if (faulted) {
     461        // list only faulted rows
     462        psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault != 0");
     463    } else {
     464        // don't list faulted rows
     465        psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault = 0");
     466    }
     467
     468    // treat limit == 0 as "no limit"
     469    if (limit) {
     470        psString limitString = psDBGenerateLimitSQL(limit);
     471        psStringAppend(&query, " %s", limitString);
     472        psFree(limitString);
     473    }
     474
     475    if (!p_psDBRunQuery(config->dbh, query)) {
     476        psError(PS_ERR_UNKNOWN, false, "database error");
     477        psFree(query);
     478        return false;
     479    }
     480    psFree(query);
     481
     482    psArray *output = p_psDBFetchResult(config->dbh);
     483    if (!output) {
     484        psError(PS_ERR_UNKNOWN, false, "database error");
     485        return false;
     486    }
     487    if (!psArrayLength(output)) {
     488        // XXX check psError here
     489        psError(PS_ERR_UNKNOWN, false, "no p2ProcessedImfile rows found");
     490        psFree(output);
     491        return true;
     492    }
     493
     494    bool simple = false;
     495    {
     496        bool status = false;
     497        simple = psMetadataLookupBool(&status, config->args, "-simple");
     498        if (!status) {
     499            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     500            return false;
     501        }
     502    }
     503
     504    // negative simple so the default is true
     505    if (!ippdbPrintMetadatas(stdout, output, "p2ProcessedImfile", !simple)) {
     506        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     507        psFree(output);
     508        return false;
     509    }
     510
     511    psFree(output);
     512
     513    return true;
     514}
     515
     516
     517static bool updateprocessedimfileMode(pxConfig *config)
    436518{
    437519    PS_ASSERT_PTR_NON_NULL(config, false);
     
    444526    }
    445527
    446     if (!pxSetFaultCode(config->dbh, "p2PendingImfile", config->where, code)) {
     528    if (!pxSetFaultCode(config->dbh, "p2ProcessedImfile", config->where, code)) {
    447529        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    448530        return false;
     
    733815    }
    734816
     817    // default values
     818    psS8 code = psMetadataLookupS8(&status, config->args, "-code");
     819    if (!status) {
     820        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
     821        return false;
     822    }
     823
    735824    return p2ProcessedImfileRowAlloc(
    736825        imfile->exp_tag,
     
    744833        b2_uri,
    745834        imfile->p1_version,
    746         imfile->p2_version
     835        imfile->p2_version,
     836        code
    747837    );
    748838}
Note: See TracChangeset for help on using the changeset viewer.