IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 14, 2010, 2:23:39 PM (16 years ago)
Author:
bills
Message:

fix tickeet 1198 add mode -revertcleanup to revert errors that occur when cleaning (or purging or scrubbing)

File:
1 edited

Legend:

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

    r28716 r29416  
    5050static bool pendingcleanuprunMode(pxConfig *config);
    5151static bool pendingcleanupimfileMode(pxConfig *config);
     52static bool revertcleanupMode(pxConfig *config);
    5253static bool donecleanupMode(pxConfig *config);
    5354static bool runMode(pxConfig *config);
     
    9495        MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPRUN,       pendingcleanuprunMode);
    9596        MODECASE(CHIPTOOL_MODE_PENDINGCLEANUPIMFILE,    pendingcleanupimfileMode);
     97        MODECASE(CHIPTOOL_MODE_REVERTCLEANUP,           revertcleanupMode);
    9698        MODECASE(CHIPTOOL_MODE_DONECLEANUP,             donecleanupMode);
    9799        MODECASE(CHIPTOOL_MODE_RUN,                     runMode);
     
    859861    }
    860862    psString query_update = pxDataGet("chiptool_revertupdatedimfile.sql");
    861     if (!query) {
     863    if (!query_update) {
    862864        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    863865        psFree(where);
    864866        return false;
    865867    }
     868
    866869
    867870    if (where && psListLength(where->list)) {
     
    886889    }
    887890    psFree(query_update);
     891
     892    return true;
     893}
     894static bool revertcleanupMode(pxConfig *config)
     895{
     896    PS_ASSERT_PTR_NON_NULL(config, false);
     897
     898    psMetadata *where = psMetadataAlloc();
     899    PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "==");
     900    pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "LIKE");
     901    pxAddLabelSearchArgs (config, where, "-data_group", "chipRun.data_group", "LIKE");
     902    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
     903
     904    char* newState = NULL;
     905    if (!state) {
     906        state = "error_cleaned";
     907    }
     908    if (!strcmp(state, "error_cleaned")) {
     909        newState = "goto_cleaned";
     910    } else if (!strcmp(state, "error_purged")) {
     911        newState = "goto_purged";
     912    } else if (!strcmp(state, "error_scrubbed")) {
     913        newState = "goto_scrubbed";
     914    } else {
     915        psError(PXTOOLS_ERR_CONFIG, true, "-state must be either error_cleaned, error_purged, or error_scrubbed");
     916        return false;
     917    }
     918
     919    if (!psListLength(where->list)) {
     920        psFree(where);
     921        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     922        return false;
     923    }
     924
     925    psString query = pxDataGet("chiptool_revertcleanup.sql");
     926    if (!query) {
     927        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     928        psFree(where);
     929        return false;
     930    }
     931
     932    if (where && psListLength(where->list)) {
     933        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     934        psStringAppend(&query, " AND %s", whereClause);
     935        psFree(whereClause);
     936    }
     937
     938    psFree(where);
     939
     940    if (!p_psDBRunQueryF(config->dbh, query, newState, state, state)) {
     941        psError(PS_ERR_UNKNOWN, false, "database error");
     942        psFree(query);
     943        return false;
     944    }
     945    psFree(query);
    888946
    889947    return true;
Note: See TracChangeset for help on using the changeset viewer.