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_normalizedexp.c

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