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/warptool.c

    r28375 r29416  
    5252static bool pendingcleanuprunMode(pxConfig *config);
    5353static bool pendingcleanupwarpMode(pxConfig *config);
     54static bool revertcleanupMode(pxConfig *config);
    5455static bool donecleanupMode(pxConfig *config);
    5556static bool tocleanedskyfileMode(pxConfig *config);
     
    107108        MODECASE(WARPTOOL_MODE_PENDINGCLEANUPRUN,  pendingcleanuprunMode);
    108109        MODECASE(WARPTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupwarpMode);
     110        MODECASE(WARPTOOL_MODE_REVERTCLEANUP,      revertcleanupMode);
    109111        MODECASE(WARPTOOL_MODE_DONECLEANUP,        donecleanupMode);
    110112        MODECASE(WARPTOOL_MODE_TOCLEANEDSKYFILE,   tocleanedskyfileMode);
     
    18051807
    18061808
     1809static bool revertcleanupMode(pxConfig *config)
     1810{
     1811    PS_ASSERT_PTR_NON_NULL(config, false);
     1812
     1813    psMetadata *where = psMetadataAlloc();
     1814    PXOPT_COPY_S64(config->args, where, "-warp_id",    "warpSkyfile.warp_id", "==");
     1815    pxAddLabelSearchArgs (config, where, "-label",     "warpRun.label", "LIKE");
     1816    pxAddLabelSearchArgs (config, where, "-data_group",   "warpRun.data_group", "LIKE");
     1817
     1818    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
     1819
     1820    if (!psListLength(where->list)) {
     1821        psFree(where);
     1822        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
     1823        return false;
     1824    }
     1825    if (!state) {
     1826        state = "error_cleaned";
     1827    }
     1828    char *newState = NULL;
     1829    if (!strcmp(state, "error_cleaned")) {
     1830        newState = "goto_cleaned";
     1831    } else if (!strcmp(state, "error_purged")) {
     1832        newState = "goto_purged";
     1833    } else if (!strcmp(state, "error_scrubbed")) {
     1834        newState = "goto_scrubbed";
     1835    } else {
     1836        psError(PXTOOLS_ERR_CONFIG, true, "-state must be either error_cleaned, error_purged, or error_scrubbed");
     1837        return false;
     1838    }
     1839
     1840    psString query = pxDataGet("warptool_revertcleanup.sql");
     1841    if (!query) {
     1842        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1843        return false;
     1844    }
     1845
     1846    if (psListLength(where->list)) {
     1847        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1848        psStringAppend(&query, " AND %s", whereClause);
     1849        psFree(whereClause);
     1850    }
     1851    psFree(where);
     1852
     1853    if (!p_psDBRunQueryF(config->dbh, query, newState, state, state)) {
     1854        psError(PS_ERR_UNKNOWN, false, "database error");
     1855        psFree(query);
     1856        return false;
     1857    }
     1858    psFree(query);
     1859
     1860    int numDeleted = psDBAffectedRows(config->dbh);
     1861
     1862    psLogMsg("warptool", PS_LOG_INFO, "Reverted %d warpRuns and warpSkyfiles", numDeleted);
     1863
     1864    return true;
     1865}
    18071866static bool donecleanupMode(pxConfig *config)
    18081867{
Note: See TracChangeset for help on using the changeset viewer.