IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2008, 2:26:10 PM (18 years ago)
Author:
jhoblitt
Message:

implement chiptool -revertproccessedimfile query support

File:
1 edited

Legend:

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

    r17161 r17186  
    151151    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
    152152
    153     if (!psListLength(where->list)) {
     153    if (!psListLength(where->list)
     154        && !psMetadataLookupBool(NULL, config->args, "-all")) {
    154155        psFree(where);
     156        where = NULL;
    155157        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
    156158        return false;
     
    176178    }
    177179
    178     if (where) {
     180    if (where && psListLength(where->list)) {
    179181        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp");
    180182        psFree(where);
     
    312314    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
    313315
    314     if (!psListLength(where->list)) {
     316    if (!psListLength(where->list)
     317        && !psMetadataLookupBool(NULL, config->args, "-all")) {
    315318        psFree(where);
     319        where = NULL;
    316320        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
    317321        return false;
     
    594598    PS_ASSERT_PTR_NON_NULL(config, false);
    595599
     600    psMetadata *where = psMetadataAlloc();
     601    PXOPT_LOOKUP_STR(chip_id, config->args, "-chip_id", false, false);
     602    // convert chip_id into a psS64
     603    if (chip_id) {
     604        if (!psMetadataAddS64(where, PS_LIST_TAIL, "chip_id", 0, "==", (psS64)atoll(chip_id))) {
     605            psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id");
     606            psFree(where);
     607            return false;
     608        }
     609    }
     610
     611    PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false);
     612    // convert exp_id into a psS64
     613    if (exp_id) {
     614        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) {
     615            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
     616            psFree(where);
     617            return false;
     618        }
     619    }
     620
     621    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
     622    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
     623    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
     624    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
     625    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
     626    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
     627    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
     628    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
     629    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
     630    PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     631    PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
     632    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
     633    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
     634    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
     635    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
     636    PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     637    PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
     638    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
     639    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
     640    PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">=");
     641    PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<");
     642    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
     643    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
     644    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
     645    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
     646    PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
     647    PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
     648    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
     649    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
     650    PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
     651    PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
     652    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
     653    PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     654    PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
     655    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
     656    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
     657
     658    if (!psListLength(where->list)
     659        && !psMetadataLookupBool(NULL, config->args, "-all")) {
     660        psFree(where);
     661        where = NULL;
     662        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     663        return false;
     664    }
     665
    596666    psString query = pxDataGet("chiptool_revertprocessedimfile.sql");
    597667    if (!query) {
     
    600670    }
    601671
    602     if (config->where) {
    603         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipProcessedImfile");
     672    if (where && psListLength(where->list)) {
     673        psString whereClause = psDBGenerateWhereConditionSQL(where, "chipProcessedImfile");
     674        psFree(where);
    604675        psStringAppend(&query, " AND %s", whereClause);
    605676        psFree(whereClause);
     
    612683    }
    613684    psFree(query);
    614 
    615     if (psDBAffectedRows(config->dbh) < 1) {
    616         psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");
    617         return false;
    618     }
    619685
    620686    return true;
Note: See TracChangeset for help on using the changeset viewer.