IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 21, 2008, 12:12:59 PM (18 years ago)
Author:
eugene
Message:

adding cleanup mode functions (but not yet sql or cmd-line options); dropping guidetool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/ippTools/src/dettool_processedexp.c

    r18641 r18643  
    260260}
    261261
     262bool pendingcleanup_processedexpMode(pxConfig *config)
     263{
     264    PS_ASSERT_PTR_NON_NULL(config, NULL);
     265
     266    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false);
     267    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     268    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     269
     270    psMetadata *where = psMetadataAlloc();
     271    if (chip_id) {
     272        PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     273    }
     274    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     275
     276    psString query = pxDataGet("dettool_pendingcleanup_processedexp.sql");
     277    if (!query) {
     278        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     279        return false;
     280    }
     281
     282    if (where && psListLength(where->list)) {
     283        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     284        psStringAppend(&query, " AND %s", whereClause);
     285        psFree(whereClause);
     286    }
     287    psFree(where);
     288
     289    // treat limit == 0 as "no limit"
     290    if (limit) {
     291        psString limitString = psDBGenerateLimitSQL(limit);
     292        psStringAppend(&query, " %s", limitString);
     293        psFree(limitString);
     294    }
     295
     296    if (!p_psDBRunQuery(config->dbh, query)) {
     297        psError(PS_ERR_UNKNOWN, false, "database error");
     298        psFree(query);
     299        return false;
     300    }
     301    psFree(query);
     302
     303    psArray *output = p_psDBFetchResult(config->dbh);
     304    if (!output) {
     305        psError(PS_ERR_UNKNOWN, false, "database error");
     306        return false;
     307    }
     308    if (!psArrayLength(output)) {
     309        psTrace("dettool", PS_LOG_INFO, "no rows found");
     310        psFree(output);
     311        return true;
     312    }
     313
     314    // negative simple so the default is true
     315    if (!ippdbPrintMetadatas(stdout, output, "detPendingCleanup_processedexp", !simple)) {
     316        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     317        psFree(output);
     318        return false;
     319    }
     320
     321    psFree(output);
     322
     323    return true;
     324}
     325
     326
     327bool donecleanup_processedexpMode(pxConfig *config)
     328{
     329    PS_ASSERT_PTR_NON_NULL(config, NULL);
     330
     331    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     332    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     333
     334    psMetadata *where = psMetadataAlloc();
     335    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     336
     337    psString query = pxDataGet("dettool_donecleanup_processedexp.sql");
     338    if (!query) {
     339        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     340        return false;
     341    }
     342
     343    if (where && psListLength(where->list)) {
     344        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     345        psStringAppend(&query, " AND %s", whereClause);
     346        psFree(whereClause);
     347    }
     348    psFree(where);
     349
     350    // treat limit == 0 as "no limit"
     351    if (limit) {
     352        psString limitString = psDBGenerateLimitSQL(limit);
     353        psStringAppend(&query, " %s", limitString);
     354        psFree(limitString);
     355    }
     356
     357    if (!p_psDBRunQuery(config->dbh, query)) {
     358        psError(PS_ERR_UNKNOWN, false, "database error");
     359        psFree(query);
     360        return false;
     361    }
     362    psFree(query);
     363
     364    psArray *output = p_psDBFetchResult(config->dbh);
     365    if (!output) {
     366        psError(PS_ERR_UNKNOWN, false, "database error");
     367        return false;
     368    }
     369    if (!psArrayLength(output)) {
     370        psTrace("dettool", PS_LOG_INFO, "no rows found");
     371        psFree(output);
     372        return true;
     373    }
     374
     375    // negative simple so the default is true
     376    if (!ippdbPrintMetadatas(stdout, output, "detDoneCleanup_processedexp", !simple)) {
     377        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     378        psFree(output);
     379        return false;
     380    }
     381
     382    psFree(output);
     383
     384    return true;
     385}
     386
Note: See TracChangeset for help on using the changeset viewer.