IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9790


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

add phase 3 masking support

Location:
trunk/ippTools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/configure.ac

    r9764 r9790  
    1616PKG_CHECK_MODULES([PSLIB], [pslib >= 0.12.99])
    1717PKG_CHECK_MODULES([PSMODULES], [psmodules >= 0.12.0])
    18 PKG_CHECK_MODULES([IPPDB], [ippdb >= 0.0.52])
     18PKG_CHECK_MODULES([IPPDB], [ippdb >= 0.0.53])
    1919
    2020AC_PROG_PERL_MODULES(
  • 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}
  • trunk/ippTools/src/camtool.h

    r9392 r9790  
    2828    P3TOOL_MODE_PENDINGIMFILE,
    2929    P3TOOL_MODE_ADDPROCESSEDEXP,
     30    P3TOOL_MODE_BLOCK,
     31    P3TOOL_MODE_MASKED,
     32    P3TOOL_MODE_UNBLOCK
    3033} p3toolMode;
    3134
  • trunk/ippTools/src/camtoolConfig.c

    r9392 r9790  
    9393            "define banana 2", NULL);
    9494
     95    // -block
     96    psMetadata *blockArgs = psMetadataAlloc();
     97    psMetadataAddStr(blockArgs, PS_LIST_TAIL, "-label",  0,
     98            "name of a label to mask out", NULL);
     99   
     100    // -masked
     101    psMetadata *maskedArgs = psMetadataAlloc();
     102    psMetadataAddBool(maskedArgs, PS_LIST_TAIL, "-simple",  0,
     103            "use the simple output format", false);
     104   
     105    // -unblock
     106    psMetadata *unblockArgs = psMetadataAlloc();
     107    psMetadataAddStr(unblockArgs, PS_LIST_TAIL, "-label",  0,
     108            "name of a label to unmask", NULL);
     109
    95110#define PXTOOL_MODE(option, modeval, argset) \
    96111{ \
     
    116131    PXTOOL_MODE("-pendingimfile",P3TOOL_MODE_PENDINGIMFILE,pendingimfileArgs);
    117132    PXTOOL_MODE("-addprocessedexp", P3TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpArgs);
     133    PXTOOL_MODE("-block",        P3TOOL_MODE_BLOCK,          blockArgs);
     134    PXTOOL_MODE("-masked",       P3TOOL_MODE_MASKED,         maskedArgs);
     135    PXTOOL_MODE("-unblock",      P3TOOL_MODE_UNBLOCK,        unblockArgs);
    118136
    119137    bool argErr = false;
  • trunk/ippTools/src/chiptool.c

    r9765 r9790  
    711711        pendingExp->exp_tag,
    712712        pendingExp->p1_version,
    713         pendingExp->p2_version
     713        pendingExp->p2_version,
     714        pendingExp->label
    714715    );
    715716}
  • trunk/ippTools/src/pxtables.c

    r9764 r9790  
    6060    CREATE_TABLE(p3PendingExpCreateTable);
    6161    CREATE_TABLE(p3ProcessedExpCreateTable);
     62    CREATE_TABLE(p3MaskCreateTable);
    6263    CREATE_TABLE(detRunCreateTable);
    6364    CREATE_TABLE(detInputExpCreateTable);
     
    119120    DROP_TABLE(p3PendingExpDropTable);
    120121    DROP_TABLE(p3ProcessedExpDropTable);
     122    DROP_TABLE(p3MaskDropTable);
    121123    DROP_TABLE(detRunDropTable);
    122124    DROP_TABLE(detInputExpDropTable);
Note: See TracChangeset for help on using the changeset viewer.