IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 30, 2006, 11:56:09 AM (20 years ago)
Author:
jhoblitt
Message:

add phase 3 masking support

File:
1 edited

Legend:

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

    r9392 r9790  
    3030static bool pendingimfileMode(pxConfig *config);
    3131static bool addprocessedexpMode(pxConfig *config);
     32static bool blockMode(pxConfig *config);
     33static bool maskedMode(pxConfig *config);
     34static bool unblockMode(pxConfig *config);
    3235
    3336# define MODECASE(caseName, func) \
     
    4851        MODECASE(P3TOOL_MODE_PENDINGIMFILE,     pendingimfileMode);
    4952        MODECASE(P3TOOL_MODE_ADDPROCESSEDEXP,   addprocessedexpMode);
     53        MODECASE(P3TOOL_MODE_BLOCK,             blockMode);
     54        MODECASE(P3TOOL_MODE_MASKED,            maskedMode);
     55        MODECASE(P3TOOL_MODE_UNBLOCK,           unblockMode);
    5056        default:
    5157            psAbort(argv[0], "invalid option (this should not happen)");
     
    7682            " LEFT JOIN p3ProcessedExp"
    7783            "   USING(exp_tag)"
     84            " LEFT JOIN p3Mask"
     85            "   ON p3PendingExp.label = p3Mask.label"
    7886            " WHERE"
    7987            "   p3ProcessedExp.exp_tag IS NULL"
     88            "   AND p3Mask.label IS NULL"
    8089    );
    8190
     
    132141
    133142    psString query = psStringCopy(
    134         "SELECT p2ProcessedImfile.*"
    135         " FROM p3PendingExp"
    136         " JOIN p2ProcessedImfile"
    137         " USING(exp_tag, p2_version)"
     143            "SELECT p2ProcessedImfile.*"
     144            " FROM p3PendingExp"
     145            " JOIN p2ProcessedImfile"
     146            "   USING(exp_tag, p2_version)"
     147            " LEFT JOIN p3ProcessedExp"
     148            "   USING(exp_tag)"
     149            " LEFT JOIN p3Mask"
     150            "   ON p3PendingExp.label = p3Mask.label"
     151            " WHERE"
     152            "   p3ProcessedExp.exp_tag IS NULL"
     153            "   AND p3Mask.label IS NULL"
    138154    );
    139155
     
    349365        zp_stdev,
    350366        pendingRow->p2_version,
    351         pendingRow->p3_version
     367        pendingRow->p3_version,
     368        pendingRow->label
    352369    );
    353370    psFree(pendingRow);
     
    364381    return true;
    365382}
     383
     384static bool blockMode(pxConfig *config)
     385{
     386    PS_ASSERT_PTR_NON_NULL(config, false);
     387
     388    bool status = false;
     389    psString label = psMetadataLookupStr(&status, config->args, "-label");
     390    if (!status) {
     391        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
     392        return false;
     393    }
     394    if (!label) {
     395        psError(PS_ERR_UNKNOWN, true, "-label is required");
     396        return false;
     397    }
     398
     399    if (!p3MaskInsert(config->dbh, label)) {
     400        psError(PS_ERR_UNKNOWN, false, "database error");
     401        return false;
     402    }
     403
     404    return true;
     405}
     406
     407static bool maskedMode(pxConfig *config)
     408{
     409    PS_ASSERT_PTR_NON_NULL(config, false);
     410
     411    psString query = psStringCopy("SELECT * FROM p3Mask");
     412
     413    if (!p_psDBRunQuery(config->dbh, query)) {
     414        psError(PS_ERR_UNKNOWN, false, "database error");
     415        psFree(query);
     416        return false;
     417    }
     418    psFree(query);
     419
     420    psArray *output = p_psDBFetchResult(config->dbh);
     421    if (!output) {
     422        psError(PS_ERR_UNKNOWN, false, "database error");
     423        return false;
     424    }
     425    if (!psArrayLength(output)) {
     426        // XXX check psError here
     427        psError(PS_ERR_UNKNOWN, false, "no p3Mask rows found");
     428        psFree(output);
     429        return true;
     430    }
     431
     432    bool simple = false;
     433    {
     434        bool status = false;
     435        simple = psMetadataLookupBool(&status, config->args, "-simple");
     436        if (!status) {
     437            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     438            return false;
     439        }
     440    }
     441
     442    // negative simple so the default is true
     443    if (!ippdbPrintMetadatas(stdout, output, "p3Mask", !simple)) {
     444        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     445        psFree(output);
     446        return false;
     447    }
     448
     449    psFree(output);
     450
     451    return true;
     452}
     453
     454static bool unblockMode(pxConfig *config)
     455{
     456    PS_ASSERT_PTR_NON_NULL(config, false);
     457
     458    bool status = false;
     459    psString label = psMetadataLookupStr(&status, config->args, "-label");
     460    if (!status) {
     461        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");
     462        return false;
     463    }
     464    if (!label) {
     465        psError(PS_ERR_UNKNOWN, true, "-label is required");
     466        return false;
     467    }
     468
     469    char *query = "DELETE FROM p3Mask WHERE label = '%s'";
     470
     471    if (!p_psDBRunQuery(config->dbh, query, label)) {
     472        psError(PS_ERR_UNKNOWN, false, "database error");
     473        psFree(query);
     474        return false;
     475    }
     476
     477    return true;
     478}
Note: See TracChangeset for help on using the changeset viewer.