IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 15, 2008, 10:30:59 AM (18 years ago)
Author:
eugene
Message:

completely deprecate config->where; make all command-line handling consistent; move nearly all sql into share/*.sql; ensure consistency between args supplied and used

File:
1 edited

Legend:

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

    r18402 r18561  
    297297    PS_ASSERT_PTR_NON_NULL(config, false);
    298298
    299     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    300     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    301     PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    302 
    303299    psMetadata *where = psMetadataAlloc();
    304300    PXOPT_COPY_S64(config->args, where,  "-exp_id", "exp_id", "==");
     
    306302    PXOPT_COPY_STR(config->args, where,  "-class_id", "class_id", "==");
    307303
     304    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     305    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
     306    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     307
    308308    psString query = pxDataGet("regtool_processedimfile.sql");
    309309    if (!query) {
     
    313313    }
    314314
    315     if (where) {
     315    if (psListLength(where->list)) {
    316316        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawImfile");
    317317        psStringAppend(&query, " AND %s", whereClause);
     
    381381    PS_ASSERT_PTR_NON_NULL(config, false);
    382382
     383    psMetadata *where = psMetadataAlloc();
     384    PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
     385    PXOPT_COPY_STR(config->args, where,  "-tmp_class_id", "tmp_class_id", "==");
     386    PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
     387    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
     388
    383389    psString query = pxDataGet("regtool_revertprocessedimfile.sql");
    384390    if (!query) {
    385391        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    386         return false;
    387     }
    388 
    389     if (config->where) {
    390         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawImfile");
     392        psFree(where);
     393        return false;
     394    }
     395
     396    if (psListLength(where->list)) {
     397        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawImfile");
    391398        psStringAppend(&query, " AND %s", whereClause);
    392399        psFree(whereClause);
    393400    }
     401    psFree(where);
    394402
    395403    if (!p_psDBRunQuery(config->dbh, query)) {
     
    413421    PS_ASSERT_PTR_NON_NULL(config, false);
    414422
     423    psMetadata *where = psMetadataAlloc();
     424    PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
     425    PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
     426
    415427    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    416428
    417     if (!pxSetFaultCode(config->dbh, "rawImfile", config->where, code)) {
     429    if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) {
    418430        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    419         return false;
    420     }
     431        psFree (where);
     432        return false;
     433    }
     434    psFree (where);
    421435
    422436    return true;
     
    511525
    512526    // optional
     527    PXOPT_LOOKUP_TIME(dateobs, config->args, "-dateobs", false, false);
     528    PXOPT_LOOKUP_STR(exp_type, config->args, "-exp_type", false, false);
     529    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
    513530    PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false);
    514531    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false);
    515532    PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false);
    516     PXOPT_LOOKUP_STR(exp_type, config->args, "-exp_type", false, false);
    517     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
    518533    PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false);
    519534    PXOPT_LOOKUP_STR(filter, config->args, "-filter", false, false);
     
    561576    PXOPT_LOOKUP_STR(label,  config->args, "-label", false, false);
    562577    PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
    563     PXOPT_LOOKUP_TIME(dateobs, config->args, "-dateobs", false, false);
    564578
    565579    // default
     
    789803    PS_ASSERT_PTR_NON_NULL(config, false);
    790804
    791     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    792     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    793     PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    794 
    795805    psString query = pxDataGet("regtool_processedexp.sql");
    796806    if (!query) {
     
    812822    PXOPT_COPY_STR(config->args, where,  "-reduction", "reduction", "==");
    813823    PXOPT_COPY_STR(config->args, where,  "-filter", "filter", "==");
    814     PXOPT_COPY_F64(config->args, where,  "-airmass_min", "airmass", ">=");
    815     PXOPT_COPY_F64(config->args, where,  "-airmass_max", "airmass", "<");
     824    PXOPT_COPY_F32(config->args, where,  "-airmass_min", "airmass", ">=");
     825    PXOPT_COPY_F32(config->args, where,  "-airmass_max", "airmass", "<");
    816826    PXOPT_COPY_F64(config->args, where,  "-ra_min", "ra", ">=");
    817827    PXOPT_COPY_F64(config->args, where,  "-ra_max", "ra", "<");
     
    832842    PXOPT_COPY_F64(config->args, where,  "-az_min", "az", ">=");
    833843    PXOPT_COPY_F64(config->args, where,  "-az_max", "az", "<");
    834     PXOPT_COPY_F32(config->args, where,  "-ccd_temp_min", "ccd_temp", ">=");
    835     PXOPT_COPY_F32(config->args, where,  "-ccd_temp_max", "ccd_temp", "<");
     844    PXOPT_COPY_F64(config->args, where,  "-ccd_temp_min", "ccd_temp", ">=");
     845    PXOPT_COPY_F64(config->args, where,  "-ccd_temp_max", "ccd_temp", "<");
    836846    PXOPT_COPY_F64(config->args, where,  "-posang_min", "posang", ">=");
    837847    PXOPT_COPY_F64(config->args, where,  "-posang_max", "posang", "<");
     
    839849    PXOPT_COPY_F32(config->args, where,  "-solang_min", "solang", ">=");
    840850    PXOPT_COPY_F32(config->args, where,  "-solang_max", "solang", "<");
     851
     852    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     853    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     854    PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);
    841855
    842856    if (psListLength(where->list)) {
     
    906920    PS_ASSERT_PTR_NON_NULL(config, false);
    907921
     922    psMetadata *where = psMetadataAlloc();
     923    PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
     924    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
     925
    908926    psString query = pxDataGet("regtool_revertprocessedexp.sql");
    909927    if (!query) {
    910928        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    911         return false;
    912     }
    913 
    914     if (config->where) {
    915         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp");
     929        psFree(where);
     930        return false;
     931    }
     932
     933    if (psListLength(where->list)) {
     934        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp");
    916935        psStringAppend(&query, " AND %s", whereClause);
     936        psFree(where);
    917937        psFree(whereClause);
    918938    }
     939    psFree(where);
    919940
    920941    if (!p_psDBRunQuery(config->dbh, query)) {
     
    938959    PS_ASSERT_PTR_NON_NULL(config, false);
    939960
     961    psMetadata *where = psMetadataAlloc();
     962    PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
     963
    940964    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
    941965
    942     if (!pxSetFaultCode(config->dbh, "rawExp", config->where, code)) {
     966    if (!pxSetFaultCode(config->dbh, "rawExp", where, code)) {
    943967        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    944         return false;
    945     }
     968        psFree(where);
     969        return false;
     970    }
     971    psFree(where);
    946972
    947973    return true;
Note: See TracChangeset for help on using the changeset viewer.